On Sat, 21 Apr 2001, Paul Herman wrote:

> This brings up a slightly related question:  Now that "cooked" block
> devices have been abolished, wouldn't it be a good idea to get rid of
> the quick mount(2)/umount(2) of /tmp/df.XXXXXX to stat the file
> system?  Something like the following patch.

No.  This code is just unreachable because it still hasn't be changed
to mount "raw" block devices.

Note that in 4.4BSD, the mount(2)/unmount(2) code works without df
being setgid operator provided group operator can read the devices,
since mount(2) doesn't require superuser privilege in 4.4BSD.  In
FreeBSD, mount privilege is controlled by the vfs.usermount sysctl
(default: off), so df must still be setgid operator to work on devices.

The mount() method is better because can work on work on all types of
filesystems that the kernel understands, while ufs_df() only works
for ufs.

Untested fixes:

Index: df.c
===================================================================
RCS file: /home/ncvs/src/bin/df/df.c,v
retrieving revision 1.24
diff -c -2 -r1.24 df.c
*** df.c        2000/06/03 20:17:39     1.24
--- df.c        2001/04/21 18:52:52
***************
*** 108,112 ****
  void    usage __P((void));
  
! int   aflag = 0, hflag, iflag, nflag;
  struct        ufs_args mdev;
  
--- 108,112 ----
  void    usage __P((void));
  
! int   aflag, hflag, iflag, nflag;
  struct        ufs_args mdev;
  
***************
*** 120,125 ****
        long mntsize;
        int ch, err, i, maxwidth, rv, width;
!       char *mntpt, *mntpath, **vfslist;
  
        vfslist = NULL;
        while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1)
--- 120,126 ----
        long mntsize;
        int ch, err, i, maxwidth, rv, width;
!       char *fstype, *mntpath, *mntpt, **vfslist;
  
+       fstype = "ufs";
        vfslist = NULL;
        while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1)
***************
*** 163,166 ****
--- 164,168 ----
                        if (vfslist != NULL)
                                errx(1, "only one -t option may be specified.");
+                       fstype = optarg;
                        vfslist = makevfslist(optarg);
                        break;
***************
*** 206,213 ****
                                continue;
                        }
!               } else if ((stbuf.st_mode & S_IFMT) == S_IFCHR) {
!                       rv = ufs_df(*argv, maxwidth) || rv;
!                       continue;
!               } else if ((stbuf.st_mode & S_IFMT) == S_IFBLK) {
                        if ((mntpt = getmntpt(*argv)) == 0) {
                                mdev.fspec = *argv;
--- 208,212 ----
                                continue;
                        }
!               } else if (S_ISBLK(stbuf.st_mode) || S_ISCHR(stbuf.st_mode)) {
                        if ((mntpt = getmntpt(*argv)) == 0) {
                                mdev.fspec = *argv;
***************
*** 225,229 ****
                                        continue;
                                }
!                               if (mount("ufs", mntpt, MNT_RDONLY,
                                    &mdev) != 0) {
                                        rv = ufs_df(*argv, maxwidth) || rv;
--- 224,228 ----
                                        continue;
                                }
!                               if (mount(fstype, mntpt, MNT_RDONLY,
                                    &mdev) != 0) {
                                        rv = ufs_df(*argv, maxwidth) || rv;


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to