I have a question regarding mounting filesystem without giving filesystem type as argument to mount command: AFAIK when mount command is run to mount a FS the corresponding call made in kernel is "compat_sys_mount" as per kernel 2.6.36. Now compat_sys_kernel expects a filesystem "type" name as argument but in compat_sys_mount there is no check for "type" argument as NULL, now as part of this mount path do_kern_mount also called which uses the "type" argument to compat_sys_mount and finds out the corresponding file_system_type structure from the file_system_type structure list and if not matching structure is found it returns with error. 842 asmlinkage long compat_sys_mount(const char __user * dev_name, 843 const char __user * dir_name, 844 const char __user * type, unsigned long flags, <====== type argument to compat_sys_mount 845 const void __user * data) 846 { 847 char *kernel_type; 848 unsigned long data_page; 849 char *kernel_dev; 850 char *dir_page; 851 int retval; 852 853 retval = copy_mount_string(type, &kernel_type); 1098 do_kern_mount(const char *fstype, int flags, const char *name, void *data) 1099 { 1100 struct file_system_type *type = get_fs_type(fstype); <======= same type argument to search in list 1101 struct vfsmount *mnt; 1102 if (!type) <======= if the type name entry not found in list return ERRROR 1103 return ERR_PTR(-ENODEV); 1104 mnt = vfs_kern_mount(type, flags, name, data); 1105 if (!IS_ERR(mnt) && (type->fs_flags & FS_HAS_SUBTYPE) && 1106 !mnt->mnt_sb->s_subtype) 1107 mnt = fs_set_subtype(mnt, fstype); 1108 put_filesystem(type); 1109 return mnt; 1110 } Now my question is that if I don't provide FS type name to mount command how the FS gets mounted. Is there some other path for this code or if before calling compat_sys_mount i.e in user mode FS type is determined somehow? Regards, Piyush
On Thu, Jul 21, 2011 at 10:20 AM, piyush moghe <pmkernel@gmail.com> wrote:
I have a question regarding mounting filesystem without giving filesystem type as argument to mount command:
Now my question is that if I don't provide FS type name to mount command how the FS gets mounted. Is there some other path for this code or if before calling compat_sys_mount i.e in user mode FS type is determined somehow?
Regards, Piyush
Hello Piyush, The mount command, resolves in userspace. Most mount binaries are compiled against libblkid library that is used to identify the content of block devices. root@aopcjm:~# ldd /bin/mount | grep blkid libblkid.so.1 => /lib/libblkid.so.1 (0xb76e3000) Mounting without specifying the FS type for my pendrive, the mount syscall is invoked with FS type vfat root@aopcjm:~# strace -emount mount /dev/sdb1 /mnt/pendrive/ mount("/dev/sdb1", "/mnt/pendrive/", "vfat", MS_MGC_VAL, NULL) = 0 Is very well described in the mount man page: If no -t option is given, or if the auto type is specified, mount will try to guess the desired type. If mount was compiled with the blkid library, the guessing is done by this library. Otherwise, mount guesses itself by probing the superblock; if that does not turn up anything that looks familiar, mount will try to read the file /etc/filesystems, or, if that does not exist, /proc/filesystems. All of the filesystem types listed there will be tried, except for those that are labeled "nodev" (e.g., devpts, proc, nfs, and nfs4). If /etc/filesystems ends in a line with a single * only, mount will read /proc/filesystems afterwards.
From the blkid man page:
The blkid program is the command-line interface to working with libuuid(3) library. It can determine the type of content (e.g. filesystem, swap) a block device holds, and also attributes (tokens, NAME=value pairs) from the content metadata (e.g. LABEL or UUID fields). Hope this helps, -- Javier Martínez Canillas (+34) 682 39 81 69 PhD Student in High Performance Computing Computer Architecture and Operating System Department (CAOS) Universitat Autònoma de Barcelona Barcelona, Spain
On Thu, Jul 21, 2011 at 7:37 AM, Javier Martinez Canillas <martinez.javier@gmail.com> wrote:
On Thu, Jul 21, 2011 at 10:20 AM, piyush moghe <pmkernel@gmail.com> wrote:
I have a question regarding mounting filesystem without giving filesystem type as argument to mount command:
Now my question is that if I don't provide FS type name to mount command how the FS gets mounted. Is there some other path for this code or if before calling compat_sys_mount i.e in user mode FS type is determined somehow?
Regards, Piyush
Hello Piyush,
The mount command, resolves in userspace. Most mount binaries are compiled against libblkid library that is used to identify the content of block devices.
root@aopcjm:~# ldd /bin/mount | grep blkid libblkid.so.1 => /lib/libblkid.so.1 (0xb76e3000)
Mounting without specifying the FS type for my pendrive, the mount syscall is invoked with FS type vfat
root@aopcjm:~# strace -emount mount /dev/sdb1 /mnt/pendrive/ mount("/dev/sdb1", "/mnt/pendrive/", "vfat", MS_MGC_VAL, NULL) = 0
Is very well described in the mount man page:
If no -t option is given, or if the auto type is specified, mount will try to guess the desired type. If mount was compiled with the blkid library, the guessing is done by this library. Otherwise, mount guesses itself by probing the superblock; if that does not turn up anything that looks familiar, mount will try to read the file /etc/filesystems, or, if that does not exist, /proc/filesystems. All of the filesystem types listed there will be tried, except for those that are labeled "nodev" (e.g., devpts, proc, nfs, and nfs4). If /etc/filesystems ends in a line with a single * only, mount will read /proc/filesystems afterwards.
From the blkid man page:
The blkid program is the command-line interface to working with libuuid(3) library. It can determine the type of content (e.g. filesystem, swap) a block device holds, and also attributes (tokens, NAME=value pairs) from the content metadata (e.g. LABEL or UUID fields).
Hope this helps,
Don't forget /etc/fstab. I almost positive the priority is: - command line arg - /etc/fstab - auto-detect Greg
On Thu, Jul 21, 2011 at 10:36 PM, Greg Freemyer <greg.freemyer@gmail.com> wrote:
Don't forget /etc/fstab.
I almost positive the priority is:
- command line arg - /etc/fstab - auto-detect
Greg
Didn't know that mount uses /etc/fstab, but you are right there is valuable information there. Thanks a lot. -- Javier Martínez Canillas (+34) 682 39 81 69 PhD Student in High Performance Computing Computer Architecture and Operating System Department (CAOS) Universitat Autònoma de Barcelona Barcelona, Spain
Thanks Javier and Greg. It answered my question. Regards, Piyush On Fri, Jul 22, 2011 at 3:01 AM, Javier Martinez Canillas < martinez.javier@gmail.com> wrote:
On Thu, Jul 21, 2011 at 10:36 PM, Greg Freemyer <greg.freemyer@gmail.com> wrote:
Don't forget /etc/fstab.
I almost positive the priority is:
- command line arg - /etc/fstab - auto-detect
Greg
Didn't know that mount uses /etc/fstab, but you are right there is valuable information there.
Thanks a lot.
-- Javier Martínez Canillas (+34) 682 39 81 69 PhD Student in High Performance Computing Computer Architecture and Operating System Department (CAOS) Universitat Autònoma de Barcelona Barcelona, Spain
participants (3)
-
Greg Freemyer -
Javier Martinez Canillas -
piyush moghe