/sbin/mount and /proc/mounts difference
Subsystems (2)
Hi,
When running "mount" I see:
~$ mount
/dev/hda6 on / type reiserfs (rw)
proc on /proc type proc (rw)
/dev/hda1 on /boot type ext2 (rw)
/dev/hda7 on /usr type reiserfs (rw,noatime,notail) /dev/hda8 on /home type reiserfs (rw,nosuid,nodev,noatime,notail) /dev/hda9 on /var type reiserfs (rw,noexec,nodev) /dev/hda10 on /tmp type reiserfs (rw,noexec,nosuid,nodev)
while /proc/mounts says
~$ cat /proc/mounts
/dev/root / reiserfs rw 0 0
/proc /proc proc rw 0 0
/dev/hda1 /boot ext2 rw 0 0
/dev/hda7 /usr reiserfs rw,noatime 0 0 /dev/hda8 /home reiserfs rw,noatime,nosuid,nodev 0 0 /dev/hda9 /var reiserfs rw,nodev,noexec 0 0 /dev/hda10 /tmp reiserfs rw,nosuid,nodev,noexec 0 0
As you can see the notail-option of reiserfs isn't listed on /proc/mounts, but it is on "mount".
Does this have any particular reason?
Wkr,
Sven Vermeulen
Signature · 2 lines
Unix, MS-DOS and Windows NT (also known as the Good, the Bad and the Ugly). ~(Matt Welsh)
Quoted 5 lines · * Sven Vermeulen ([email protected]) wrote:
As you can see the notail-option of reiserfs isn't listed on
/proc/mounts, but it is on "mount".Does this have any particular reason?
Sure, mount reads /etc/mtab.
Stephen
Quoted 4 lines · Sven Vermeulen
As you can see the notail-option of reiserfs isn't listed on
/proc/mounts, but it is on "mount".Does this have any particular reason?
mount writes everything to /etc/mtab and displays that when asked.
The kernel doesn't ask the individual filesystem "drivers" if they have some options they would like to list there. So for /proc it simply lists the options the VFS knows about. Except for NFS that for some reson has code there.
I don't know if there are any plans to change that. Wouldn't be difficult to add something to super_operations.
fs/namespace.c:
show_vfsmnt
show_nfs_mount
If it is important to you, you could add a "show_reiserfs_mount" by copying how things are done for nfs.
/Urban
Quoted 8 lines · Urban Widmark
On Sun, 18 Nov 2001, Sven Vermeulen wrote:
I don't know if there are any plans to change that. Wouldn't be difficult to add something to
super_operations.
fs/namespace.c:
show_vfsmnt
show_nfs_mount
Well, now that's easy to do. With the old code (FVO "old" equal to 2.4.15-pre2) you would end up with mind-boggling amount of buffer overruns _and_ ugly code in filesystems.
I would rather start messing with that area with cleaning up mount options' parsers - I've got a patch that does it, it just needs to be ported to recent trees.
PATCH 1/1 fs-specific options in /proc/mounts
Quoted 9 lines · Alexander Viro
Quoted 6 lines · Urban Widmark
I don't know if there are any plans to change that. Wouldn't be difficult to add something to
super_operations.
fs/namespace.c:
show_vfsmnt
show_nfs_mount
Quoted 7 lines
Well, now that's easy to do. With the old code (FVO "old" equal to 2.4.15-pre2) you would end up with mind-boggling amount of buffer overruns _and_ ugly code in filesystems.
I would rather start messing with that area with cleaning up mount options' parsers - I've got a patch that does it, it just needs to be ported to recent trees.
OTOH... This stuff is really trivial now, so that can easily go into 2.4.
* new superblock method: ->show_options(). It's optional and if
present - used by show_vfsmnt() (i.e. /proc/mounts) to show fs-specific options.
* Prototype: int (*show_options)(struct seq_file *, struct vfsmount *);
Use seq_{putc,puts,printf,escape} for output (see fs/nfs/inode.c for example of use). Pointer to seq_file describes the output buffer (first argument of seq_...().
* Return 0 in case of success, negative - in case of fatal error
(e.g. your function needs to allocate memory and fails). read() from /proc/mounts will fail at that point, so if you see that e.g. server is all fucked up - say seq_puts(m, "server_all_fucked_up"); and return 0 instead of returning -EINVAL.
* The only lock held by caller is mount_sem. Method may block,
allocate memory, cause IO, yodda, yodda. It must not call path_walk() (e.g. filp_open() is off-limits) since that could deadlock if lookup triggers automount.
Patch below moves handling of NFS-specific options into such
method; if you want to show some fs-specific options in your fs - add ->show_options() in your super_operations.
fs/namespace.c +4 -47
@@ -19,9 +19,6 @@#include <asm/uaccess.h> -#include <linux/nfs_fs.h> -#include <linux/nfs_fs_sb.h> -#include <linux/nfs_mount.h> #include <linux/seq_file.h> struct vfsmount *do_kern_mount (char *type,int flags,char *name,void *data);
@@ -198,50 +195,10 @@seq_escape (m, s," \t\n\\" ); } -static void show_nfs_mount (struct seq_file *m,struct vfsmount *mnt) -{ -static struct proc_nfs_info { -int flag; -char *str; -char *nostr; - } nfs_info[] = { - {NFS_MOUNT_SOFT ,",soft" ,",hard" }, - {NFS_MOUNT_INTR ,",intr" ,"" }, - {NFS_MOUNT_POSIX ,",posix" ,"" }, - {NFS_MOUNT_TCP ,",tcp" ,",udp" }, - {NFS_MOUNT_NOCTO ,",nocto" ,"" }, - {NFS_MOUNT_NOAC ,",noac" ,"" }, - {NFS_MOUNT_NONLM ,",nolock" ,",lock" }, - {NFS_MOUNT_BROKEN_SUID ,",broken_suid" ,"" }, - {0 ,NULL ,NULL } - }; -struct proc_nfs_info *nfs_infop; -struct nfs_server *nfss = &mnt->mnt_sb->u.nfs_sb.s_server; - -seq_printf (m,",v%d" , nfss->rpc_ops->version); -seq_printf (m,",rsize=%d" , nfss->rsize); -seq_printf (m,",wsize=%d" , nfss->wsize); -if (nfss->acregmin !=3 *HZ ) -seq_printf (m,",acregmin=%d" , nfss->acregmin/HZ ); -if (nfss->acregmax !=60 *HZ ) -seq_printf (m,",acregmax=%d" , nfss->acregmax/HZ ); -if (nfss->acdirmin !=30 *HZ ) -seq_printf (m,",acdirmin=%d" , nfss->acdirmin/HZ ); -if (nfss->acdirmax !=60 *HZ ) -seq_printf (m,",acdirmax=%d" , nfss->acdirmax/HZ ); -for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { -if (nfss->flags & nfs_infop->flag) -seq_puts (m, nfs_infop->str); -else -seq_puts (m, nfs_infop->nostr); - } -seq_puts (m,",addr=" ); -mangle (m, nfss->hostname); -} -static int show_vfsmnt (struct seq_file *m,void *v) {struct vfsmount *mnt = v; +int err =0 ; static struct proc_fs_info { int flag; char *str;
@@ -281,10 +238,10 @@if (mnt->mnt_flags & fs_infop->flag)seq_puts (m, fs_infop->str); } -if (strcmp ("nfs" , mnt->mnt_sb->s_type->name) ==0 ) -show_nfs_mount (m, mnt); +if (mnt->mnt_sb->s_op->show_options) + err = mnt->mnt_sb->s_op->show_options (m, mnt);seq_puts (m," 0 0\n" ); -return 0 ; +return err; }struct seq_operations mounts_op = {
fs/nfs/inode.c +45 -0
69 lines not on this page · raw message
include/linux/fs.h +3 -0
@@ -853,6 +853,8 @@int (*getattr) (struct dentry *,struct iattr *); }; +struct seq_file ; +/* * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called * without the big kernel lock held in all filesystems.
@@ -904,6 +906,7 @@*/ struct dentry * (*fh_to_dentry)(struct super_block *sb,__u32 *fh,int len,int fhtype,int parent);int (*dentry_to_fh)(struct dentry *,__u32 *fh,int *lenp,int need_parent); +int (*show_options)(struct seq_file *,struct vfsmount *); };/* Inode state bits.. */
Quoted 9 lines · Urban Widmark
Quoted 4 lines · Sven Vermeulen
As you can see the notail-option of reiserfs isn't listed on
/proc/mounts, but it is on "mount".Does this have any particular reason?
mount writes everything to
/etc/mtaband displays that when asked.
Not quite...
~/tmp# strings /bin/mount | grep mounts
Note that one does not really mount a device, one mounts /proc/mounts
~/tmp#
Quoted 10 lines · Martin Dalecki
Quoted 2 lines · Urban Widmark
mount writes everything to
/etc/mtaband displays that when asked.Not quite...
~/tmp# strings
/bin/mount| grep mounts
Note that one does not really mount a device, one mounts/proc/mounts
~/tmp#
Not sure what you are trying to show with that grep ...
# strace mount |& grep mounts
# strace mount |& grep mtab
open("/etc/mtab", O_RDONLY) = 3mount does read /etc/mtab for displaying the mounts. It only looks at /proc/mounts if /etc/mtab can't be read. Or at least, that is what the version(s) I have does. I would say that the common setup is to have a readable mtab.
/Urban