| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | #!/bin/sh - | | 1 | #!/bin/sh - |
2 | # $NetBSD: MAKEDEV.tmpl,v 1.118 2008/11/28 16:04:31 joerg Exp $ | | 2 | # $NetBSD: MAKEDEV.tmpl,v 1.119 2009/01/03 08:49:03 apb Exp $ |
3 | # | | 3 | # |
4 | # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc. | | 4 | # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc. |
5 | # All rights reserved. | | 5 | # All rights reserved. |
6 | # | | 6 | # |
7 | # Redistribution and use in source and binary forms, with or without | | 7 | # Redistribution and use in source and binary forms, with or without |
8 | # modification, are permitted provided that the following conditions | | 8 | # modification, are permitted provided that the following conditions |
9 | # are met: | | 9 | # are met: |
10 | # 1. Redistributions of source code must retain the above copyright | | 10 | # 1. Redistributions of source code must retain the above copyright |
11 | # notice, this list of conditions and the following disclaimer. | | 11 | # notice, this list of conditions and the following disclaimer. |
12 | # 2. Redistributions in binary form must reproduce the above copyright | | 12 | # 2. Redistributions in binary form must reproduce the above copyright |
13 | # notice, this list of conditions and the following disclaimer in the | | 13 | # notice, this list of conditions and the following disclaimer in the |
14 | # documentation and/or other materials provided with the distribution. | | 14 | # documentation and/or other materials provided with the distribution. |
15 | # | | 15 | # |
| @@ -277,32 +277,39 @@ | | | @@ -277,32 +277,39 @@ |
277 | # twa 3ware Apache control interface | | 277 | # twa 3ware Apache control interface |
278 | # twe 3ware Escalade control interface | | 278 | # twe 3ware Escalade control interface |
279 | # uk* unknown SCSI device | | 279 | # uk* unknown SCSI device |
280 | # veriexec verified executable fingerprint loader | | 280 | # veriexec verified executable fingerprint loader |
281 | # video* video capture devices | | 281 | # video* video capture devices |
282 | # view* generic interface to graphic displays (Amiga) | | 282 | # view* generic interface to graphic displays (Amiga) |
283 | # vmegen* generic VME access | | 283 | # vmegen* generic VME access |
284 | # wsfont* console font control | | 284 | # wsfont* console font control |
285 | # wsmux* wscons event multiplexor | | 285 | # wsmux* wscons event multiplexor |
286 | # xenevt Xen event interface | | 286 | # xenevt Xen event interface |
287 | | | 287 | |
288 | | | 288 | |
289 | # | | 289 | # |
290 | # Apart from a few lines right at the end, this file should consist | | 290 | # NOTE: |
291 | # entirely of function definitions. | | | |
292 | # | | 291 | # |
293 | # This file is used both as a standalone script (via "sh ./MAKEDEV all" | | 292 | # * MAKEDEV is used both as a standalone script (via "sh ./MAKEDEV |
294 | # or similar), and as a function library (via "MAKEDEV_AS_LIBRARY=1 . | | 293 | # all" or similar), and as a function library for MAKEDEV.local (via |
295 | # MAKEDEV" from MAKEDEV.local). | | 294 | # "MAKEDEV_AS_LIBRARY=1 . MAKEDEV"). Because of this, the script |
| | | 295 | # should consist almost entirely of function definitions, apart from a |
| | | 296 | # few lines right at the end. |
| | | 297 | # |
| | | 298 | # * MAKEDEV may be executed in an environment that is missing some |
| | | 299 | # common commands. For example, it may be executed from a minimal |
| | | 300 | # system used during installation, or it may be executed early in the |
| | | 301 | # boot sequence before most file systems have been mounted. It may |
| | | 302 | # also be executed in a cross-build environment on a non-NetBSD host. |
296 | # | | 303 | # |
297 | | | 304 | |
298 | usage() | | 305 | usage() |
299 | { | | 306 | { |
300 | cat 1>&2 << _USAGE_ | | 307 | cat 1>&2 << _USAGE_ |
301 | Usage: ${0##*/} [-fMs] [-m mknod] [-p pax] [-t mtree] special [...] | | 308 | Usage: ${0##*/} [-fMs] [-m mknod] [-p pax] [-t mtree] special [...] |
302 | Create listed special devices. Options: | | 309 | Create listed special devices. Options: |
303 | -f Force permissions to be updated on existing devices. | | 310 | -f Force permissions to be updated on existing devices. |
304 | -M Create memory file system. | | 311 | -M Create memory file system. |
305 | -m mknod Name of mknod(8) program. [\$TOOL_MKNOD or mknod] | | 312 | -m mknod Name of mknod(8) program. [\$TOOL_MKNOD or mknod] |
306 | -p pax Name of pax(1) program. [\$TOOL_PAX or pax] | | 313 | -p pax Name of pax(1) program. [\$TOOL_PAX or pax] |
307 | -s Generate mtree(8) specfile instead of creating devices. | | 314 | -s Generate mtree(8) specfile instead of creating devices. |
308 | -t mtree Name of mtree(8) program. [\$TOOL_MTREE or mtree] | | 315 | -t mtree Name of mtree(8) program. [\$TOOL_MTREE or mtree] |
| @@ -466,34 +473,52 @@ setup() | | | @@ -466,34 +473,52 @@ setup() |
466 | u_root="%uid_root%" | | 473 | u_root="%uid_root%" |
467 | u_uucp="%uid_uucp%" | | 474 | u_uucp="%uid_uucp%" |
468 | g_kmem="%gid_kmem%" | | 475 | g_kmem="%gid_kmem%" |
469 | g_ntpd="%gid_ntpd%" | | 476 | g_ntpd="%gid_ntpd%" |
470 | g_operator="%gid_operator%" | | 477 | g_operator="%gid_operator%" |
471 | g_wheel="%gid_wheel%" | | 478 | g_wheel="%gid_wheel%" |
472 | dialin=0 | | 479 | dialin=0 |
473 | dialout=524288 | | 480 | dialout=524288 |
474 | callunit=262144 | | 481 | callunit=262144 |
475 | | | 482 | |
476 | # only allow read&write for owner by default | | 483 | # only allow read&write for owner by default |
477 | umask 077 | | 484 | umask 077 |
478 | | | 485 | |
479 | # Check if we have fdesc mounted | | 486 | # Set fdesc_mounted=true if the fdesc file system is mounted |
| | | 487 | # on the current directory (typically "/dev"). |
| | | 488 | # Later, this will be used to suppress creation of device nodes |
| | | 489 | # that are supplied by the fdesc file system. |
| | | 490 | # |
| | | 491 | fdesc_mounted=false |
480 | if [ -d fd ]; then | | 492 | if [ -d fd ]; then |
481 | case "$(df fd)" in | | 493 | # Parse the output from "mount -u -o nosuchoption .". |
482 | *fdesc*) nofdesc=false;; | | 494 | # We don't parse the output from df(1) because that's |
483 | *) nofdesc=true;; | | 495 | # less likely to be available on install media. |
| | | 496 | # |
| | | 497 | # If the current directory is a mount point for the |
| | | 498 | # fdesc file system, then the expected output (whether |
| | | 499 | # or not the current user is root) is: |
| | | 500 | # mount_fdesc: -o suchoption: option not supported. |
| | | 501 | # |
| | | 502 | # If the current directory is not a mount point, then |
| | | 503 | # the expected output is: |
| | | 504 | # mount: .: unknown special file or file system. |
| | | 505 | # |
| | | 506 | # If we are not running on NetBSD, or mount(8) is not |
| | | 507 | # found, then we should get some other error message. |
| | | 508 | # |
| | | 509 | case "$({ LC_ALL=C mount -u -o nosuchoption . ; } 2>&1)" in |
| | | 510 | *mount_fdesc*) fdesc_mounted=true ;; |
484 | esac | | 511 | esac |
485 | else | | | |
486 | nofdesc=true | | | |
487 | fi | | 512 | fi |
488 | | | 513 | |
489 | # do_force requires mknod | | 514 | # do_force requires mknod |
490 | if $do_force; then | | 515 | if $do_force; then |
491 | if $do_mtree || $do_pax || $do_specfile; then | | 516 | if $do_mtree || $do_pax || $do_specfile; then |
492 | die "-f option works only with mknod" | | 517 | die "-f option works only with mknod" |
493 | fi | | 518 | fi |
494 | do_mknod=true | | 519 | do_mknod=true |
495 | fi | | 520 | fi |
496 | | | 521 | |
497 | # If no explicit method was specified on the command line or | | 522 | # If no explicit method was specified on the command line or |
498 | # forced above, then use one of mtree, pax, or mknod, in that | | 523 | # forced above, then use one of mtree, pax, or mknod, in that |
499 | # order of preference. | | 524 | # order of preference. |
| @@ -772,27 +797,27 @@ isdns) | | | @@ -772,27 +797,27 @@ isdns) |
772 | makedev isdn isdnctl isdnbchan0 isdnbchan1 isdntel0 isdntel1 isdnteld0 isdnteld1 isdntrc0 isdntrc1 | | 797 | makedev isdn isdnctl isdnbchan0 isdnbchan1 isdntel0 isdntel1 isdnteld0 isdnteld1 isdntrc0 isdntrc1 |
773 | ;; | | 798 | ;; |
774 | | | 799 | |
775 | std) | | 800 | std) |
776 | mkdev console c %cons_chr% 0 600 | | 801 | mkdev console c %cons_chr% 0 600 |
777 | mkdev constty c %cons_chr% 1 600 | | 802 | mkdev constty c %cons_chr% 1 600 |
778 | mkdev drum c %swap_chr% 0 640 $g_kmem | | 803 | mkdev drum c %swap_chr% 0 640 $g_kmem |
779 | mkdev kmem c %mem_chr% 1 640 $g_kmem | | 804 | mkdev kmem c %mem_chr% 1 640 $g_kmem |
780 | mkdev mem c %mem_chr% 0 640 $g_kmem | | 805 | mkdev mem c %mem_chr% 0 640 $g_kmem |
781 | mkdev null c %mem_chr% 2 666 | | 806 | mkdev null c %mem_chr% 2 666 |
782 | mkdev zero c %mem_chr% 12 666 | | 807 | mkdev zero c %mem_chr% 12 666 |
783 | mkdev klog c %log_chr% 0 600 | | 808 | mkdev klog c %log_chr% 0 600 |
784 | mkdev ksyms c %ksyms_chr% 0 444 | | 809 | mkdev ksyms c %ksyms_chr% 0 444 |
785 | if $nofdesc; then | | 810 | if ! $fdesc_mounted; then |
786 | mkdev tty c %ctty_chr% 0 666 | | 811 | mkdev tty c %ctty_chr% 0 666 |
787 | mkdev stdin c %filedesc_chr% 0 666 | | 812 | mkdev stdin c %filedesc_chr% 0 666 |
788 | mkdev stdout c %filedesc_chr% 1 666 | | 813 | mkdev stdout c %filedesc_chr% 1 666 |
789 | mkdev stderr c %filedesc_chr% 2 666 | | 814 | mkdev stderr c %filedesc_chr% 2 666 |
790 | fi | | 815 | fi |
791 | ;; | | 816 | ;; |
792 | | | 817 | |
793 | usb) | | 818 | usb) |
794 | mkdev usb c %usb_chr% 255 444 | | 819 | mkdev usb c %usb_chr% 255 444 |
795 | ;; | | 820 | ;; |
796 | | | 821 | |
797 | usb*) | | 822 | usb*) |
798 | unit=${i#usb} | | 823 | unit=${i#usb} |
| @@ -898,27 +923,27 @@ ttyE*) | | | @@ -898,27 +923,27 @@ ttyE*) |
898 | ;; | | 923 | ;; |
899 | | | 924 | |
900 | wsmouse*) | | 925 | wsmouse*) |
901 | unit=${i#wsmouse} | | 926 | unit=${i#wsmouse} |
902 | mkdev wsmouse$unit c %wsmouse_chr% $unit | | 927 | mkdev wsmouse$unit c %wsmouse_chr% $unit |
903 | ;; | | 928 | ;; |
904 | | | 929 | |
905 | wskbd*) | | 930 | wskbd*) |
906 | unit=${i#wskbd} | | 931 | unit=${i#wskbd} |
907 | mkdev wskbd$unit c %wskbd_chr% $unit | | 932 | mkdev wskbd$unit c %wskbd_chr% $unit |
908 | ;; | | 933 | ;; |
909 | | | 934 | |
910 | fd) | | 935 | fd) |
911 | if $nofdesc; then | | 936 | if ! $fdesc_mounted; then |
912 | makedir fd 755 | | 937 | makedir fd 755 |
913 | n=0 | | 938 | n=0 |
914 | while [ $n -lt 64 ] | | 939 | while [ $n -lt 64 ] |
915 | do | | 940 | do |
916 | mkdev fd/$n c %filedesc_chr% $n 666 | | 941 | mkdev fd/$n c %filedesc_chr% $n 666 |
917 | n=$(($n + 1)) | | 942 | n=$(($n + 1)) |
918 | done | | 943 | done |
919 | fi | | 944 | fi |
920 | ;; | | 945 | ;; |
921 | | | 946 | |
922 | wt*) | | 947 | wt*) |
923 | case $i in | | 948 | case $i in |
924 | wt*) name=wt; unit=${i#wt}; chr=%wt_chr%; blk=%wt_blk%;; | | 949 | wt*) name=wt; unit=${i#wt}; chr=%wt_chr%; blk=%wt_blk%;; |