From f84e3f521e1449300e0fdc314b7b43b418a66dc3 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 8 Feb 2008 04:21:34 -0800 Subject: mount options: add documentation This series addresses the problem of showing mount options in /proc/mounts. Several filesystems which use mount options, have not implemented a .show_options superblock operation. Several others have implemented this callback, but have not kept it fully up to date with the parsed options. Q: Why do we need correct option showing in /proc/mounts? A: We want /proc/mounts to fully replace /etc/mtab. The reasons for this are: - unprivileged mounters won't be able to update /etc/mtab - /etc/mtab doesn't work with private mount namespaces - /etc/mtab can become out-of-sync with reality Q: Can't this be done, so that filesystems need not bother with implementing a .show_mounts callback, and keeping it up to date? A: Only in some cases. Certain filesystems allow modification of a subset of options in their remount_fs method. It is not possible to take this into account without knowing exactly how the filesystem handles options. For the simple case (no remount or remount resets all options) the patchset introduces two helpers: generic_show_options() save_mount_options() These can also be used to emulate the old /etc/mtab behavior, until proper support is added. Even if this is not 100% correct, it's still better than showing no options at all. The following patches fix up most in-tree filesystems, some have been compile tested only, some have been reviewed and acked by the maintainer. Table displaying status of all in-kernel filesystems: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - legend: none - fs has options, but doesn't define ->show_options() some - fs defines ->show_options(), but some only options are shown good - fs shows all options noopt - fs does not have options patch - a patch will be posted merged - a patch has been merged by subsystem maintainer 9p good adfs patch affs patch afs patch autofs patch autofs4 patch befs patch bfs noopt cifs some coda noopt configfs noopt cramfs noopt debugfs noopt devpts patch ecryptfs good efs noopt ext2 patch ext3 good ext4 merged fat patch freevxfs noopt fuse patch fusectl noopt gfs2 good gfs2meta noopt hfs good hfsplus good hostfs patch hpfs patch hppfs noopt hugetlbfs patch isofs patch jffs2 noopt jfs merged minix noopt msdos ->fat ncpfs patch nfs some nfsd noopt ntfs good ocfs2 good ocfs2/dlmfs noopt openpromfs noopt proc noopt qnx4 noopt ramfs noopt reiserfs patch romfs noopt smbfs good sysfs noopt sysv noopt udf patch ufs good vfat ->fat xfs good mm/shmem.c patch drivers/oprofile/oprofilefs.c noopt drivers/infiniband/hw/ipath/ipath_fs.c noopt drivers/misc/ibmasm/ibmasmfs.c noopt drivers/usb/core (usbfs) merged drivers/usb/gadget (gadgetfs) noopt drivers/isdn/capi/capifs.c patch kernel/cpuset.c noopt fs/binfmt_misc.c noopt net/sunrpc/rpc_pipe.c noopt arch/powerpc/platforms/cell/spufs patch arch/s390/hypfs good ipc/mqueue.c noopt security (securityfs) noopt security/selinux/selinuxfs.c noopt kernel/cgroup.c good security/smack/smackfs.c noopt in -mm: reiser4 some unionfs good - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This patch: Document the rules for handling mount options in the .show_options super operation. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/filesystems/vfs.txt | 50 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'Documentation') diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index bd55038b56f5..81e5be6e6e35 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -151,7 +151,7 @@ The get_sb() method has the following arguments: const char *dev_name: the device name we are mounting. void *data: arbitrary mount options, usually comes as an ASCII - string + string (see "Mount Options" section) struct vfsmount *mnt: a vfs-internal representation of a mount point @@ -182,7 +182,7 @@ A fill_super() method implementation has the following arguments: must initialize this properly. void *data: arbitrary mount options, usually comes as an ASCII - string + string (see "Mount Options" section) int silent: whether or not to be silent on error @@ -291,7 +291,8 @@ or bottom half). umount_begin: called when the VFS is unmounting a filesystem. - show_options: called by the VFS to show mount options for /proc//mounts. + show_options: called by the VFS to show mount options for + /proc//mounts. (see "Mount Options" section) quota_read: called by the VFS to read from filesystem quota file. @@ -969,6 +970,49 @@ manipulate dentries: For further information on dentry locking, please refer to the document Documentation/filesystems/dentry-locking.txt. +Mount Options +============= + +Parsing options +--------------- + +On mount and remount the filesystem is passed a string containing a +comma separated list of mount options. The options can have either of +these forms: + + option + option=value + +The header defines an API that helps parse these +options. There are plenty of examples on how to use it in existing +filesystems. + +Showing options +--------------- + +If a filesystem accepts mount options, it must define show_options() +to show all the currently active options. The rules are: + + - options MUST be shown which are not default or their values differ + from the default + + - options MAY be shown which are enabled by default or have their + default value + +Options used only internally between a mount helper and the kernel +(such as file descriptors), or which only have an effect during the +mounting (such as ones controlling the creation of a journal) are exempt +from the above rules. + +The underlying reason for the above rules is to make sure, that a +mount can be accurately replicated (e.g. umounting and mounting again) +based on the information found in /proc/mounts. + +A simple method of saving options at mount/remount time and showing +them is provided with the save_mount_options() and +generic_show_options() helper functions. Please note, that using +these may have drawbacks. For more info see header comments for these +functions in fs/namespace.c. Resources ========= -- cgit v1.2.2