Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 11 Aug 2009 17:07:49 +0000 (10:07 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 11 Aug 2009 17:07:49 +0000 (10:07 -0700)
32 files changed:
etc/defaults/compilers.conf
etc/defaults/make.conf
include/stdlib.h
lib/libc/gen/Makefile.inc
lib/libc/gen/devname.3
lib/libc/gen/fdevname.3 [deleted file]
lib/libc/gen/fdevname.c
lib/libc/gen/ttyname.c
share/installer/cmdnames.conf
share/man/man5/compilers.conf.5
share/man/man5/make.conf.5
sys/boot/pc32/boot2/Makefile
sys/config/VKERNEL_DEVFS [deleted file]
sys/dev/virtual/disk/vdisk.c
sys/kern/kern_conf.c
sys/kern/subr_disk.c
sys/net/i4b/driver/i4b_tel.c
sys/sys/device.h
sys/vfs/devfs/devfs.h
sys/vfs/devfs/devfs_core.c
sys/vfs/devfs/devfs_vnops.c
usr.sbin/devfsctl/Makefile
usr.sbin/devfsctl/devfsctl.c
usr.sbin/devfsctl/devfsctl.h [new file with mode: 0644]
usr.sbin/installer/dfuibe_installer/fn_configure.c
usr.sbin/installer/dfuibe_installer/fn_disk.c
usr.sbin/installer/dfuibe_installer/fn_subpart_hammer.c
usr.sbin/installer/dfuibe_installer/fn_subpart_ufs.c
usr.sbin/installer/libinstaller/commands.c
usr.sbin/installer/libinstaller/commands.h
usr.sbin/installer/libinstaller/confed.c
usr.sbin/installer/libinstaller/survey.c

index ea9ba41..a40512e 100644 (file)
@@ -2,8 +2,3 @@
 clang_CC=/usr/local/bin/clang
 clang_CFLAGS="-fno-color-diagnostics -std=gnu89"
 clang_VERSION=4.1.2
-
-# gcc44 from pkgsrc
-gcc44_CC=/usr/pkg/gcc44/bin/cc
-gcc44_CXX=/usr/pkg/gcc44/bin/c++
-gcc44_CPP=/usr/pkg/gcc44/bin/cpp
index 90232df..18738b9 100644 (file)
@@ -108,6 +108,7 @@ THREAD_LIB?=        thread_xu
 #NO_CVS=       true    # do not build CVS
 #NO_GAMES=     true    # do not enter the games subdirectory
 #NO_GCC34=     true    # do not build gcc-3.4
+#NO_GCC44=     true    # do not build gcc-4.4
 #NO_GDB=       true    # do not build GDB
 #NO_I4B=       true    # do not build isdn4bsd package
 #NO_IPFILTER=  true    # do not build IP Filter package
index 5fa5925..171498d 100644 (file)
@@ -243,7 +243,8 @@ void         arc4random_stir(void);
 __uint32_t
         arc4random_uniform(__uint32_t);
 char   *getbsize(int *, long *);
-                                       /* getcap(3) functions */
+
+/* getcap(3) functions */
 char   *cgetcap(char *, const char *, int);
 int     cgetclose(void);
 int     cgetent(char **, char **, const char *);
@@ -256,10 +257,10 @@ int        cgetstr(char *, const char *, char **);
 int     cgetustr(char *, const char *, char **);
 
 int     daemon(int, int);
-char   *fdevname(int);
-int    fdevname_r(int, char *, size_t);
 char   *devname(dev_t, mode_t);
 char   *devname_r(dev_t, mode_t, char *, size_t);
+char   *fdevname(int);
+int     fdevname_r(int, char *, size_t);
 int     getloadavg(double [], int);
 __const char *
         getprogname(void);
@@ -279,7 +280,7 @@ int  sradixsort(const unsigned char **, int, const unsigned char *,
 void    sranddev(void);
 void    srandomdev(void);
 long long
-       strtonum(const char *, long long, long long, const char **);
+        strtonum(const char *, long long, long long, const char **);
 
 /* Deprecated interfaces. */
 #if !defined(_KERNEL_VIRTUAL)
index ff774ec..4a7c246 100644 (file)
@@ -51,7 +51,7 @@ MAN+= alarm.3 arc4random.3 clock.3 \
        confstr.3 ctermid.3 ctype.3 daemon.3 \
        devname.3 directory.3 dirname.3 \
        dladdr.3 dlinfo.3 dlopen.3 \
-       err.3 exec.3 fdevname.3 \
+       err.3 exec.3 \
        fmtcheck.3 fmtmsg.3 fnmatch.3 fpclassify.3 frexp.3 ftok.3 fts.3 ftw.3 \
        getbootfile.3 getbsize.3 getcap.3 getcontext.3 getcwd.3 \
        getdevpath.3 \
@@ -85,7 +85,7 @@ MLINKS+=ctermid.3 ctermid_r.3
 MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \
        directory.3 readdir.3 directory.3 readdir_r.3 directory.3 rewinddir.3 \
        directory.3 seekdir.3 directory.3 telldir.3 directory.3 fdopendir.3
-MLINKS+=devname.3 devname_r.3
+MLINKS+=devname.3 devname_r.3 devname.3 fdevname.3 devname.3 fdevname_r.3
 MLINKS+=dlopen.3 dlclose.3 dlopen.3 dlerror.3 dlopen.3 dlsym.3
 MLINKS+=err.3 err_set_exit.3 err.3 err_set_file.3 err.3 errc.3 err.3 errx.3 \
        err.3 verr.3 err.3 verrc.3 err.3 verrx.3 err.3 vwarn.3 err.3 vwarnc.3 \
index 3683e5c..b6a5fa0 100644 (file)
 .\" $FreeBSD: src/lib/libc/gen/devname.3,v 1.7.2.7 2003/03/15 15:11:05 trhodes Exp $
 .\" $DragonFly: src/lib/libc/gen/devname.3,v 1.5 2007/05/17 08:19:00 swildner Exp $
 .\"
-.Dd July 18, 1999
+.Dd August 11, 2009
 .Dt DEVNAME 3
 .Os
 .Sh NAME
 .Nm devname ,
-.Nm devname_r
+.Nm devname_r ,
+.Nm fdevname ,
+.Nm fdevname_r
 .Nd get device name
 .Sh LIBRARY
 .Lb libc
 .Fn devname "dev_t dev" "mode_t type"
 .Ft char *
 .Fn devname_r "dev_t dev" "mode_t type" "char *buf" "size_t len"
+.Ft char *
+.Fn fdevname "int fd"
+.Ft int
+.Fn fdevname_r "int fd" "char *buf" "size_t len"
 .Sh DESCRIPTION
 The
 .Fn devname
-function returns a pointer to the name of the block or character
+and
+.Fn devname_r
+functions return a pointer to the name of the block or character
 device in
 .Pa /dev
 with a device number of
@@ -65,7 +73,9 @@ or
 .Dv S_IFCHR .
 To find the right name,
 .Fn devname
-first searches the device database created by
+and
+.Fn devname_r
+first search the device database created by
 .Xr dev_mkdb 8 ;
 if that fails, it will format the information encapsulated in
 .Fa dev
@@ -73,11 +83,74 @@ and
 .Fa type
 in a human-readable format.
 .Pp
+The
+.Fn fdevname
+and
+.Fn fdevname_r
+function obtain the device name directly from a file descriptor
+pointing to a character device.
+.Pp
 .Fn devname
+and
+.Fn fdevname
 returns a pointer to an internal static object; thus, subsequent calls will
 modify the same buffer.
 .Fn devname_r
-avoids this problem by taking a buffer and buffer length as arguments.
+and
+.Fn fdevname_r
+avoid this problem by taking a buffer
+.Fa buf
+and a buffer length
+.Fa len
+as arguments.
+.Sh RETURN VALUES
+The
+.Fn devname ,
+.Fn devname_r
+and
+.Fn fdevname
+functions return a pointer to the name of the block or character
+device in
+.Pa /dev
+if successful; otherwise
+.Dv NULL
+is returned.
+If
+.Fn fdevname
+fails,
+.Va errno
+is set to indicate the error.
+.Pp
+The
+.Fn fdevname_r
+function returns 0 if successful.
+Otherwise an error number is returned.
+.Sh ERRORS
+The
+.Fn fdevname
+and
+.Fn fdevname_r
+functions may fail and return the following error codes:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+is not a valid open file descriptor.
+.It Bq Er EINVAL
+The
+.Fa fd
+must belong to a character device.
+.El
+.Pp
+The
+.Fn fdevname_r
+function may fail and return the following error code:
+.Bl -tag -width Er
+.It Bq Er ERANGE
+The
+.Fa len
+argument is smaller than the length of the string to be returned.
+.El
 .Sh SEE ALSO
 .Xr stat 2 ,
 .Xr dev_mkdb 8
@@ -86,3 +159,14 @@ The
 .Fn devname
 function appeared in
 .Bx 4.4 .
+.Pp
+The
+.Fn devname_r
+function appeared in
+.Dx 1.0
+and the
+.Fn fdevname
+and
+.Fn fdevname_r
+functions appeared in
+.Dx 2.3 .
diff --git a/lib/libc/gen/fdevname.3 b/lib/libc/gen/fdevname.3
deleted file mode 100644 (file)
index 3683e5c..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-.\" Copyright (c) 1993
-.\"    The Regents of the University of California.  All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"    This product includes software developed by the University of
-.\"    California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     @(#)devname.3  8.2 (Berkeley) 4/29/95
-.\" $FreeBSD: src/lib/libc/gen/devname.3,v 1.7.2.7 2003/03/15 15:11:05 trhodes Exp $
-.\" $DragonFly: src/lib/libc/gen/devname.3,v 1.5 2007/05/17 08:19:00 swildner Exp $
-.\"
-.Dd July 18, 1999
-.Dt DEVNAME 3
-.Os
-.Sh NAME
-.Nm devname ,
-.Nm devname_r
-.Nd get device name
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/stat.h
-.In stdlib.h
-.Ft char *
-.Fn devname "dev_t dev" "mode_t type"
-.Ft char *
-.Fn devname_r "dev_t dev" "mode_t type" "char *buf" "size_t len"
-.Sh DESCRIPTION
-The
-.Fn devname
-function returns a pointer to the name of the block or character
-device in
-.Pa /dev
-with a device number of
-.Fa dev ,
-and a file type matching the one encoded in
-.Fa type
-which must be one of
-.Dv S_IFBLK
-or
-.Dv S_IFCHR .
-To find the right name,
-.Fn devname
-first searches the device database created by
-.Xr dev_mkdb 8 ;
-if that fails, it will format the information encapsulated in
-.Fa dev
-and
-.Fa type
-in a human-readable format.
-.Pp
-.Fn devname
-returns a pointer to an internal static object; thus, subsequent calls will
-modify the same buffer.
-.Fn devname_r
-avoids this problem by taking a buffer and buffer length as arguments.
-.Sh SEE ALSO
-.Xr stat 2 ,
-.Xr dev_mkdb 8
-.Sh HISTORY
-The
-.Fn devname
-function appeared in
-.Bx 4.4 .
index 58803fe..c4131c3 100644 (file)
@@ -53,29 +53,26 @@ static char fdevname_buf[sizeof(_PATH_DEV) + NAME_MAX];
 
 static once_t          fdevname_init_once = ONCE_INITIALIZER;
 static thread_key_t    fdevname_key;
-static int                     fdevname_keycreated = 0;
+static int             fdevname_keycreated = 0;
 
 int
 fdevname_r(int fd, char *buf, size_t len)
 {
        struct stat     sb;
        struct fiodname_args fa;
-       size_t used;
 
        *buf = '\0';
 
-       /* Must be a character device. */
-       if (_fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
-               return (ENOTTY);
+       /* Must be a valid file descriptor */
+       if (_fstat(fd, &sb))
+               return (EBADF);
 
-       /* Must have enough room */
-       if (len <= sizeof(_PATH_DEV))
-               return (ERANGE);
+       /* Must be a character device */
+       if (!S_ISCHR(sb.st_mode))
+               return (EINVAL);
 
-       strcpy(buf, _PATH_DEV);
-       used = strlen(buf);
-       fa.len = len - used;
-       fa.name = buf + used;
+       fa.len = len;
+       fa.name = buf;
        if (_ioctl(fd, FIODNAME, &fa) == -1) {
                return ERANGE;
        }
@@ -92,6 +89,7 @@ char *
 fdevname(int fd)
 {
        char    *buf;
+       int     error;
 
        if (thr_main() != 0)
                buf = fdevname_buf;
@@ -109,7 +107,9 @@ fdevname(int fd)
                }
        }
 
-       if (fdevname_r(fd, buf, sizeof fdevname_buf) != 0)
+       if (((error = fdevname_r(fd, buf, sizeof fdevname_buf))) != 0) {
+               errno = error;
                return (NULL);
+       }
        return (buf);
 }
index b22b8ea..da6a328 100644 (file)
@@ -66,12 +66,15 @@ ttyname_r(int fd, char *buf, size_t len)
 
        *buf = '\0';
 
+       /* Must be a valid file descriptor */
+       if (_fstat(fd, &sb))
+               return (EBADF);
+       /* Must be a character device */
+       if (!S_ISCHR(sb.st_mode))
+               return (ENOTTY);
        /* Must be a terminal. */
        if (!isatty(fd))
                return (ENOTTY);
-       /* Must be a character device. */
-       if (_fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
-               return (ENOTTY);
        /* Must have enough room */
        if (len <= sizeof(_PATH_DEV))
                return (ERANGE);
@@ -100,6 +103,7 @@ ttyname_keycreate(void)
 char *
 ttyname(int fd)
 {
+       int     error;
        char    *buf;
 
        if (thr_main() != 0)
@@ -118,7 +122,9 @@ ttyname(int fd)
                }
        }
 
-       if (ttyname_r(fd, buf, sizeof ttyname_buf) != 0)
+       if (((error = ttyname_r(fd, buf, sizeof ttyname_buf))) != 0) {
+               errno = error;
                return (NULL);
+       }
        return (buf);
 }
index f839339..7c0209d 100644 (file)
@@ -21,8 +21,6 @@ MKDIR=bin/mkdir
 MV=bin/mv
 RM=bin/rm
 SH=bin/sh
-TEST=bin/test
-TEST_DEV="$TEST -c"
 
 CHFLAGS=usr/bin/chflags
 DHCLIENT=sbin/dhclient
@@ -42,20 +40,14 @@ NEWFS_MSDOS=sbin/newfs_msdos
 NFSD=sbin/nfsd
 ROUTE=sbin/route
 SWAPON=sbin/swapon
-SYSCTL=sbin/sysctl
 UMOUNT=sbin/umount
 
 AWK=usr/bin/awk
-BASENAME=usr/bin/basename
-BC=usr/bin/bc
 BUNZIP2=usr/bin/bunzip2
-COMM=usr/bin/comm
 GREP=usr/bin/grep
 KILLALL=usr/bin/killall
 SED=usr/bin/sed
-SORT=usr/bin/sort
 TOUCH=usr/bin/touch
-TR=usr/bin/tr
 YES=usr/bin/yes
 
 TFTPD=usr/libexec/tftpd
index 9e1fcef..84da401 100644 (file)
@@ -29,7 +29,7 @@
 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd July 3, 2009
+.Dd August 11, 2009
 .Os
 .Dt COMPILERS.CONF 5
 .Sh NAME
@@ -88,19 +88,14 @@ with
 .Pp
 Once configured the compiler can then be used like this:
 .Bd -literal -offset indent
-cd /usr/pkgsrc/wip/gcc44
-[build and install gcc44]
+[build and install clang]
 cd /usr/src
-env WORLD_CCVER=gcc44 make buildworld
+env WORLD_CCVER=clang make buildworld
 .Ed
 .Pp
-Defaults are provided for
+Currently, defaults are provided for
 .Nm clang
-(installed from SVN trunk)
-and
-.Nm gcc44
-(installed from
-.Pa pkgsrc/wip ) .
+(installed from SVN trunk).
 .Sh FILES
 .Bl -tag -width ".Pa /etc/compilers.conf" -compact
 .It Pa /etc/compilers.conf
index 0575f38..c40eb4d 100644 (file)
@@ -25,7 +25,7 @@
 .\" $FreeBSD: src/share/man/man5/make.conf.5,v 1.12.2.30 2003/05/18 17:05:55 brueffer Exp $
 .\" $DragonFly: src/share/man/man5/make.conf.5,v 1.38 2008/11/03 00:25:45 pavalos Exp $
 .\"
-.Dd August 6, 2009
+.Dd August 11, 2009
 .Dt MAKE.CONF 5
 .Os
 .Sh NAME
@@ -335,6 +335,9 @@ Set to not build games.
 .It Va NO_GCC34
 .Pq Vt bool
 Set to not build the older version of GCC (3.4).
+.It Va NO_GCC44
+.Pq Vt bool
+Set to not build the newer version of GCC (4.4).
 .It Va NO_GDB
 .Pq Vt bool
 Set to not build
index 92006e1..1896bcb 100644 (file)
@@ -54,6 +54,8 @@ CFLAGS=       -elf -ffreestanding -Os -fno-builtin \
        -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
        -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
 
+DEBUG_FLAGS=
+
 # Tell gcc that it shouldn't do fancy optimizations for newer processors.
 # Otherwise it winds up creating larger code and we won't be able to fit boot2.
 CFLAGS+= -march=i386
diff --git a/sys/config/VKERNEL_DEVFS b/sys/config/VKERNEL_DEVFS
deleted file mode 100644 (file)
index f9d5b4b..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-# VKERNEL - configuration for a virtual kernel
-#
-# $DragonFly: src/sys/config/VKERNEL,v 1.14 2008/11/09 18:57:17 dillon Exp $
-
-platform       vkernel         # platform architecture (i386, vkernel, etc)
-machine                i386
-machine_arch   i386            # cpu architecture (i386, etc)
-ident          VKERNEL
-maxusers       0
-
-makeoptions    DEBUG=-g
-
-cpu            I586_CPU
-cpu            I686_CPU
-
-options                DEBUG_PCTRACK
-
-options                KTR
-options                KTR_GIANT_CONTENTION
-options                KTR_SPIN_CONTENTION
-#options       DEBUG_CRIT_SECTIONS
-
-options                QUOTA
-options                DUMMYNET
-options         IPFIREWALL              #firewall
-options                IPFIREWALL_FORWARD      #enable transparent proxy support
-options                IPFIREWALL_DEFAULT_TO_ACCEPT    #allow everything by default
-
-# ALTQ
-options         ALTQ            #alternate queueing
-options         ALTQ_CBQ        #class based queueing
-options         ALTQ_RED        #random early detection
-options         ALTQ_RIO        #triple red for diffserv (needs RED)
-options         ALTQ_HFSC       #hierarchical fair service curve
-options         ALTQ_PRIQ       #priority queue
-options                ALTQ_FAIRQ      #fair queue
-#options        ALTQ_NOPCC      #don't use processor cycle counter
-options         ALTQ_DEBUG      #for debugging
-
-options                IPSEC                   #IP security
-options                IPSEC_ESP               #IP security (crypto; define w/ IPSEC)
-options                IPSEC_DEBUG             #debug for IP security
-
-options                DEVFS
-options                HAMMER
-options                EXT2FS
-options        INET                    #InterNETworking
-options        INET6                   #IPv6 communications protocols
-options        FFS                     #Berkeley Fast Filesystem
-options        FFS_ROOT                #FFS usable as root device [keep this!]
-options        SOFTUPDATES             #Enable FFS soft updates support
-options        UFS_DIRHASH             #Improve performance on big directories
-options        MFS                     #Memory Filesystem
-options        MD_ROOT                 #MD is a potential root device
-options        NFS                     #Network Filesystem
-options        NFS_ROOT                #NFS usable as root device, NFS required
-options        MSDOSFS                 #MSDOS Filesystem
-options        CD9660                  #ISO 9660 Filesystem
-options        PROCFS                  #Process filesystem
-options        COMPAT_43               #Compatible with BSD 4.3 [KEEP THIS!]
-options                COMPAT_DF12             #Compatible with DragonFly 1.2 and earlier
-options                DEVICE_POLLING          # Support mixed interrupt-polling
-                                       # handling of network device drivers
-options        UCONSOLE                #Allow users to grab the console
-options        KTRACE                  #ktrace(1) support
-options        SYSVSHM                 #SYSV-style shared memory
-options        SYSVMSG                 #SYSV-style message queues
-options        SYSVSEM                 #SYSV-style semaphores
-options        P1003_1B                #Posix P1003_1B real-time extensions
-options        _KPOSIX_PRIORITY_SCHEDULING
-options        ICMP_BANDLIM            #Rate limit bad replies
-
-options        SMP                     # Symmetric MultiProcessor Kernel
-
-# Debugging for Development
-options        DDB
-options        DDB_TRACE
-options        INVARIANTS
-
-#options       CARP
-
-# Floating point support - do not disable.
-device         npx0    at nexus?
-
-# Pseudo devices - the number indicates how many units to allocate.
-pseudo-device  loop            # Network loopback
-pseudo-device  ether           # Ethernet support
-pseudo-device  sl      1       # Kernel SLIP
-pseudo-device  ppp     1       # Kernel PPP
-pseudo-device  tun             # Packet tunnel.
-pseudo-device  pty             # Pseudo-ttys (telnet etc)
-pseudo-device  md              # Memory "disks"
-pseudo-device  gif             # IPv6 and IPv4 tunneling
-pseudo-device  faith   1       # IPv6-to-IPv4 relaying (translation)
-
-#pseudo-device carp
-
-# The `bpf' pseudo-device enables the Berkeley Packet Filter.
-# Be aware of the administrative consequences of enabling this!
-pseudo-device  bpf             #Berkeley packet filter
-
-# VIRTUAL DEVICES
-#
-device         vn
-device         vkd
-device         vke
-
-device         vcd
index cc5dadc..4f0291e 100644 (file)
@@ -139,7 +139,7 @@ static int
 vkdopen(struct dev_open_args *ap)
 {
        struct vkd_softc *sc;
-       struct disk_info info;
+       /* struct disk_info info; */
        struct stat st;
        cdev_t dev;
 
index 4a47dbd..0b778b2 100644 (file)
@@ -174,7 +174,7 @@ makeudev(int x, int y)
  * its cred requirements and name (XXX DEVFS interface).
  */
 cdev_t
-make_dev(struct dev_ops *ops, int minor, uid_t uid, gid_t gid, 
+make_dev(struct dev_ops *ops, int minor, uid_t uid, gid_t gid,
        int perms, const char *fmt, ...)
 {
        cdev_t  devfs_dev;
@@ -322,6 +322,8 @@ make_dev_alias(cdev_t target, const char *fmt, ...)
        return 0;
 }
 
+extern struct dev_ops default_dev_ops;
+
 cdev_t
 make_autoclone_dev(struct dev_ops *ops, struct devfs_bitmap *bitmap,
                d_clone_t *nhandler, uid_t uid, gid_t gid, int perms, const char *fmt, ...)
@@ -336,13 +338,29 @@ make_autoclone_dev(struct dev_ops *ops, struct devfs_bitmap *bitmap,
        name[i] = '\0';
        __va_end(ap);
 
-       devfs_clone_bitmap_init(bitmap);
+       if (bitmap != NULL)
+               devfs_clone_bitmap_init(bitmap);
+
        devfs_clone_handler_add(name, nhandler);
-       dev = make_dev(ops, 0xffff00ff, uid, gid, perms, name);
+       dev = make_dev(&default_dev_ops, 0xffff00ff, uid, gid, perms, name);
 
        return dev;
 }
 
+void
+destroy_autoclone_dev(cdev_t dev, struct devfs_bitmap *bitmap)
+{
+       if (dev == NULL)
+               return;
+
+       devfs_clone_handler_del(dev->si_name);
+
+       if (bitmap != NULL)
+               devfs_clone_bitmap_uninit(bitmap);
+
+       destroy_dev(dev);
+}
+
 
 /*
  * Add a reference to a device.  Callers generally add their own references
@@ -361,7 +379,7 @@ reference_dev(cdev_t dev)
        if (dev != NULL) {
                sysref_get(&dev->si_sysref);
                if (dev_ref_debug & 2) {
-                       kprintf("reference dev %p %s(minor=%08x) refs=%d\n", 
+                       kprintf("reference dev %p %s(minor=%08x) refs=%d\n",
                            dev, devtoname(dev), dev->si_uminor,
                            dev->si_sysref.refcnt);
                }
index 29db992..6ae2731 100644 (file)
@@ -1,13 +1,13 @@
 /*
  * Copyright (c) 2003,2004,2009 The DragonFly Project.  All rights reserved.
- * 
+ *
  * This code is derived from software contributed to The DragonFly Project
  * by Matthew Dillon <dillon@backplane.com>
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
@@ -17,7 +17,7 @@
  * 3. Neither the name of The DragonFly Project nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific, prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -30,7 +30,7 @@
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * ----------------------------------------------------------------------------
  * "THE BEER-WARE LICENSE" (Revision 42):
  * <phk@FreeBSD.ORG> wrote this file.  As long as you retain this notice you
@@ -118,7 +118,7 @@ static void disk_probe(struct disk *dp, int reprobe);
 static void _setdiskinfo(struct disk *disk, struct disk_info *info);
 
 static d_open_t diskopen;
-static d_close_t diskclose; 
+static d_close_t diskclose;
 static d_ioctl_t diskioctl;
 static d_strategy_t diskstrategy;
 static d_psize_t diskpsize;
@@ -304,8 +304,10 @@ disk_probe(struct disk *dp, int reprobe)
                 * Probe appropriate slices for a disklabel
                 *
                 * XXX slice type 1 used by our gpt probe code.
+                * XXX slice type 0 used by mbr compat slice.
                 */
-               if (sp->ds_type == DOSPTYP_386BSD || sp->ds_type == 1) {
+               if (sp->ds_type == DOSPTYP_386BSD || sp->ds_type == 0 ||
+                       sp->ds_type == 1) {
                        if (dp->d_slice->dss_first_bsd_slice == 0)
                                dp->d_slice->dss_first_bsd_slice = i;
                        disk_probe_slice(dp, ndev, i, reprobe);
@@ -506,11 +508,11 @@ _setdiskinfo(struct disk *disk, struct disk_info *info)
         */
        KKASSERT(info->d_media_size == 0 || info->d_media_blksize == 0);
        if (info->d_media_size == 0 && info->d_media_blocks) {
-               info->d_media_size = (u_int64_t)info->d_media_blocks * 
+               info->d_media_size = (u_int64_t)info->d_media_blocks *
                                     info->d_media_blksize;
-       } else if (info->d_media_size && info->d_media_blocks == 0 && 
+       } else if (info->d_media_size && info->d_media_blocks == 0 &&
                   info->d_media_blksize) {
-               info->d_media_blocks = info->d_media_size / 
+               info->d_media_blocks = info->d_media_size /
                                       info->d_media_blksize;
        }
 
@@ -589,7 +591,7 @@ disk_unprobe(struct disk *disk)
        disk_msg_send_sync(DISK_UNPROBE, disk, NULL);
 }
 
-void 
+void
 disk_invalidate (struct disk *disk)
 {
        if (disk->d_slice)
@@ -612,7 +614,7 @@ disk_enumerate(struct disk *disk)
        return dp;
 }
 
-static 
+static
 int
 sysctl_disks(SYSCTL_HANDLER_ARGS)
 {
@@ -638,7 +640,7 @@ sysctl_disks(SYSCTL_HANDLER_ARGS)
        error = SYSCTL_OUT(req, "", 1);
        return error;
 }
+
 SYSCTL_PROC(_kern, OID_AUTO, disks, CTLTYPE_STRING | CTLFLAG_RD, NULL, 0,
     sysctl_disks, "A", "names of available disks");
 
@@ -698,13 +700,13 @@ diskopen(struct dev_open_args *ap)
        if (!dsisopen(dp->d_slice)) {
                dev_dclose(dp->d_rawdev, ap->a_oflags, ap->a_devtype);
        }
-out:   
+out:
        dp->d_flags &= ~DISKFLAG_LOCK;
        if (dp->d_flags & DISKFLAG_WANTED) {
                dp->d_flags &= ~DISKFLAG_WANTED;
                wakeup(dp);
        }
-       
+
        return(error);
 }
 
@@ -730,7 +732,7 @@ diskclose(struct dev_close_args *ap)
 }
 
 /*
- * First execute the ioctl on the disk device, and if it isn't supported 
+ * First execute the ioctl on the disk device, and if it isn't supported
  * try running it on the backing device.
  */
 static
@@ -820,7 +822,7 @@ diskpsize(struct dev_psize_args *ap)
  * When new device entries are instantiated, make sure they inherit our
  * si_disk structure and block and iosize limits from the raw device.
  *
- * This routine is always called synchronously in the context of the 
+ * This routine is always called synchronously in the context of the
  * client.
  *
  * XXX The various io and block size constraints are not always initialized
@@ -859,10 +861,10 @@ diskdump(struct dev_dump_args *ap)
 }
 
 
-SYSCTL_INT(_debug_sizeof, OID_AUTO, diskslices, CTLFLAG_RD, 
+SYSCTL_INT(_debug_sizeof, OID_AUTO, diskslices, CTLFLAG_RD,
     0, sizeof(struct diskslices), "sizeof(struct diskslices)");
 
-SYSCTL_INT(_debug_sizeof, OID_AUTO, disk, CTLFLAG_RD, 
+SYSCTL_INT(_debug_sizeof, OID_AUTO, disk, CTLFLAG_RD,
     0, sizeof(struct disk), "sizeof(struct disk)");
 
 /*
@@ -894,14 +896,14 @@ bioqdisksort(struct bio_queue_head *bioq, struct bio *bio)
        struct bio *bq;
        struct bio *bn;
        struct bio *be;
-       
+
        be = TAILQ_LAST(&bioq->queue, bio_queue);
 
        /*
         * If the queue is empty or we are an
         * ordered transaction, then it's easy.
         */
-       if ((bq = bioq_first(bioq)) == NULL || 
+       if ((bq = bioq_first(bioq)) == NULL ||
            (bio->bio_buf->b_flags & B_ORDERED) != 0) {
                bioq_insert_tail(bioq, bio);
                return;
index 859fef3..b19413b 100644 (file)
@@ -157,7 +157,6 @@ static struct dev_ops i4btel_ops = {
        .d_poll =       POLLFIELD,
 };
 
-PDEVSTATIC void i4btelinit(void *unused);
 PDEVSTATIC void i4btelattach(void *);
 
 PSEUDO_SET(i4btelattach, i4b_tel);
index a46dccc..10684e0 100644 (file)
@@ -1,13 +1,13 @@
 /*
  * Copyright (c) 2003,2004,2007 The DragonFly Project.  All rights reserved.
- * 
+ *
  * This code is derived from software contributed to The DragonFly Project
  * by Matthew Dillon <dillon@backplane.com>
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
@@ -17,7 +17,7 @@
  * 3. Neither the name of The DragonFly Project nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific, prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -30,7 +30,7 @@
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * $DragonFly: src/sys/sys/device.h,v 1.11 2007/05/17 03:02:00 dillon Exp $
  */
 
@@ -168,11 +168,12 @@ struct dev_kqfilter_args {
  */
 struct dev_clone_args {
        struct dev_generic_args a_head;
-       struct cdev *a_dev;
-       struct ucred *a_cred;
 
-       char    *a_name;
-       size_t  a_namelen;
+       struct cdev     *a_dev;
+       const char      *a_name;
+       size_t          a_namelen;
+       struct ucred    *a_cred;
+       int             a_mode;
 };
 
 /*
@@ -372,6 +373,7 @@ void destroy_only_dev(cdev_t dev);
 int make_dev_alias(cdev_t target, const char *fmt, ...);
 cdev_t make_autoclone_dev(struct dev_ops *ops, struct devfs_bitmap *bitmap,
                d_clone_t *nhandler, uid_t uid, gid_t gid, int perms, const char *fmt, ...);
+void destroy_autoclone_dev(cdev_t dev, struct devfs_bitmap *bitmap);
 #endif
 
 #endif
index cb97bf9..9a1541a 100644 (file)
@@ -134,9 +134,9 @@ struct devfs_mnt_data {
 };
 
 struct devfs_clone_handler {
-       char            *name;
+       char            *name;
        u_char          namlen;
-       d_clone_t       *nhandler;
+       d_clone_t       *nhandler;
        TAILQ_ENTRY(devfs_clone_handler) link;
 };
 
@@ -157,14 +157,14 @@ typedef struct devfs_msg {
                        cdev_t  dev;
                        uid_t   uid;
                        gid_t   gid;
-                       int             perms;
+                       int     perms;
                } __m_dev;
                struct {
                        struct devfs_mnt_data *mnt;
                } __m_mnt;
                struct {
-                       char            *name;
-                       d_clone_t       *nhandler;
+                       const char      *name;
+                       d_clone_t       *nhandler;
                } __m_chandler;
                struct {
                        void *load;
@@ -179,31 +179,31 @@ typedef struct devfs_msg {
                        cdev_t  cdev;
                } __m_cdev;
                struct {
-                       char *name;
+                       char    *name;
                } __m_name;
                struct {
-                       char *basename;
-                       u_char unit;
+                       char    *basename;
+                       u_char  unit;
                        struct vnode *vp;
                } __m_clone;
                struct {
                        struct devfs_node *node;
                } __m_node;
                struct {
-                       char *name;
-                       char *target;
+                       char    *name;
+                       char    *target;
                        struct mount *mp;
                } __m_link;
                struct {
                        struct dev_ops *ops;
-                       int minor;
+                       int     minor;
                } __m_ops;
                struct {
-                       char *name;
-                       uint32_t flag;
+                       char    *name;
+                       uint32_t        flag;
                } __m_flags;
                struct {
-                       ino_t ino;
+                       ino_t   ino;
                        struct vnode *vp;
                        struct mount *mp;
                } __m_ino;
@@ -211,17 +211,17 @@ typedef struct devfs_msg {
 } *devfs_msg_t;
 
 #define mdv_chandler   __m_u.__m_chandler
-#define mdv_mnt        __m_u.__m_mnt.mnt
+#define mdv_mnt                __m_u.__m_mnt.mnt
 #define mdv_load       __m_u.__m_gen.load
 #define mdv_response   __m_u.__m_resp.resp
-#define mdv_dev        __m_u.__m_dev
+#define mdv_dev                __m_u.__m_dev
 #define mdv_link       __m_u.__m_link
 #define mdv_udev       __m_u.__m_udev.udev
 #define mdv_cdev       __m_u.__m_cdev.cdev
 #define mdv_name       __m_u.__m_name.name
 #define mdv_clone      __m_u.__m_clone
 #define mdv_node       __m_u.__m_node.node
-#define mdv_ops        __m_u.__m_ops
+#define mdv_ops                __m_u.__m_ops
 #define mdv_flags      __m_u.__m_flags
 #define mdv_ino                __m_u.__m_ino
 
@@ -242,7 +242,7 @@ typedef void* (devfs_iterate_callback_t)(struct devfs_node *, void *);
 #define DEVFS_NODE(x)          ((struct devfs_node *)((x)->v_data))
 #define DEVFS_MNTDATA(x)       ((struct devfs_mnt_data *)((x)->mnt_data))
 #define DEVFS_ORPHANLIST(x)    (&(DEVFS_MNTDATA(x)->orphan_list))
-#define DEVFS_DENODE_HEAD(x)   (&((x)->list))
+#define DEVFS_DENODE_HEAD(x)   (&((x)->list))
 #define DEVFS_ISDIGIT(x)       ((x >= '0') && (x <= '9'))
 
 /*
@@ -252,7 +252,7 @@ typedef void* (devfs_iterate_callback_t)(struct devfs_node *, void *);
                                 ((VREAD|VEXEC)>>6));
 
 #define DEVFS_DEFAULT_UID      0       /* root */
-#define DEVFS_DEFAULT_GID      5       /* operator */
+#define DEVFS_DEFAULT_GID      5       /* operator */
 
 /*
  * debug levels
@@ -267,7 +267,7 @@ typedef void* (devfs_iterate_callback_t)(struct devfs_node *, void *);
  */
 #define DEVFS_TERMINATE_CORE           0x01
 #define DEVFS_DEVICE_CREATE            0x02
-#define DEVFS_DEVICE_DESTROY           0x03
+#define DEVFS_DEVICE_DESTROY           0x03
 #define DEVFS_MOUNT_ADD                        0x04
 #define DEVFS_MOUNT_DEL                        0x05
 #define DEVFS_CREATE_ALL_DEV           0x06
@@ -289,8 +289,8 @@ typedef void* (devfs_iterate_callback_t)(struct devfs_node *, void *);
 /*
  * Node flags
  *
- * HIDDEN      Makes node inaccessible, apart from already allocated vnodes
- * INVISIBLE   Makes node invisible in a readdir()
+ * HIDDEN      Makes node inaccessible, apart from already allocated vnodes
+ * INVISIBLE   Makes node invisible in a readdir()
  */
 #define DEVFS_NODE_LINKED              0x001   /* Linked into topology */
 #define        DEVFS_USER_CREATED              0x002   /* Node was user-created */
@@ -392,13 +392,13 @@ cdev_t devfs_find_device_by_udev(udev_t);
 
 struct vnode *devfs_inode_to_vnode(struct mount *, ino_t);
 
-int devfs_clone_handler_add(char *, d_clone_t *);
-int devfs_clone_handler_del(char *);
-int devfs_clone(char *, size_t *, cdev_t *, int, struct ucred *);
+int devfs_clone_handler_add(const char *, d_clone_t *);
+int devfs_clone_handler_del(const char *);
+cdev_t devfs_clone(cdev_t, const char *, size_t, int, struct ucred *);
 
 int devfs_link_dev(cdev_t);
 
-int devfs_make_alias(char *, cdev_t);
+int devfs_make_alias(const char *, cdev_t);
 
 int devfs_alias_create(char *, struct devfs_node *, int);
 
index 04243bb..94b452e 100644 (file)
@@ -109,8 +109,8 @@ static int devfs_propagate_dev(cdev_t, int);
 static int devfs_unlink_dev(cdev_t dev);
 static void devfs_msg_exec(devfs_msg_t msg);
 
-static int devfs_chandler_add_worker(char *, d_clone_t *);
-static int devfs_chandler_del_worker(char *);
+static int devfs_chandler_add_worker(const char *, d_clone_t *);
+static int devfs_chandler_del_worker(const char *);
 
 static void devfs_msg_autofree_reply(lwkt_port_t, lwkt_msg_t);
 static void devfs_msg_core(void *);
@@ -665,7 +665,7 @@ devfs_destroy_dev_by_ops(struct dev_ops *ops, int minor)
  * the devfs core.
  */
 int
-devfs_clone_handler_add(char *name, d_clone_t *nhandler)
+devfs_clone_handler_add(const char *name, d_clone_t *nhandler)
 {
        devfs_msg_t msg;
 
@@ -683,7 +683,7 @@ devfs_clone_handler_add(char *name, d_clone_t *nhandler)
  * the devfs core.
  */
 int
-devfs_clone_handler_del(char *name)
+devfs_clone_handler_del(const char *name)
 {
        devfs_msg_t msg;
 
@@ -775,7 +775,7 @@ devfs_inode_to_vnode(struct mount *mp, ino_t target)
  * devfs core.
  */
 int
-devfs_make_alias(char *name, cdev_t dev_target)
+devfs_make_alias(const char *name, cdev_t dev_target)
 {
        struct devfs_alias *alias;
        size_t len;
@@ -783,8 +783,7 @@ devfs_make_alias(char *name, cdev_t dev_target)
        len = strlen(name);
 
        alias = kmalloc(sizeof(struct devfs_alias), M_DEVFS, M_WAITOK);
-       alias->name = kmalloc(len + 1, M_DEVFS, M_WAITOK);
-       memcpy(alias->name, name, len + 1);
+       alias->name = kstrdup(name, M_DEVFS);
        alias->namlen = len;
        alias->dev_target = dev_target;
 
@@ -801,11 +800,8 @@ int
 devfs_apply_rules(char *mntto)
 {
        char *new_name;
-       size_t  namelen;
 
-       namelen = strlen(mntto) + 1;
-       new_name = kmalloc(namelen, M_DEVFS, M_WAITOK);
-       memcpy(new_name, mntto, namelen);
+       new_name = kstrdup(mntto, M_DEVFS);
        devfs_msg_send_name(DEVFS_APPLY_RULES, new_name);
 
        return 0;
@@ -819,11 +815,8 @@ int
 devfs_reset_rules(char *mntto)
 {
        char *new_name;
-       size_t  namelen;
 
-       namelen = strlen(mntto) + 1;
-       new_name = kmalloc(namelen, M_DEVFS, M_WAITOK);
-       memcpy(new_name, mntto, namelen);
+       new_name = kstrdup(mntto, M_DEVFS);
        devfs_msg_send_name(DEVFS_RESET_RULES, new_name);
 
        return 0;
@@ -1293,7 +1286,7 @@ devfs_destroy_dev_by_ops_worker(struct dev_ops *ops, int minor)
  * Worker function that registers a new clone handler in devfs.
  */
 static int
-devfs_chandler_add_worker(char *name, d_clone_t *nhandler)
+devfs_chandler_add_worker(const char *name, d_clone_t *nhandler)
 {
        struct devfs_clone_handler *chandler = NULL;
        u_char len = strlen(name);
@@ -1312,8 +1305,7 @@ devfs_chandler_add_worker(char *name, d_clone_t *nhandler)
        }
 
        chandler = kmalloc(sizeof(*chandler), M_DEVFS, M_WAITOK | M_ZERO);
-       chandler->name = kmalloc(len+1, M_DEVFS, M_WAITOK);
-       memcpy(chandler->name, name, len+1);
+       chandler->name = kstrdup(name, M_DEVFS);
        chandler->namlen = len;
        chandler->nhandler = nhandler;
 
@@ -1326,7 +1318,7 @@ devfs_chandler_add_worker(char *name, d_clone_t *nhandler)
  * clone handler list.
  */
 static int
-devfs_chandler_del_worker(char *name)
+devfs_chandler_del_worker(const char *name)
 {
        struct devfs_clone_handler *chandler, *chandler2;
        u_char len = strlen(name);
@@ -1770,7 +1762,7 @@ devfs_create_device_node(struct devfs_node *root, cdev_t dev,
        }
 
        node = devfs_allocp(Pdev, name, parent, parent->mp, dev);
-
+       nanotime(&parent->mtime);
 #if 0
        /*
         * Ugly unix98 pty magic, to hide pty master (ptm) devices and their
@@ -1892,8 +1884,10 @@ devfs_destroy_device_node(struct devfs_node *root, cdev_t target)
 
        node = devfs_find_device_node_by_name(parent, name);
 
-       if (node)
+       if (node) {
+               nanotime(&node->parent->mtime);
                devfs_gc(node);
+       }
 
        return 0;
 }
@@ -1978,43 +1972,37 @@ devfs_node_to_path(struct devfs_node *node, char *buffer)
  * if clone != 0, calls the device's clone handler to get a new
  * device, which in turn is returned in devp.
  */
-int
-devfs_clone(char *name, size_t *namlenp, cdev_t *devp, int clone,
+cdev_t
+devfs_clone(cdev_t dev, const char *name, size_t len, int mode,
                struct ucred *cred)
 {
-       KKASSERT(namlenp);
-
-       size_t len = *namlenp;
-       int error = 1;
+       int error;
        struct devfs_clone_handler *chandler;
        struct dev_clone_args ap;
 
-       if (!clone) {
-               for (; (len > 0) && (DEVFS_ISDIGIT(name[len-1])); len--);
-       }
-
        TAILQ_FOREACH(chandler, &devfs_chandler_list, link) {
-               if ((chandler->namlen == len) &&
-                   (!memcmp(chandler->name, name, len)) &&
-                   (chandler->nhandler)) {
-                       if (clone) {
-                               ap.a_dev = NULL;
-                               ap.a_name = name;
-                               ap.a_namelen = len;
-                               ap.a_cred = cred;
-                               error = (chandler->nhandler)(&ap);
-                               KKASSERT(devp);
-                               *devp = ap.a_dev;
-                       } else {
-                               *namlenp = len;
-                               error = 0;
-                       }
+               if (chandler->namlen != len)
+                       continue;
+               if ((!memcmp(chandler->name, name, len)) && (chandler->nhandler)) {
+                       lockmgr(&devfs_lock, LK_RELEASE);
+                       devfs_config();
+                       lockmgr(&devfs_lock, LK_EXCLUSIVE);
+
+                       ap.a_head.a_dev = dev;
+                       ap.a_dev = NULL;
+                       ap.a_name = name;
+                       ap.a_namelen = len;
+                       ap.a_mode = mode;
+                       ap.a_cred = cred;
+                       error = (chandler->nhandler)(&ap);
+                       if (error)
+                               continue;
 
-                       break;
+                       return ap.a_dev;
                }
        }
 
-       return error;
+       return NULL;
 }
 
 
index 453616e..5265909 100644 (file)
@@ -528,7 +528,6 @@ devfs_getattr(struct vop_getattr_args *ap)
        if (node->symlink_name != 0) {
                vap->va_size = node->symlink_namelen;
        }
-       nanotime(&node->atime);
        lockmgr(&devfs_lock, LK_RELEASE);
 
        return (error);
@@ -579,7 +578,7 @@ devfs_setattr(struct vop_setattr_args *ap)
        }
 
 out:
-       nanotime(&node->mtime);
+       nanotime(&node->ctime);
        lockmgr(&devfs_lock, LK_RELEASE);
 
        return error;
@@ -703,7 +702,6 @@ devfs_spec_open(struct vop_open_args *ap)
        struct devfs_node *newnode;
        cdev_t dev, ndev = NULL;
        int error = 0;
-       size_t len;
 
        if (node) {
                if (node->d_dev == NULL)
@@ -718,31 +716,36 @@ devfs_spec_open(struct vop_open_args *ap)
        if (node && ap->a_fp) {
                devfs_debug(DEVFS_DEBUG_DEBUG, "devfs_spec_open: -1.1-\n");
                lockmgr(&devfs_lock, LK_EXCLUSIVE);
-               len = node->d_dir.d_namlen;
-               if (devfs_clone(node->d_dir.d_name, &len,
-                                 &ndev, 1, ap->a_cred) == 0) {
-                       dev = ndev;
-                       devfs_link_dev(dev);
+
+               ndev = devfs_clone(dev, node->d_dir.d_name, node->d_dir.d_namlen,
+                                               ap->a_mode, ap->a_cred);
+               if (ndev != NULL) {
                        newnode = devfs_create_device_node(
                                        DEVFS_MNTDATA(vp->v_mount)->root_node,
-                                       dev, NULL, NULL);
+                                       ndev, NULL, NULL);
+                       /* XXX: possibly destroy device if this happens */
 
-                       devfs_debug(DEVFS_DEBUG_DEBUG,
-                                   "parent here is: %s, node is: |%s|\n",
-                                   ((node->parent->node_type == Proot) ?
-                                       "ROOT!" : node->parent->d_dir.d_name),
-                                   newnode->d_dir.d_name);
-                       devfs_debug(DEVFS_DEBUG_DEBUG,
-                                   "test: %s\n",
-                                   ((struct devfs_node *)(TAILQ_LAST(DEVFS_DENODE_HEAD(node->parent), devfs_node_head)))->d_dir.d_name);
+                       if (newnode != NULL) {
+                               dev = ndev;
+                               devfs_link_dev(dev);
 
-                       /*
-                        * orig_vp is set to the original vp if we cloned.
-                        */
-                       /* node->flags |= DEVFS_CLONED; */
-                       devfs_allocv(&vp, newnode);
-                       orig_vp = ap->a_vp;
-                       ap->a_vp = vp;
+                               devfs_debug(DEVFS_DEBUG_DEBUG,
+                                               "parent here is: %s, node is: |%s|\n",
+                                               ((node->parent->node_type == Proot) ?
+                                               "ROOT!" : node->parent->d_dir.d_name),
+                                               newnode->d_dir.d_name);
+                               devfs_debug(DEVFS_DEBUG_DEBUG,
+                                               "test: %s\n",
+                                               ((struct devfs_node *)(TAILQ_LAST(DEVFS_DENODE_HEAD(node->parent), devfs_node_head)))->d_dir.d_name);
+
+                               /*
+                                * orig_vp is set to the original vp if we cloned.
+                                */
+                               /* node->flags |= DEVFS_CLONED; */
+                               devfs_allocv(&vp, newnode);
+                               orig_vp = ap->a_vp;
+                               ap->a_vp = vp;
+                       }
                }
                lockmgr(&devfs_lock, LK_RELEASE);
        }
@@ -797,8 +800,10 @@ devfs_spec_open(struct vop_open_args *ap)
        }
 
        vop_stdopen(ap);
+#if 0
        if (node)
                nanotime(&node->atime);
+#endif
 
        if (orig_vp)
                vn_unlock(vp);
@@ -1059,8 +1064,10 @@ devfs_specf_write(struct file *fp, struct uio *uio,
        error = dev_dwrite(dev, uio, ioflag);
 
        release_dev(dev);
-       if (node)
+       if (node) {
+               nanotime(&node->atime);
                nanotime(&node->mtime);
+       }
 
        if ((flags & O_FOFFSET) == 0)
                fp->f_offset = uio->uio_offset;
@@ -1201,8 +1208,6 @@ devfs_specf_kqfilter(struct file *fp, struct knote *kn)
 
        release_dev(dev);
 
-       if (node)
-               nanotime(&node->atime);
 done:
        rel_mplock();
        return (error);
@@ -1235,8 +1240,10 @@ devfs_specf_poll(struct file *fp, int events, struct ucred *cred)
 
        release_dev(dev);
 
+#if 0
        if (node)
                nanotime(&node->atime);
+#endif
 done:
        rel_mplock();
        return (error);
@@ -1295,10 +1302,12 @@ devfs_specf_ioctl(struct file *fp, u_long com, caddr_t data, struct ucred *ucred
        reference_dev(dev);
        error = dev_dioctl(dev, com, data, fp->f_flag, ucred);
        release_dev(dev);
+#if 0
        if (node) {
                nanotime(&node->atime);
                nanotime(&node->mtime);
        }
+#endif
 
        if (com == TIOCSCTTY) {
                devfs_debug(DEVFS_DEBUG_DEBUG,
@@ -1417,8 +1426,10 @@ devfs_spec_write(struct vop_write_args *ap)
        error = dev_dwrite(dev, uio, ap->a_ioflag);
        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 
-       if (node)
+       if (node) {
+               nanotime(&node->atime);
                nanotime(&node->mtime);
+       }
 
        return (error);
 }
@@ -1440,10 +1451,12 @@ devfs_spec_ioctl(struct vop_ioctl_args *ap)
                return (EBADF);         /* device was revoked */
        node = DEVFS_NODE(vp);
 
+#if 0
        if (node) {
                nanotime(&node->atime);
                nanotime(&node->mtime);
        }
+#endif
 
        return (dev_dioctl(dev, ap->a_command, ap->a_data,
                           ap->a_fflag, ap->a_cred));
@@ -1464,8 +1477,10 @@ devfs_spec_poll(struct vop_poll_args *ap)
                return (EBADF);         /* device was revoked */
        node = DEVFS_NODE(vp);
 
+#if 0
        if (node)
                nanotime(&node->atime);
+#endif
 
        return (dev_dpoll(dev, ap->a_events));
 }
@@ -1485,8 +1500,10 @@ devfs_spec_kqfilter(struct vop_kqfilter_args *ap)
                return (EBADF);         /* device was revoked */
        node = DEVFS_NODE(vp);
 
+#if 0
        if (node)
                nanotime(&node->atime);
+#endif
 
        return (dev_dkqfilter(dev, ap->a_kn));
 }
@@ -1934,6 +1951,8 @@ devfs_spec_getpages(struct vop_getpages_args *ap)
         * Free the buffer header back to the swap buffer pool.
         */
        relpbuf(bp, NULL);
+       if (DEVFS_NODE(ap->a_vp))
+               nanotime(&DEVFS_NODE(ap->a_vp)->mtime);
        return VM_PAGER_OK;
 }
 
index bdd97b5..a03d2ef 100644 (file)
@@ -1,4 +1,5 @@
 PROG=  devfsctl
+SRCS=  devfsctl.c
 #MAN=  devfsctl.8
 NOMAN=
 CFLAGS+=-I${.CURDIR}/../../sys
index 32c783b..4095bc5 100644 (file)
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#include <sys/ioctl.h>
+
 #include <sys/types.h>
-#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/device.h>
+#include <sys/queue.h>
+
+#include <vfs/devfs/devfs_rules.h>
+
+#include <err.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <pwd.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <fcntl.h>
-#include <err.h>
-#include <pwd.h>
-#include <grp.h>
-#include <vfs/devfs/devfs_rules.h>
-#include <sys/device.h>
+#include <unistd.h>
 
-void dump_config(void);
-void rule_init(struct devfs_rule *rule, char *name);
-int rule_check_num_args(char **tokens, int num);
-void rule_group(char **tokens);
-void rule_parse_groups(void);
-void rule_clear_groups(void);
-void rule_clear_rules(void);
-void rule_perm(char **tokens);
-void rule_link(char **tokens);
-void rule_hide(char **tokens);
-void rule_show(char **tokens);
-struct devfs_rule *get_group(char *name);
-struct devfs_rule *get_rule(char *name);
-void put_rule(struct devfs_rule *rule);
-int rule_open(void);
-int rule_close(void);
-int rule_ioctl(unsigned long cmd, struct devfs_rule *rule);
-int read_config(char *name);
-int process_line(FILE* fd);
-void usage(void);
+#include "devfsctl.h"
+
+struct verb {
+       const char *verb;
+       rule_parser_t *parser;
+       int     min_args;
+};
+
+struct devtype {
+       const char *name;
+       int     value;
+};
+
+
+
+static int parser_include(char **);
+static int parser_jail(char **);
+static int parser_hide(char **);
+static int parser_show(char **);
+static int parser_link(char **);
+static int parser_group(char **);
+static int parser_perm(char **);
+static int dump_config_entry(struct rule *, struct groupdevid *);
+static int rule_id_iterate(struct groupdevid *, struct rule *,
+               rule_iterate_callback_t *);
+static int rule_ioctl(unsigned long, struct devfs_rule *);
+static void rule_fill(struct devfs_rule *, struct rule *,
+               struct groupdevid *);
+static int rule_send(struct rule *, struct groupdevid *);
+static int rule_check_num_args(char **, int);
+static int process_line(FILE*);
+static void usage(void);
 
 static int dev_fd;
+
+const char *config_name = NULL, *mountp = NULL;
+static int dflag = 0;
+static int aflag = 0, cflag = 0, rflag = 0;
+static int line_stack[RULE_MAX_STACK];
+static char *file_stack[RULE_MAX_STACK];
+static int line_stack_depth = 0;
 static int jail = 0;
-static struct devfs_rule dummy_rule;
-static int verbose = 0;
 
+static TAILQ_HEAD(, rule) rule_list =
+               TAILQ_HEAD_INITIALIZER(rule_list);
 
-TAILQ_HEAD(devfs_rule_head, devfs_rule);
+static TAILQ_HEAD(, groupdevid) group_list =
+               TAILQ_HEAD_INITIALIZER(group_list);
 
-static struct devfs_rule_head devfs_rule_list =
-               TAILQ_HEAD_INITIALIZER(devfs_rule_list);
-static struct devfs_rule_head devfs_group_list =
-               TAILQ_HEAD_INITIALIZER(devfs_group_list);
 
+static const struct verb parsers[] = {
+       { "include", parser_include, 1 },
+       { "jail", parser_jail, 1 },
+       { "group", parser_group, 2 },
+       { "perm", parser_perm, 2 },
+       { "link", parser_link, 2 },
+       { "hide", parser_hide, 2 },
+       { "show", parser_show, 2 },
+       { NULL, NULL, 0 }
+};
 
-void
-dump_config(void)
-{
-       struct devfs_rule *rule;
-       struct passwd *pwd;
-       struct group *grp;
+static const struct devtype devtypes[] = {
+       { "D_TAPE", D_TAPE },
+       { "D_DISK", D_DISK },
+       { "D_TTY", D_TTY },
+       { "D_MEM", D_MEM },
+       { NULL, 0 }
+};
 
-       TAILQ_FOREACH(rule, &devfs_rule_list, link) {
-               printf("-----------------------------------------\n");
-               printf("Affects:\t");
-               if (rule->dev_type) {
-                       printf("device type ");
-                       switch (rule->dev_type) {
-                       case D_TAPE:
-                               puts("D_TAPE");
-                               break;
-                       case D_DISK:
-                               puts("D_DISK");
-                               break;
-                       case D_TTY:
-                               puts("D_TTY");
-                               break;
-                       case D_MEM:
-                               puts("D_MEM");
-                               break;
-                       default:
-                               puts("*unknown");
-                       }
-               } else {
-                       printf("%s\n", rule->name);
-               }
+int
+syntax_error(const char *fmt, ...)
+{
+       char buf[1024];
+       va_list ap;
+
+       va_start(ap, fmt);
+       vsnprintf(buf, sizeof(buf), fmt, ap);
+       va_end(ap);
+       errx(1, "%s: syntax error on line %d: %s\n",file_stack[line_stack_depth],
+                       line_stack[line_stack_depth], buf);
+}
 
-               printf("only jails?\t%s\n",
-                               (rule->rule_type & DEVFS_RULE_JAIL)?"yes":"no");
+static int
+parser_include(char **tokens)
+{
+       read_config(tokens[1]);
 
-               printf("Action:\t\t");
-               if (rule->rule_type & DEVFS_RULE_LINK) {
-                       printf("link to %s\n", rule->linkname);
-               } else if (rule->rule_type & DEVFS_RULE_HIDE) {
-                       printf("hide\n");
-               } else if (rule->rule_type & DEVFS_RULE_SHOW) {
-                       printf("show\n");
-               } else {
-                       pwd = getpwuid(rule->uid);
-                       grp = getgrgid(rule->gid);
-                       printf("set mode: %o\n\t\tset owner: %s\n\t\tset group: %s\n",
-                                       rule->mode, pwd->pw_name, grp->gr_name);
-               }
-       }
-       printf("-----------------------------------------\n");
+       return 0;
 }
 
-void
-rule_init(struct devfs_rule *rule, char *name)
+static int
+parser_jail(char **tokens)
 {
-       size_t len;
-
-       if (!strcmp(name, "D_TAPE")) {
-               rule->rule_type = DEVFS_RULE_TYPE;
-               rule->dev_type = D_TAPE;
-       } else if (!strcmp(name, "D_DISK")) {
-               rule->rule_type = DEVFS_RULE_TYPE;
-               rule->dev_type = D_DISK;
-       } else if (!strcmp(name, "D_TTY")) {
-               rule->rule_type = DEVFS_RULE_TYPE;
-               rule->dev_type = D_TTY;
-       } else if (!strcmp(name, "D_MEM")) {
-               rule->rule_type = DEVFS_RULE_TYPE;
-               rule->dev_type = D_MEM;
+       if (tokens[1][0] == 'y') {
+               jail = 1;
+       } else if (tokens[1][0] == 'n') {
+               jail = 0;
        } else {
-               len = strlen(name);
-               rule->namlen = len;
-               rule->name = malloc(len+1);
-               strlcpy(rule->name, name, len+1);
-               rule->rule_type = DEVFS_RULE_NAME;
+               syntax_error("incorrect argument to 'jail'. Must be either y[es] or n[o]");
        }
 
-       if (jail)
-               rule->rule_type |= DEVFS_RULE_JAIL;
+       return 0;
 }
 
-int
-rule_check_num_args(char **tokens, int num)
+static int
+parser_hide(char **tokens)
 {
-       int i = 0;
-       for (i = 0; tokens[i] != NULL; i++);
+       struct groupdevid *id;
+       struct rule *rule;
 
-       if (i != num) {
-               printf("This line in the configuration file is incorrect."
-                               " It has %d words, but %d were expected\n",
-                               i, num);
+       id = get_id(tokens[1]);
+       rule = new_rule(rHIDE, id);
+       add_rule(rule);
 
-               for (i = 0; tokens[i] != NULL; i++) {
-                       printf("%s", tokens[i]);
-                       putchar('\t');
-               }
-               putchar('\n');
-
-               return 1;
-       }
        return 0;
 }
 
-void
-rule_group(char **tokens)
+static int
+parser_show(char **tokens)
 {
-       size_t len;
-       struct devfs_rule *group, *rule;
+       struct groupdevid *id;
+       struct rule *rule;
 
-       if (get_group(tokens[0])) {
-               printf("Name to group cannot be a group, aborting. "
-                               "Please check your config file\n");
-               exit(1);
-       }
+       id = get_id(tokens[1]);
+       rule = new_rule(rSHOW, id);
+       add_rule(rule);
 
-       rule = get_rule(tokens[0]);
-       rule_init(rule, tokens[0]);
+       return 0;
+}
 
-       if (!(group = get_group(tokens[2]))) {
-               group = get_rule(NULL);
-               len = strlen(tokens[2]);
-               group->namlen = len;
-               group->name = malloc(len+1);
-               strlcpy(group->name, tokens[2], len+1);
-       }
+static int
+parser_link(char **tokens)
+{
+       struct groupdevid *id;
+       struct rule *rule;
+
+       id = get_id(tokens[1]);
+       rule = new_rule(rLINK, id);
+       rule->dest = strdup(tokens[2]);
+       add_rule(rule);
 
-       rule->group = group;
+       return 0;
 }
 
-void
-rule_parse_groups(void)
+static int
+parser_group(char **tokens)
 {
-       struct devfs_rule *rule, *group;
-
-       TAILQ_FOREACH(rule, &devfs_rule_list, link) {
-               if ((group = rule->group)) {
-                       rule->group = 0;
-                       rule->rule_type |= group->rule_type;
-                       rule->mode = group->mode;
-                       rule->uid = group->uid;
-                       rule->gid = group->gid;
-
-                       if (group->linkname) {
-                               rule->linknamlen = group->linknamlen;
-                               rule->linkname = malloc(group->linknamlen+1);
-                               strlcpy(rule->linkname, group->linkname, group->linknamlen+1);
+       struct groupdevid *gid, *id;
+       int i;
+       size_t k;
+
+       gid = get_group(tokens[1], 1);
+       for (k = 0; gid->list[k] != NULL; k++)
+               /* Do nothing */;
+       for (i = 2; tokens[i] != NULL; i++) {
+               id = get_id(tokens[i]);
+               if (id == gid) {
+                       syntax_error("recursive group definition for group %s", gid->name);
+               } else {
+                       if (k >= gid->listsize-1 ) {
+                               gid->list = realloc(gid->list,
+                                               2*gid->listsize*sizeof(struct groupdevid *));
+                               gid->listsize *= 2;
                        }
-               }
-       }
-}
 
-void
-rule_clear_groups(void)
-{
-       struct devfs_rule *rule, *rule1;
-       TAILQ_FOREACH_MUTABLE(rule, &devfs_group_list, link, rule1) {
-               TAILQ_REMOVE(&devfs_group_list, rule, link);
-               put_rule(rule);
+                       gid->list[k++] = id;
+               }
        }
-}
+       gid->list[k] = NULL;
 
-void
-rule_clear_rules(void)
-{
-       struct devfs_rule *rule, *rule1;
-       TAILQ_FOREACH_MUTABLE(rule, &devfs_rule_list, link, rule1) {
-               TAILQ_REMOVE(&devfs_rule_list, rule, link);
-               put_rule(rule);
-       }
+       return 0;
 }
 
-void
-rule_perm(char **tokens)
+static int
+parser_perm(char **tokens)
 {
-       struct devfs_rule *rule;
        struct passwd *pwd;
        struct group *grp;
-       rule = get_rule(tokens[0]);
-       rule_init(rule, tokens[0]);
-       rule->mode = strtol(tokens[2], NULL, 8);
-       if ((pwd = getpwnam(tokens[3])))
+       struct groupdevid *id;
+       struct rule *rule;
+       char *uname;
+       char *grname;
+
+       id = get_id(tokens[1]);
+       rule = new_rule(rPERM, id);
+
+       rule->mode = strtol(tokens[3], NULL, 8);
+       uname = tokens[2];
+       grname = strchr(tokens[2], ':');
+       if (grname == NULL)
+               syntax_error("invalid format for user/group (%s)", tokens[2]);
+
+       *grname = '\0';
+       ++grname;
+       if ((pwd = getpwnam(uname)))
                rule->uid = pwd->pw_uid;
-       if ((grp = getgrnam(tokens[4])))
+       else
+               syntax_error("invalid user name %s", uname);
+
+       if ((grp = getgrnam(grname)))
                rule->gid = grp->gr_gid;
+       else
+               syntax_error("invalid group name %s", grname);
+
+       add_rule(rule);
+       return 0;
 }
 
-void
-rule_link(char **tokens)
+struct groupdevid *
+new_id(const char *name, int type_in)
 {
-       struct devfs_rule *rule;
-       size_t len;
+       struct groupdevid *id;
+       int type = (type_in != 0)?(type_in):(isNAME), i;
+
+       id = calloc(1, sizeof(*id));
+       if (id == NULL)
+               err(1, NULL);
+
+       if (type_in == 0) {
+               for (i = 0; devtypes[i].name != NULL; i++) {
+                       if (!strcmp(devtypes[i].name, name)) {
+                               type = isTYPE;
+                               id->devtype = devtypes[i].value;
+                               break;
+                       }
+               }
+       }
+       id->type = type;
 
-       rule = get_rule(tokens[0]);
-       rule_init(rule, tokens[0]);
+       if ((type == isNAME) || (type == isGROUP)) {
+               id->name = strdup(name);
+       }
 
-       len = strlen(tokens[2]);
-       rule->linknamlen = len;
-       rule->linkname = malloc(len+1);
-       strlcpy(rule->linkname, tokens[2], len+1);
-       rule->rule_type |= DEVFS_RULE_LINK;
+       if (type == isGROUP) {
+               id->list = calloc(4, sizeof(struct groupdevid *));
+               memset(id->list, 0, 4 * sizeof(struct groupdevid *));
+               id->listsize = 4;
+       }
+
+       return (id);
 }
 
-void
-rule_hide(char **tokens)
+struct groupdevid *
+get_id(const char *name)
 {
-       struct devfs_rule *rule;
+       struct groupdevid *id;
 
-       rule = get_rule(tokens[0]);
-       rule_init(rule, tokens[0]);
+       if ((name[0] == '@') && (name[1] != '\0')) {
+               id = get_group(name+1, 0);
+               if (id == NULL)
+                       syntax_error("unknown group name '%s', you "
+                                       "have to use the 'group' verb first.", name+1);
+       }
+       else
+               id = new_id(name, 0);
 
-       rule->rule_type |= DEVFS_RULE_HIDE;
+       return id;
 }
 
-void
-rule_show(char **tokens)
+struct groupdevid *
+get_group(const char *name, int expect)
 {
-       struct devfs_rule *rule;
+       struct groupdevid *g;
+
+       TAILQ_FOREACH(g, &group_list, link) {
+               if (strcmp(g->name, name) == 0)
+                       return (g);
+       }
 
-       rule = get_rule(tokens[0]);
-       rule_init(rule, tokens[0]);
+       /* Caller doesn't expect to get a group no matter what */
+       if (!expect)
+               return NULL;
 
-       rule->rule_type |= DEVFS_RULE_SHOW;
+       g = new_id(name, isGROUP);
+       TAILQ_INSERT_TAIL(&group_list, g, link);
+       return (g);
 }
 
-struct devfs_rule *
-get_group(char *name)
+struct rule *
+new_rule(int type, struct groupdevid *id)
 {
-       struct devfs_rule *rule, *found = NULL;
+       struct rule *rule;
 
-       TAILQ_FOREACH(rule, &devfs_group_list, link) {
-               if (!strcmp(rule->name, name)) {
-                       found = rule;
-                       break;
-               }
-       }
+       rule = calloc(1, sizeof(*rule));
+       if (rule == NULL)
+               err(1, NULL);
 
-       return found;
+       rule->type = type;
+       rule->id = id;
+       rule->jail = jail;
+       return (rule);
 }
 
-struct devfs_rule *
-get_rule(char *name)
+void
+add_rule(struct rule *rule)
 {
-       struct devfs_rule *rule;
-       int     alloced = 0;
+       TAILQ_INSERT_TAIL(&rule_list, rule, link);
+}
 
-       if ((name == NULL) || (!(rule = get_group(name)))) {
-               rule = (struct devfs_rule *)malloc(sizeof(struct devfs_rule));
-               memset(rule, 0, sizeof(struct devfs_rule));
-               alloced = 1;
+static int
+dump_config_entry(struct rule *rule, struct groupdevid *id)
+{
+       struct passwd *pwd;
+       struct group *grp;
+       int i;
+
+       switch (rule->type) {
+       case rPERM: printf("perm "); break;
+       case rLINK: printf("link "); break;
+       case rHIDE: printf("hide "); break;
+       case rSHOW: printf("show "); break;
+       default: errx(1, "invalid rule type");
+       }
+
+       switch (id->type) {
+       case isGROUP: printf("@"); /* FALLTHROUGH */
+       case isNAME: printf("%s", id->name); break;
+       case isTYPE:
+               for (i = 0; devtypes[i].name != NULL; i++) {
+                       if (devtypes[i].value == id->devtype) {
+                               printf("%s", devtypes[i].name);
+                               break;
+                       }
+               }
+               break;
+       default: errx(1, "invalid id type %d", id->type);
        }
 
-       if (alloced) {
-               if (name == NULL) {
-                       /*
-                        * If the name was NULL, the intention was to allocate a
-                        * new group.
-                        */
-                       TAILQ_INSERT_TAIL(&devfs_group_list, rule, link);
+       switch (rule->type) {
+       case rPERM:
+               pwd = getpwuid(rule->uid);
+               grp = getgrgid(rule->gid);
+               if (pwd && grp) {
+                       printf(" %s:%s 0%.03o",
+                                  pwd->pw_name,
+                                  grp->gr_name,
+                                  rule->mode);
                } else {
-                       /*
-                        * If a name was passed, the intention was to either find
-                        * a pre-existing group or allocate a new rule.
-                        */
-                       TAILQ_INSERT_TAIL(&devfs_rule_list, rule, link);
+                       printf(" %d:%d 0%.03o",
+                                  rule->uid,
+                                  rule->gid,
+                                  rule->mode);
                }
+               break;
+       case rLINK:
+               printf(" %s", rule->dest);
+               break;
+       default: /* NOTHING */;
        }
 
-       return rule;
+       if (rule->jail)
+               printf("\t(only affects jails)");
+
+       printf("\n");
+
+       return 0;
 }
 
-void
-put_rule(struct devfs_rule *rule)
+static int
+rule_id_iterate(struct groupdevid *id, struct rule *rule,
+               rule_iterate_callback_t *callback)
 {
-       if (rule->name)
-               free(rule->name);
+       int error = 0;
+       int i;
 
-       if (rule->linkname)
-               free(rule->linkname);
+       if (id->type == isGROUP) {
+               for (i = 0; id->list[i] != NULL; i++) {
+                       if ((error = rule_id_iterate(id->list[i], rule, callback)))
+                               return error;
+               }
+       } else {
+               error = callback(rule, id);
+       }
 
-       if (rule->mntpoint)
-               free(rule->mntpoint);
+       return error;
+}
+
+void
+dump_config(void)
+{
+       struct rule *rule;
 
-       free(rule);
+       TAILQ_FOREACH(rule, &rule_list, link) {
+               rule_id_iterate(rule->id, rule, dump_config_entry);
+       }
 }
 
-int
-rule_open(void)
+static int
+rule_ioctl(unsigned long cmd, struct devfs_rule *rule)
 {
-    if ((dev_fd = open("/dev/devfs", O_RDWR)) == -1) {
-        perror("open /dev/devfs error\n");
-        return 1;
-    }
+       if (ioctl(dev_fd, cmd, rule) == -1)
+               err(1, "ioctl");
 
        return 0;
 }
 
-int
-rule_close(void)
+static void
+rule_fill(struct devfs_rule *dr, struct rule *r, struct groupdevid *id)
 {
-       close(dev_fd);
-       return 0;
+       dr->rule_type = 0;
+
+       switch (id->type) {
+       default:
+               errx(1, "invalid id type");
+       case isGROUP:
+               errx(1, "internal error: can not fill group rule");
+               /* NOTREACHED */
+       case isNAME:
+               dr->rule_type |= DEVFS_RULE_NAME;
+               dr->name = id->name;
+               dr->namlen = strlen(dr->name);
+               break;
+       case isTYPE:
+               dr->rule_type |= DEVFS_RULE_TYPE;
+               dr->dev_type = id->devtype;
+               break;
+       }
+
+       switch (r->type) {
+       case rPERM:
+               dr->rule_type |= DEVFS_RULE_PERM;
+               dr->uid = r->uid;
+               dr->gid = r->gid;
+               dr->mode = r->mode;
+               break;
+       case rLINK:
+               dr->rule_type |= DEVFS_RULE_LINK;
+               dr->linkname = r->dest;
+               dr->linknamlen = strlen(dr->linkname);
+               break;
+       case rHIDE:
+               dr->rule_type |= DEVFS_RULE_HIDE;
+               break;
+       case rSHOW:
+               dr->rule_type |= DEVFS_RULE_SHOW;
+               break;
+       }
+
+       if (r->jail)
+               dr->rule_type |= DEVFS_RULE_JAIL;
+}
+
+static int
+rule_send(struct rule *rule, struct groupdevid *id)
+{
+       struct devfs_rule dr;
+       int r = 0;
+
+       dr.mntpoint = mountp;
+       dr.mntpointlen = strlen(mountp);
+
+       rule_fill(&dr, rule, id);
+       r = rule_ioctl(DEVFS_RULE_ADD, &dr);
+
+       return r;
 }
 
 int
-rule_ioctl(unsigned long cmd, struct devfs_rule *rule)
+rule_apply(void)
 {
-       if (ioctl(dev_fd, cmd, rule) == -1) {
-               perror("ioctl error");
-               return 1;
+       struct devfs_rule dr;
+       struct rule *rule;
+       int r = 0;
+
+       dr.mntpoint = mountp;
+       dr.mntpointlen = strlen(mountp);
+
+       TAILQ_FOREACH(rule, &rule_list, link) {
+               r = rule_id_iterate(rule->id, rule, rule_send);
+               if (r != 0)
+                       return (-1);
        }
 
+       return (rule_ioctl(DEVFS_RULE_APPLY, &dr));
+}
+
+static int
+rule_check_num_args(char **tokens, int num)
+{
+       int i = 0;
+       for (i = 0; tokens[i] != NULL; i++);
+
+       if (i < num) {
+               syntax_error("at least %d tokens were expected but only %d were found", num, i);
+               return 1;
+       }
        return 0;
 }
 
@@ -397,27 +542,43 @@ int
 read_config(char *name)
 {
        FILE *fd;
+
        if ((fd = fopen(name, "r")) == NULL) {
                printf("Error opening config file %s\n", name);
                perror("fopen");
                return 1;
        }
 
-       while (process_line(fd) == 0);
-       rule_parse_groups();
+       if (++line_stack_depth >= RULE_MAX_STACK) {
+               --line_stack_depth;
+               syntax_error("Maximum include depth (%d) exceeded, "
+                               "check for recursion.", RULE_MAX_STACK);
+       }
+
+       line_stack[line_stack_depth] = 1;
+       file_stack[line_stack_depth] = strdup(name);
+
+       while (process_line(fd) == 0)
+               line_stack[line_stack_depth]++;
 
        fclose(fd);
 
+       free(file_stack[line_stack_depth]);
+       --line_stack_depth;
+
        return 0;
 }
 
-int
+static int
 process_line(FILE* fd)
 {
        char buffer[4096];
        char *tokens[256];
        int c, n, i = 0;
+       int quote = 0;
        int ret = 0;
+       int error = 0;
+       int parsed = 0;
 
 
        while (((c = fgetc(fd)) != EOF) && (c != '\n')) {
@@ -426,113 +587,114 @@ process_line(FILE* fd)
                        break;
        }
        buffer[i] = '\0';
+
        if (feof(fd) || ferror(fd))
                ret = 1;
        c = 0;
        while (((buffer[c] == ' ') || (buffer[c] == '\t')) && (c < i)) c++;
+       /*
+        * If this line effectively (after indentation) begins with the comment
+        * character #, we ignore the rest of the line.
+        */
+       if (buffer[c] == '#')
+               return 0;
+
        tokens[0] = &buffer[c];
        for (n = 1; c < i; c++) {
+               if (buffer[c] == '"') {
+                       quote = !quote;
+                       if (quote) {
+                               if ((c >= 1) && (&buffer[c] != tokens[n-1])) {
+                                       syntax_error("stray opening quote not at beginning of token");
+                                       /* NOTREACHED */
+                               }
+                               tokens[n-1] = &buffer[c+1];
+                       } else {
+                               if ((c < i-1) && (!iswhitespace(buffer[c+1]))) {
+                                       syntax_error("stray closing quote not at end of token");
+                                       /* NOTREACHED */
+                               }
+                               buffer[c] = '\0';
+                       }
+               }
+
+               if (quote) {
+                       continue;
+               }
+
                if ((buffer[c] == ' ') || (buffer[c] == '\t')) {
                        buffer[c++] = '\0';
-                       while (((buffer[c] == ' ') || (buffer[c] == '\t')) && (c < i)) c++;
-                       tokens[n++] = &buffer[c];
+                       while ((iswhitespace(buffer[c])) && (c < i)) c++;
+                       tokens[n++] = &buffer[c--];
                }
        }
        tokens[n] = NULL;
 
        /*
         * If there are not enough arguments for any function or it is
-        * a line full of whitespaces, we just return here.
+        * a line full of whitespaces, we just return here. Or if a
+        * quote wasn't closed.
         */
-       if ((n < 2) || (tokens[0][0] == '\0'))
+       if ((quote) || (n < 2) || (tokens[0][0] == '\0'))
                return ret;
 
-       if (verbose) {
-               printf("Currently processing verb/command: %s\n",
-                               (tokens[0][0] == '#')?(tokens[0]):(tokens[1]));
-       }
+       /* Convert the command/verb to lowercase */
+       for (i = 0; tokens[0][i] != '\0'; i++)
+               tokens[0][i] = tolower(tokens[0][i]);
 
-       if (!strcmp(tokens[0], "#include")) {
-               /* This is an include instruction */
-               if (!rule_check_num_args(tokens, 2))
-                       read_config(tokens[1]);
-       } else if (!strcmp(tokens[0], "#jail")) {
-               /* This is a jail instruction */
-               if (!rule_check_num_args(tokens, 2))
-                       jail = (tokens[1][0] == 'y')?1:0;
-       } else if (!strcmp(tokens[1], "group")) {
-               /* This is a group rule */
-               if (!rule_check_num_args(tokens, 3))
-                       rule_group(tokens);
-       } else if (!strcmp(tokens[1], "perm")) {
-               /* This is a perm rule */
-               if (!rule_check_num_args(tokens, 5))
-                       rule_perm(tokens);
-       } else if (!strcmp(tokens[1], "link")) {
-               /* This is a link rule */
-               if (!rule_check_num_args(tokens, 3))
-                       rule_link(tokens);
-       } else if (!strcmp(tokens[1], "hide")) {
-               /* This is a hide rule */
-               if (!rule_check_num_args(tokens, 2))
-                       rule_hide(tokens);
-       } else if (!strcmp(tokens[1], "show")) {
-               /* This is a show rule */
-               if (!rule_check_num_args(tokens, 2))
-                       rule_show(tokens);
-       } else {
-               printf("Unknown verb %s\n", tokens[1]);
+       for (i = 0; parsers[i].verb; i++) {
+               if ((error = rule_check_num_args(tokens, parsers[i].min_args)))
+                       continue;
+
+               if (!strcmp(tokens[0], parsers[i].verb)) {
+                       parsers[i].parser(tokens);
+                       parsed = 1;
+                       break;
+               }
+       }
+       if (parsed == 0) {
+               syntax_error("unknown verb/command %s", tokens[0]);
        }
        return ret;
 }
 
-
-void
+static void
 usage(void)
 {
-    printf("Usage: devfsctl <commands> [options]\n");
-       printf("Valid commands are:\n");
-       printf(" -a\n\t Loads all read rules into the kernel and "
-                       "applies them\n");
-       printf(" -c\n\t Clears all rules stored in the kernel but "
-                       "does not reset the nodes\n");
-       printf(" -d\n\t Dumps the rules that have been loaded to the "
-                       "screen to verify syntax\n");
-       printf(" -r\n\t Resets all devfs_nodes but does not clear "
-                       "the rules stored\n");
-
-       printf("\nValid options and its arguments are:\n");
-       printf(" -f <config_file>\n\t Specifies the configuration file "
-                       "to be used\n");
-       printf(" -m <mount_point>\n\t Specifies a mount point to which "
-                       "the command will apply. Defaults to *\n");
-       printf(" -v\n\t Enables verbose mode\n");
-
-    exit(1);
+       fprintf(stderr,
+               "Usage: devfsctl <commands> [options]\n"
+               "Valid commands are:\n"
+               " -a\n"
+               "\t Loads all read rules into the kernel and applies them\n"
+               " -c\n"
+               "\t Clears all rules stored in the kernel but does not reset the nodes\n"
+               " -d\n"
+               "\t Dumps the rules that have been loaded to the screen to verify syntax\n"
+               " -r\n"
+               "\t Resets all devfs_nodes but does not clear the rules stored\n"
+               "\n"
+               "Valid options and its arguments are:\n"
+               " -f <config_file>\n"
+               "\t Specifies the configuration file to be used\n"
+               " -m <mount_point>\n"
+               "\t Specifies a mount point to which the command will apply. Defaults to *\n"
+               );
+
+       exit(1);
 }
 
-
 int main(int argc, char *argv[])
 {
-       struct devfs_rule *rule;
-       int ch, done = 0;
-       size_t len;
-       char farg[1024], marg[1024];
-       int fflag = 0, dflag = 0, mflag = 0;
-       int aflag = 0, cflag = 0, rflag = 0;
-
-    while ((ch = getopt(argc, argv, "acdf:hrvm:")) != -1) {
-        switch (ch) {
-        case 'v':
-            verbose = 1;
-            break;
+       struct devfs_rule dummy_rule;
+       int ch;
+
+       while ((ch = getopt(argc, argv, "acdf:hm:r")) != -1) {
+               switch (ch) {
                case 'f':
-                       strlcpy(farg, optarg, 1024);
-                       fflag = 1;
+                       config_name = optarg;
                        break;
                case 'm':
-                       strlcpy(marg, optarg, 1024);
-                       mflag = 1;
+                       mountp = optarg;
                        break;
                case 'a':
                        aflag = 1;
@@ -547,79 +709,55 @@ int main(int argc, char *argv[])
                        dflag = 1;
                        break;
                case 'h':
-        case '?':
-        default:
-            usage();
-        }
-    }
-
-    argc -= optind;
-    argv += optind;
-
-       if (!mflag)
-               strcpy(marg, "*");
-
-       if (cflag) {
-               done = 1;
-               len = strlen(marg);
-               dummy_rule.mntpoint = malloc(len+1);
-               strlcpy(dummy_rule.mntpoint, marg, len+1);
-               dummy_rule.mntpointlen = len;
-
-               rule_open();
-               rule_ioctl(DEVFS_RULE_CLEAR, &dummy_rule);
-               rule_close();
+               case '?':
+               default:
+                       usage();
+                       /* NOT REACHED */
+               }
        }
 
-       if (rflag) {
-               done = 1;
-               len = strlen(marg);
-               dummy_rule.mntpoint = malloc(len+1);
-               strlcpy(dummy_rule.mntpoint, marg, len+1);
-               dummy_rule.mntpointlen = len;
-               rule_open();
-               rule_ioctl(DEVFS_RULE_RESET, &dummy_rule);
-               rule_close();
-       }
+       argc -= optind;
+       argv += optind;
 
-       if (fflag) {
-               jail = 0;
-               read_config(farg);
+       /*
+        * Check arguments:
+        * - need to use at least one mode
+        * - can not use -d with any other mode
+        */
+       if (!(aflag || rflag || cflag || dflag) ||
+           (dflag && (aflag || rflag || cflag))) {
+               usage();
+               /* NOT REACHED */
        }
 
+       if (mountp == NULL)
+               mountp = "*";
+
+       dummy_rule.mntpoint = mountp;
+       dummy_rule.mntpointlen = strlen(dummy_rule.mntpoint);
+
+       if (config_name != NULL)
+               read_config(config_name);
+
        if (dflag) {
-               done = 1;
                dump_config();
+               exit(0);
        }
 
-       if (aflag) {
-               done = 1;
-               jail = 0;
-#if 0
-               read_config(farg);
-#endif
-               rule_open();
-               len = strlen(marg);
-
-               TAILQ_FOREACH(rule, &devfs_rule_list, link) {
-                       rule->mntpoint = malloc(len+1);
-                       strlcpy(rule->mntpoint, marg, len+1);
-                       rule->mntpointlen = len;
-                       rule_ioctl(DEVFS_RULE_ADD, rule);
-               }
+       dev_fd = open("/dev/devfs", O_RDWR);
+       if (dev_fd == -1)
+               err(1, "open(/dev/devfs)");
 
-               dummy_rule.mntpoint = malloc(len+1);
-               strlcpy(dummy_rule.mntpoint, marg, len+1);
-               dummy_rule.mntpointlen = len;
-               rule_ioctl(DEVFS_RULE_APPLY, &dummy_rule);
+       if (cflag)
+               rule_ioctl(DEVFS_RULE_CLEAR, &dummy_rule);
 
-               rule_close();
-               rule_clear_groups();
-               rule_clear_rules();
-       }
+       if (rflag)
+               rule_ioctl(DEVFS_RULE_RESET, &dummy_rule);
 
-       if (!done)
-               usage();
+       if (aflag)
+               rule_apply();
+
+       close(dev_fd);
 
        return 0;
 }
diff --git a/usr.sbin/devfsctl/devfsctl.h b/usr.sbin/devfsctl/devfsctl.h
new file mode 100644 (file)
index 0000000..b437d6b
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef DEVFSCTL_H
+#define DEVFSCTL_H
+
+#include <sys/queue.h>
+
+#define iswhitespace(X)        ((((X) == ' ') || ((X) == '\t'))?1:0)
+#define RULE_MAX_STACK 32
+
+
+struct groupdevid {
+       enum {
+               isGROUP = 1,
+               isNAME,
+               isTYPE
+       }               type;
+
+       union {
+               const char      *name;
+               int             devtype;
+       };
+
+       struct groupdevid **list;
+       size_t  listsize;
+#if 0
+    struct groupdevid *next;
+       TAILQ_HEAD(, groupdevid) list;
+#endif
+       TAILQ_ENTRY(groupdevid) link;
+};
+
+struct rule {
+       enum {
+               rPERM = 1,
+               rLINK,
+               rHIDE,
+               rSHOW
+       }               type;
+
+       struct groupdevid *id;
+       const char      *dest;
+       uid_t           uid;
+       uid_t           gid;
+       int             mode;
+       int             jail;
+
+       TAILQ_ENTRY(rule) link;
+};
+
+typedef int (rule_iterate_callback_t)(struct rule *rule,
+               struct groupdevid *id);
+typedef int (rule_parser_t)(char **);
+
+struct groupdevid *new_id(const char *, int);
+struct groupdevid *get_id(const char *);
+struct groupdevid *get_group(const char *, int);
+struct rule *new_rule(int, struct groupdevid *);
+void add_rule(struct rule *);
+int rule_apply(void);
+void dump_config(void);
+int read_config(char *);
+int syntax_error(const char *fmt, ...);
+#endif
index d8e1782..6e78a66 100644 (file)
@@ -1267,22 +1267,12 @@ mount_target_system(struct i_fn_args *a)
 
        /*
         * Create a temporary dummy subpartition - that we
-        * assume exists - for the benefit of ensure_dev et al.
+        * assume exists
         */
 
        a_subpart = subpartition_new(storage_get_selected_slice(a->s),
            "/dummy", 0, 0, 0, 0, 0);
 
-       /*
-        * Ensure that the devices we'll be using exist.
-        */
-       command_add_ensure_dev(a, cmds,
-           disk_get_device_name(storage_get_selected_disk(a->s)));
-       command_add_ensure_dev(a, cmds,
-           slice_get_device_name(storage_get_selected_slice(a->s)));
-       command_add_ensure_dev(a, cmds,
-           subpartition_get_device_name(a_subpart));
-
        /*
         * Mount the target's / and read its /etc/fstab.
         */
@@ -1298,7 +1288,6 @@ mount_target_system(struct i_fn_args *a)
                    a->os_root,
                    subpartition_get_device_name(a_subpart),
                    a->os_root, a->cfg_root);
-               /* XXX ensure_dev */
                command_add(cmds,
                    "%s%s %sdev/`%s%s \"^vfs\\.root\\.mountfrom\" %sboot/loader.conf |"
                    "%s%s -Fhammer: '{print $2;}' |"
@@ -1395,7 +1384,6 @@ mount_target_system(struct i_fn_args *a)
                                        free(cvtoptions);
                                } else {
                                        if (use_hammer == 0) {
-                                               /* command_add_ensure_dev(a, cmds, device); */
                                                command_add(cmds,
                                                    "%s%s -o %s %s%s %s%s%s",
                                                    a->os_root, cmd_name(a, "MOUNT"),
@@ -1403,7 +1391,6 @@ mount_target_system(struct i_fn_args *a)
                                                    a->os_root, device, a->os_root,
                                                    a->cfg_root, mtpt);
                                        } else {
-                                               /* command_add_ensure_dev(a, cmds, device); */
                                                command_add(cmds,
                                                    "%s%s -o %s %s%s%s %s%s%s",
                                                    a->os_root, cmd_name(a, "MOUNT_NULL"),
index c086319..55b1041 100644 (file)
@@ -203,11 +203,6 @@ fn_format_disk(struct i_fn_args *a)
            "LAST CHANCE to cancel!"), disk_get_desc(storage_get_selected_disk(a->s)))) {
                cmds = commands_new();
 
-               /*
-                * Create the device node if it does not exist.
-                */
-               command_add_ensure_dev(a, cmds,
-                   disk_get_device_name(storage_get_selected_disk(a->s)));
                command_add(cmds, "%s%s -BI %s",
                    a->os_root, cmd_name(a, "FDISK"),
                    disk_get_raw_device_name(storage_get_selected_disk(a->s)));
@@ -630,12 +625,6 @@ format_slice(struct i_fn_args *a)
 
        cmds = commands_new();
 
-       /*
-        * Create the device node if it does not exist.
-        */
-       command_add_ensure_dev(a, cmds,
-           slice_get_device_name(storage_get_selected_slice(a->s)));
-
        /*
         * The information in a->s NEEDS to be accurate here!
         * Presumably we just did a survey_storage() recently.
index 7884942..2720d21 100644 (file)
@@ -199,16 +199,6 @@ create_subpartitions(struct i_fn_args *a)
                if (subpartition_is_swap(sp) || subpartition_is_mfsbacked(sp))
                        continue;
 
-               /*
-                * Ensure that all the needed device nodes exist.
-                */
-               command_add_ensure_dev(a, cmds,
-                   disk_get_device_name(storage_get_selected_disk(a->s)));
-               command_add_ensure_dev(a, cmds,
-                   slice_get_device_name(storage_get_selected_slice(a->s)));
-               command_add_ensure_dev(a, cmds,
-                   subpartition_get_device_name(sp));
-
                if (strcmp(subpartition_get_mountpoint(sp), "/boot") == 0) {
                        command_add(cmds, "%s%s %sdev/%s",
                            a->os_root, cmd_name(a, "NEWFS"),
index a57adc2..a6082bb 100644 (file)
@@ -195,16 +195,6 @@ create_subpartitions(struct i_fn_args *a)
                if (subpartition_is_swap(sp) || subpartition_is_mfsbacked(sp))
                        continue;
 
-               /*
-                * Ensure that all the needed device nodes exist.
-                */
-               command_add_ensure_dev(a, cmds,
-                   disk_get_device_name(storage_get_selected_disk(a->s)));
-               command_add_ensure_dev(a, cmds,
-                   slice_get_device_name(storage_get_selected_slice(a->s)));
-               command_add_ensure_dev(a, cmds,
-                   subpartition_get_device_name(sp));
-
                command_add(cmds, "%s%s%s -b %ld -f %ld %sdev/%s",
                    a->os_root, cmd_name(a, "NEWFS"),
                    subpartition_is_softupdated(sp) ? " -U" : "",
index b2d6d12..3ac03a5 100644 (file)
@@ -570,36 +570,3 @@ commands_free(struct commands *cmds)
        }
        AURA_FREE(cmds, commands);
 }
-
-/*
- * Command generators.
- */
-
-/*
- * Generate a command to create a generic device node
- * only if it does not already exist.
- */
-struct command *
-command_add_ensure_dev(struct i_fn_args *a, struct commands *cmds,
-                      const char *dev_name)
-{
-#if 0
-       struct command *cmd;
-       char *dev_basename;
-
-       dev_basename = basename(dev_name);
-       /*
-        * We don't need to do this on systems with a devfs
-        * (which is, at the time of this writing, FreeBSD 5.x and later.)
-        */
-       cmd = command_add(cmds, "cd %sdev && %s%s %s || %s%s MAKEDEV %s",
-           a->os_root,
-           a->os_root, cmd_name(a, "TEST_DEV"),
-           dev_basename,
-           a->os_root, cmd_name(a, "SH"),
-           dev_basename);
-
-       return(cmd);
-#endif
-       return (NULL);
-}
index b064dff..3adec0a 100644 (file)
@@ -113,9 +113,6 @@ void                 view_command_log(struct i_fn_args *);
 
 /* Command Generators */
 
-struct command *command_add_ensure_dev(struct i_fn_args *,
-                       struct commands *, const char *);
-
 void            unmount_all_under(struct i_fn_args *, struct commands *,
                                   const char *, ...);
 
index 6043ea4..4b3c04d 100644 (file)
@@ -223,8 +223,8 @@ config_vars_read(struct i_fn_args *a, struct config_vars *cvs,
        fclose(script);
 
        cmds = commands_new();
-       command_add(cmds, "%sbin/sh %sextract_vars >%sextracted_vars.txt",
-           a->os_root, a->tmp, a->tmp);
+       command_add(cmds, "%s%s %sextract_vars >%sextracted_vars.txt",
+           a->os_root, cmd_name(a, "SH"), a->tmp, a->tmp);
        temp_file_add(a, "extracted_vars.txt");
        if (!commands_execute(a, cmds)) {
                commands_free(cmds);
index 5fe5161..ce81425 100644 (file)
@@ -222,11 +222,6 @@ survey_storage(struct i_fn_args *a)
                    a->os_root, cmd_name(a, "ECHO"), a->tmp);
                command_set_log_mode(cmd, COMMAND_LOG_SILENT);
 
-               /*
-                * Ensure that the device node for this disk exists,
-                */
-               cmd = command_add_ensure_dev(a, cmds, disk);
-
                /*
                 * Probe the disk with fdisk.
                 */