summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-08-12 19:28:27 +0800
committerSascha Hauer <s.hauer@pengutronix.de>2012-09-04 09:08:39 +0200
commita1b1aec6afa625451f531e0b870c8206a3841f69 (patch)
tree0e55a01d0de3e0cfd9fa07dcaee23cf28795db0e /fs
parent7039368327be40b1fc91a4af055f7f71851af1af (diff)
downloadbarebox-a1b1aec6afa625451f531e0b870c8206a3841f69.tar.gz
barebox-a1b1aec6afa625451f531e0b870c8206a3841f69.tar.xz
fs/mount: add autodetection type support
if NULL is pass as type mount will try to autodetect the filesystem type Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/Kconfig5
-rw-r--r--fs/fs.c30
2 files changed, 34 insertions, 1 deletions
diff --git a/fs/Kconfig b/fs/Kconfig
index b75820f4a0..4c66543290 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1,6 +1,11 @@
menu "Filesystem support "
+config FS
+ bool
+ default y
+ select FILETYPE
+
config FS_AUTOMOUNT
bool
diff --git a/fs/fs.c b/fs/fs.c
index 0b376a544b..8ab1a3a7ef 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -954,6 +954,28 @@ int register_fs_driver(struct fs_driver_d *fsdrv)
}
EXPORT_SYMBOL(register_fs_driver);
+static const char *detect_fs(const char *filename)
+{
+ enum filetype type = file_name_detect_type(filename);
+ struct driver_d *drv;
+ struct fs_driver_d *fdrv;
+
+ if (type == filetype_unknown)
+ return NULL;
+
+ for_each_driver(drv) {
+ if (drv->bus != &fs_bus)
+ continue;
+
+ fdrv = drv_to_fs_driver(drv);
+
+ if (type == fdrv->type)
+ return drv->name;
+ }
+
+ return NULL;
+}
+
/*
* Mount a device to a directory.
* We do this by registering a new device on which the filesystem
@@ -985,6 +1007,12 @@ int mount(const char *device, const char *fsname, const char *_path)
}
}
+ if (!fsname)
+ fsname = detect_fs(device);
+
+ if (!fsname)
+ return -ENOENT;
+
fsdev = xzalloc(sizeof(struct fs_device_d));
fsdev->backingstore = xstrdup(device);
safe_strncpy(fsdev->dev.name, fsname, MAX_DRIVER_NAME);
@@ -1222,7 +1250,7 @@ int rmdir (const char *pathname)
fsdev = get_fs_device_and_root_path(&p);
if (!fsdev) {
- ret = -ENOENT;
+ ret = -ENODEV;
goto out;
}
fsdrv = fsdev->driver;