Subject: mount(2) option to retrieve arguments
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 09/20/2002 19:34:23
Hello,

I added a mount option in my kernel (MNT_GETARGS), that retrieves the
fs-specific mount arguments. The code is pretty straight forward and
allows one to do:

mount -vv
/dev/wd0a on / type ffs (local, root file system, writes: sync 462 async 270)
/dev/wd0f on /var type ffs (local, writes: sync 713 async 736)
/dev/wd0e on /usr type ffs (local, writes: sync 2 async 495)
/dev/wd0g on /usr/local type ffs (local, writes: sync 2 async 140)
/dev/wd0h on /home type ffs (NFS exported, local, writes: sync 429 async 448)
mfs:161 on /tmp type mfs (local, writes: sync 149 async 97, [mfs: base=0xbbeb2000, size=15360000])
kernfs on /kern type kernfs (local, writes: sync 0 async 0)
procfs on /proc type procfs (local, writes: sync 0 async 0)
fdesc on /dev type fdesc (union, local, writes: sync 0 async 0)
gw2:/home/sparc/root on /mnt type nfs (writes: sync 0 async 0, [nfs: version=3, addrlen=0, sotype=2, proto=0, fhsize=0, flags=0x8280<noconn,nfsv3,resvport>, wsize=32768, rsize=32768, readdirsize=8192, timeo=300, retrans=10, maxgrouplist=16, readahead=2, leaseterm=30, deadthresh=-882516348])

Each filesystem's mount code is modified in the following manner, the
following example is taken from mfs:

	if (mp->mnt_flag & MNT_GETARGS) {
                struct vnode *vp;
                struct mfsnode *mfsp;
        
                ump = VFSTOUFS(mp); 
                if (ump == NULL)
                        return EIO;
        
                vp = ump->um_devvp;
                if (vp == NULL)
                        return EIO;
        
                mfsp = VTOMFS(vp);
                if (mfsp == NULL)
                        return EIO;
        
                args.fspec = NULL;
                vfs_showexport(mp, &args.export, &ump->um_export);
                args.base = mfsp->mfs_baseoff;
                args.size = mfsp->mfs_size;
                return copyout(&args, data, sizeof(args));
        }


	- I have added this to all the filesystems in the kernel.
	- Pointer fields are not currently supported. This can
	  be fixed, but it is probably more trouble than it is worth.
	- I have not implemented vfs_showexport() yet [it is a memset(0) now].
	- I only implemented mfs and nfs in userland.

What do you think? Should I commit?

christos