aboutsummaryrefslogtreecommitdiffstats
path: root/fs/filesystems.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2007-05-08 03:25:43 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:01 -0400
commit79c0b2df79eb56fc71e54c75cd7fb3acf84370f9 (patch)
treef19be816fef3565b7f9cc746786e29fee0ac62e6 /fs/filesystems.c
parent880afc4d76af452267174b5989943f081c1db2c0 (diff)
add filesystem subtype support
There's a slight problem with filesystem type representation in fuse based filesystems. From the kernel's view, there are just two filesystem types: fuse and fuseblk. From the user's view there are lots of different filesystem types. The user is not even much concerned if the filesystem is fuse based or not. So there's a conflict of interest in how this should be represented in fstab, mtab and /proc/mounts. The current scheme is to encode the real filesystem type in the mount source. So an sshfs mount looks like this: sshfs#user@server:/ /mnt/server fuse rw,nosuid,nodev,... This url-ish syntax works OK for sshfs and similar filesystems. However for block device based filesystems (ntfs-3g, zfs) it doesn't work, since the kernel expects the mount source to be a real device name. A possibly better scheme would be to encode the real type in the type field as "type.subtype". So fuse mounts would look like this: /dev/hda1 /mnt/windows fuseblk.ntfs-3g rw,... user@server:/ /mnt/server fuse.sshfs rw,nosuid,nodev,... This patch adds the necessary code to the kernel so that this can be correctly displayed in /proc/mounts. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/filesystems.c')
-rw-r--r--fs/filesystems.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/fs/filesystems.c b/fs/filesystems.c
index 7a4f61aa05f8..f37f87262837 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -41,11 +41,12 @@ void put_filesystem(struct file_system_type *fs)
41 module_put(fs->owner); 41 module_put(fs->owner);
42} 42}
43 43
44static struct file_system_type **find_filesystem(const char *name) 44static struct file_system_type **find_filesystem(const char *name, unsigned len)
45{ 45{
46 struct file_system_type **p; 46 struct file_system_type **p;
47 for (p=&file_systems; *p; p=&(*p)->next) 47 for (p=&file_systems; *p; p=&(*p)->next)
48 if (strcmp((*p)->name,name) == 0) 48 if (strlen((*p)->name) == len &&
49 strncmp((*p)->name, name, len) == 0)
49 break; 50 break;
50 return p; 51 return p;
51} 52}
@@ -68,11 +69,12 @@ int register_filesystem(struct file_system_type * fs)
68 int res = 0; 69 int res = 0;
69 struct file_system_type ** p; 70 struct file_system_type ** p;
70 71
72 BUG_ON(strchr(fs->name, '.'));
71 if (fs->next) 73 if (fs->next)
72 return -EBUSY; 74 return -EBUSY;
73 INIT_LIST_HEAD(&fs->fs_supers); 75 INIT_LIST_HEAD(&fs->fs_supers);
74 write_lock(&file_systems_lock); 76 write_lock(&file_systems_lock);
75 p = find_filesystem(fs->name); 77 p = find_filesystem(fs->name, strlen(fs->name));
76 if (*p) 78 if (*p)
77 res = -EBUSY; 79 res = -EBUSY;
78 else 80 else
@@ -215,19 +217,26 @@ int get_filesystem_list(char * buf)
215struct file_system_type *get_fs_type(const char *name) 217struct file_system_type *get_fs_type(const char *name)
216{ 218{
217 struct file_system_type *fs; 219 struct file_system_type *fs;
220 const char *dot = strchr(name, '.');
221 unsigned len = dot ? dot - name : strlen(name);
218 222
219 read_lock(&file_systems_lock); 223 read_lock(&file_systems_lock);
220 fs = *(find_filesystem(name)); 224 fs = *(find_filesystem(name, len));
221 if (fs && !try_module_get(fs->owner)) 225 if (fs && !try_module_get(fs->owner))
222 fs = NULL; 226 fs = NULL;
223 read_unlock(&file_systems_lock); 227 read_unlock(&file_systems_lock);
224 if (!fs && (request_module("%s", name) == 0)) { 228 if (!fs && (request_module("%.*s", len, name) == 0)) {
225 read_lock(&file_systems_lock); 229 read_lock(&file_systems_lock);
226 fs = *(find_filesystem(name)); 230 fs = *(find_filesystem(name, len));
227 if (fs && !try_module_get(fs->owner)) 231 if (fs && !try_module_get(fs->owner))
228 fs = NULL; 232 fs = NULL;
229 read_unlock(&file_systems_lock); 233 read_unlock(&file_systems_lock);
230 } 234 }
235
236 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
237 put_filesystem(fs);
238 fs = NULL;
239 }
231 return fs; 240 return fs;
232} 241}
233 242