mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
fs: simplify get_filesystem_list / get_all_fs_names
Just output the '\0' separate list of supported file systems for block devices directly rather than going through a pointless round of string manipulation. Based on an earlier patch from Al Viro <viro@zeniv.linux.org.uk>. Vivek: Modified list_bdev_fs_names() and split_fs_names() to return number of null terminted strings to caller. Callers now use that information to loop through all the strings instead of relying on one extra null char being present at the end. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
committed by
Al Viro
parent
f9259be6a9
commit
6e7c1770a2
@@ -209,21 +209,28 @@ SYSCALL_DEFINE3(sysfs, int, option, unsigned long, arg1, unsigned long, arg2)
|
||||
}
|
||||
#endif
|
||||
|
||||
int __init get_filesystem_list(char *buf)
|
||||
int __init list_bdev_fs_names(char *buf, size_t size)
|
||||
{
|
||||
int len = 0;
|
||||
struct file_system_type * tmp;
|
||||
struct file_system_type *p;
|
||||
size_t len;
|
||||
int count = 0;
|
||||
|
||||
read_lock(&file_systems_lock);
|
||||
tmp = file_systems;
|
||||
while (tmp && len < PAGE_SIZE - 80) {
|
||||
len += sprintf(buf+len, "%s\t%s\n",
|
||||
(tmp->fs_flags & FS_REQUIRES_DEV) ? "" : "nodev",
|
||||
tmp->name);
|
||||
tmp = tmp->next;
|
||||
for (p = file_systems; p; p = p->next) {
|
||||
if (!(p->fs_flags & FS_REQUIRES_DEV))
|
||||
continue;
|
||||
len = strlen(p->name) + 1;
|
||||
if (len > size) {
|
||||
pr_warn("%s: truncating file system list\n", __func__);
|
||||
break;
|
||||
}
|
||||
memcpy(buf, p->name, len);
|
||||
buf += len;
|
||||
size -= len;
|
||||
count++;
|
||||
}
|
||||
read_unlock(&file_systems_lock);
|
||||
return len;
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
|
Reference in New Issue
Block a user