Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys PR/1796: John Kohl: statfs misbehaves under chrooted env...



details:   https://anonhg.NetBSD.org/src/rev/147ee6d743a5
branches:  trunk
changeset: 545827:147ee6d743a5
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Apr 16 21:44:18 2003 +0000

description:
PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
  and factored out some of the vfsop statfs() code to copy_statfs_info(). This
  fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.

diffstat:

 sys/coda/coda_vfsops.c              |   15 +--
 sys/fs/adosfs/advfsops.c            |   19 +---
 sys/fs/cd9660/cd9660_vfsops.c       |   19 +---
 sys/fs/filecorefs/filecore_vfsops.c |   19 +---
 sys/fs/msdosfs/msdosfs_vfsops.c     |   19 +---
 sys/fs/ntfs/ntfs_vfsops.c           |   43 ++--------
 sys/fs/smbfs/smbfs_vfsops.c         |   26 +----
 sys/fs/union/union_vfsops.c         |   17 +--
 sys/kern/vfs_subr.c                 |   88 +++++++++++++++++++++-
 sys/kern/vfs_syscalls.c             |  145 +++++++++++++++++++++++++----------
 sys/miscfs/fdesc/fdesc_vfsops.c     |   20 +---
 sys/miscfs/genfs/layer_vfsops.c     |   11 +-
 sys/miscfs/kernfs/kernfs_vfsops.c   |   20 +---
 sys/miscfs/nullfs/null_vfsops.c     |   14 +--
 sys/miscfs/overlay/overlay_vfsops.c |   14 +--
 sys/miscfs/portal/portal_vfsops.c   |   20 +---
 sys/miscfs/procfs/procfs_vfsops.c   |   21 +---
 sys/miscfs/umapfs/umap_vfsops.c     |   14 +--
 sys/nfs/nfs_vfsops.c                |   17 +--
 sys/sys/mount.h                     |    7 +-
 sys/ufs/ext2fs/ext2fs_vfsops.c      |   22 +---
 sys/ufs/ffs/ffs_vfsops.c            |   21 +---
 sys/ufs/lfs/lfs_vfsops.c            |   20 +---
 sys/ufs/mfs/mfs_vfsops.c            |   17 +--
 24 files changed, 318 insertions(+), 330 deletions(-)

diffs (truncated from 1529 to 300 lines):

diff -r 116340ac4d7e -r 147ee6d743a5 sys/coda/coda_vfsops.c
--- a/sys/coda/coda_vfsops.c    Wed Apr 16 21:37:37 2003 +0000
+++ b/sys/coda/coda_vfsops.c    Wed Apr 16 21:44:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vfsops.c,v 1.21 2003/02/01 06:23:36 thorpej Exp $ */
+/*     $NetBSD: coda_vfsops.c,v 1.22 2003/04/16 21:44:18 christos Exp $        */
 
 /*
  * 
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.21 2003/02/01 06:23:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.22 2003/04/16 21:44:18 christos Exp $");
 
 #ifdef _LKM
 #define        NVCODA 4
@@ -266,8 +266,9 @@
        MARK_INT_FAIL(CODA_MOUNT_STATS);
     else
        MARK_INT_SAT(CODA_MOUNT_STATS);
-    
-    return(error);
+
+    return set_statfs_info("/coda", UIO_SYSSPACE, "CODA", UIO_SYSSPACE, vfsp,
+       p);
 }
 
 int
@@ -453,11 +454,7 @@
        sbp->f_bavail = fsstat.f_bavail;
        sbp->f_files  = fsstat.f_files;
        sbp->f_ffree  = fsstat.f_ffree;
-        bcopy((caddr_t)&(vfsp->mnt_stat.f_fsid),
-             (caddr_t)&(sbp->f_fsid), sizeof (fsid_t));
-        strncpy(sbp->f_fstypename, MOUNT_CODA, MFSNAMELEN-1);
-        strcpy(sbp->f_mntonname, "/coda");
-        strcpy(sbp->f_mntfromname, "CODA");
+       copy_statfs_info(sbp, vfsp);
     }
 
     MARK_INT_SAT(CODA_STATFS_STATS);
diff -r 116340ac4d7e -r 147ee6d743a5 sys/fs/adosfs/advfsops.c
--- a/sys/fs/adosfs/advfsops.c  Wed Apr 16 21:37:37 2003 +0000
+++ b/sys/fs/adosfs/advfsops.c  Wed Apr 16 21:44:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: advfsops.c,v 1.3 2003/03/21 23:11:24 dsl Exp $ */
+/*     $NetBSD: advfsops.c,v 1.4 2003/04/16 21:44:18 christos Exp $    */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.3 2003/03/21 23:11:24 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.4 2003/04/16 21:44:18 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -103,7 +103,6 @@
        struct vnode *devvp;
        struct adosfs_args args;
        struct adosfsmount *amp;
-       size_t size;
        int error;
        mode_t accessmode;
 
@@ -175,12 +174,8 @@
        amp->uid = args.uid;
        amp->gid = args.gid;
        amp->mask = args.mask;
-       (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
-       memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
-       (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
-           &size);
-       memset(mp->mnt_stat.f_mntfromname + size, 0, MNAMELEN - size);
-       return (0);
+       return set_statfs_info(path, UIO_USERSPACE, args.fspec, UIO_USERSPACE,
+           mp, p);
 }
 
 int
@@ -381,11 +376,7 @@
        sbp->f_bavail = amp->freeblks;
        sbp->f_files = 0;               /* who knows */
        sbp->f_ffree = 0;               /* " " */
-       if (sbp != &mp->mnt_stat) {
-               memcpy(sbp->f_mntonname, mp->mnt_stat.f_mntonname, MNAMELEN);
-               memcpy(sbp->f_mntfromname, mp->mnt_stat.f_mntfromname, MNAMELEN);
-       }
-       strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
+       copy_statfs_info(sbp, mp);
        return (0);
 }
 
diff -r 116340ac4d7e -r 147ee6d743a5 sys/fs/cd9660/cd9660_vfsops.c
--- a/sys/fs/cd9660/cd9660_vfsops.c     Wed Apr 16 21:37:37 2003 +0000
+++ b/sys/fs/cd9660/cd9660_vfsops.c     Wed Apr 16 21:44:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_vfsops.c,v 1.4 2003/04/03 15:37:55 christos Exp $       */
+/*     $NetBSD: cd9660_vfsops.c,v 1.5 2003/04/16 21:44:19 christos Exp $       */
 
 /*-
  * Copyright (c) 1994
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.4 2003/04/03 15:37:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.5 2003/04/16 21:44:19 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -177,7 +177,6 @@
 {
        struct vnode *devvp;
        struct iso_args args;
-       size_t size;
        int error;
        struct iso_mnt *imp = NULL;
        
@@ -249,12 +248,8 @@
                return error;
        }
        imp = VFSTOISOFS(mp);
-       (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
-       memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
-       (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
-           &size);
-       memset(mp->mnt_stat.f_mntfromname + size, 0, MNAMELEN - size);
-       return 0;
+       return set_statfs_info(path, UIO_USERSPACE, args.fspec, UIO_USERSPACE,
+           mp, p);
 }
 
 /*
@@ -643,11 +638,7 @@
        sbp->f_bavail = 0; /* blocks free for non superuser */
        sbp->f_files =  0; /* total files */
        sbp->f_ffree = 0; /* free file nodes */
-       if (sbp != &mp->mnt_stat) {
-               memcpy(sbp->f_mntonname, mp->mnt_stat.f_mntonname, MNAMELEN);
-               memcpy(sbp->f_mntfromname, mp->mnt_stat.f_mntfromname, MNAMELEN);
-       }
-       strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
+       copy_statfs_info(sbp, mp);
        /* Use the first spare for flags: */
        sbp->f_spare[0] = isomp->im_flags;
        return 0;
diff -r 116340ac4d7e -r 147ee6d743a5 sys/fs/filecorefs/filecore_vfsops.c
--- a/sys/fs/filecorefs/filecore_vfsops.c       Wed Apr 16 21:37:37 2003 +0000
+++ b/sys/fs/filecorefs/filecore_vfsops.c       Wed Apr 16 21:44:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecore_vfsops.c,v 1.2 2003/02/01 06:23:41 thorpej Exp $      */
+/*     $NetBSD: filecore_vfsops.c,v 1.3 2003/04/16 21:44:19 christos Exp $     */
 
 /*-
  * Copyright (c) 1998 Andrew McMurry
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.2 2003/02/01 06:23:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.3 2003/04/16 21:44:19 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -159,7 +159,6 @@
 {
        struct vnode *devvp;
        struct filecore_args args;
-       size_t size;
        int error;
        struct filecore_mnt *fcmp = NULL;
        
@@ -233,12 +232,8 @@
                return error;
        }
        fcmp = VFSTOFILECORE(mp);
-       (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
-       memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
-       (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
-           &size);
-       memset(mp->mnt_stat.f_mntfromname + size, 0, MNAMELEN - size);
-       return 0;
+       return set_statfs_info(path, UIO_USERSPACE, args.fspec, UIO_USERSPACE,
+           mp, p);
 }
 
 /*
@@ -484,11 +479,7 @@
        sbp->f_bavail = 0; /* blocks free for non superuser */
        sbp->f_files =  0; /* total files */
        sbp->f_ffree = 0; /* free file nodes */
-       if (sbp != &mp->mnt_stat) {
-               memcpy(sbp->f_mntonname, mp->mnt_stat.f_mntonname, MNAMELEN);
-               memcpy(sbp->f_mntfromname, mp->mnt_stat.f_mntfromname, MNAMELEN);
-       }
-       strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
+       copy_statfs_info(sbp, mp);
        return 0;
 }
 
diff -r 116340ac4d7e -r 147ee6d743a5 sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c   Wed Apr 16 21:37:37 2003 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c   Wed Apr 16 21:44:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vfsops.c,v 1.3 2003/03/21 23:11:25 dsl Exp $   */
+/*     $NetBSD: msdosfs_vfsops.c,v 1.4 2003/04/16 21:44:19 christos Exp $      */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.3 2003/03/21 23:11:25 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.4 2003/04/16 21:44:19 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -245,7 +245,6 @@
        struct msdosfs_args args; /* will hold data from mount request */
        /* msdosfs specific mount control block */
        struct msdosfsmount *pmp = NULL;
-       size_t size;
        int error, flags;
        mode_t accessmode;
 
@@ -367,15 +366,11 @@
                return error;
        }
 
-       (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
-       memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
-       (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
-           &size);
-       memset(mp->mnt_stat.f_mntfromname + size, 0, MNAMELEN - size);
 #ifdef MSDOSFS_DEBUG
        printf("msdosfs_mount(): mp %p, pmp %p, inusemap %p\n", mp, pmp, pmp->pm_inusemap);
 #endif
-       return (0);
+       return set_statfs_info(path, UIO_USERSPACE, args.fspec, UIO_USERSPACE,
+           mp, p);
 }
 
 int
@@ -875,11 +870,7 @@
        sbp->f_bavail = pmp->pm_freeclustercount;
        sbp->f_files = pmp->pm_RootDirEnts;                     /* XXX */
        sbp->f_ffree = 0;       /* what to put in here? */
-       if (sbp != &mp->mnt_stat) {
-               memcpy(sbp->f_mntonname, mp->mnt_stat.f_mntonname, MNAMELEN);
-               memcpy(sbp->f_mntfromname, mp->mnt_stat.f_mntfromname, MNAMELEN);
-       }
-       strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
+       copy_statfs_info(sbp, mp);
        return (0);
 }
 
diff -r 116340ac4d7e -r 147ee6d743a5 sys/fs/ntfs/ntfs_vfsops.c
--- a/sys/fs/ntfs/ntfs_vfsops.c Wed Apr 16 21:37:37 2003 +0000
+++ b/sys/fs/ntfs/ntfs_vfsops.c Wed Apr 16 21:44:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_vfsops.c,v 1.3 2003/04/09 16:18:17 jdolecek Exp $ */
+/*     $NetBSD: ntfs_vfsops.c,v 1.4 2003/04/16 21:44:20 christos Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.3 2003/04/09 16:18:17 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.4 2003/04/16 21:44:20 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -246,7 +246,6 @@
        struct nameidata *ndp,
        struct proc *p )
 {
-       size_t          size;
        int             err = 0;
        struct vnode    *devvp;
        struct ntfs_args args;
@@ -369,12 +368,8 @@
                 * Update device name only on success
                 */
                if( !err) {
-                       /* Save "mounted from" info for mount point (NULL pad)*/
-                       copyinstr(      args.fspec,
-                                       mp->mnt_stat.f_mntfromname,
-                                       MNAMELEN - 1,
-                                       &size);
-                       bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
+                       err = set_statfs_info(NULL, UIO_USERSPACE, args.fspec,
+                           UIO_USERSPACE, mp, p);



Home | Main Index | Thread Index | Old Index