diff options
author | Corentin Chary <corentincj@iksaif.net> | 2009-09-28 21:10:11 +0200 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-11-24 08:18:54 +0200 |
commit | b57102841846d9840dcb1b8b308f6d7369b8e5c5 (patch) | |
tree | 5792c36c373eef0be91714e5a7a3b83d8cf62960 /drivers/mtd/ubi/kapi.c | |
parent | 648f4e3e50c4793d9dbf9a09afa193631f76fa26 (diff) | |
download | blackbird-op-linux-b57102841846d9840dcb1b8b308f6d7369b8e5c5.tar.gz blackbird-op-linux-b57102841846d9840dcb1b8b308f6d7369b8e5c5.zip |
UBI: Add ubi_open_volume_path
Add an 'ubi_open_volume_path(path, mode)' function which works like
'open_bdev_exclusive(path, mode, ...)' where path is the special file
representing the UBI volume, typically /dev/ubi0_0.
This is needed to teach UBIFS being able to mount UBI character devices.
[Comments and the patch were amended a bit by Artem]
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/kapi.c')
-rw-r--r-- | drivers/mtd/ubi/kapi.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index 88a72e9c8beb..277786ebaa2c 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c @@ -22,6 +22,8 @@ #include <linux/module.h> #include <linux/err.h> +#include <linux/namei.h> +#include <linux/fs.h> #include <asm/div64.h> #include "ubi.h" @@ -280,6 +282,44 @@ struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name, EXPORT_SYMBOL_GPL(ubi_open_volume_nm); /** + * ubi_open_volume_path - open UBI volume by its character device node path. + * @pathname: volume character device node path + * @mode: open mode + * + * This function is similar to 'ubi_open_volume()', but opens a volume the path + * to its character device node. + */ +struct ubi_volume_desc *ubi_open_volume_path(const char *pathname, int mode) +{ + int error, ubi_num, vol_id; + struct ubi_volume_desc *ret; + struct inode *inode; + struct path path; + + dbg_gen("open volume %s, mode %d", pathname, mode); + + if (!pathname || !*pathname) + return ERR_PTR(-EINVAL); + + error = kern_path(pathname, LOOKUP_FOLLOW, &path); + if (error) + return ERR_PTR(error); + + inode = path.dentry->d_inode; + ubi_num = ubi_major2num(imajor(inode)); + vol_id = iminor(inode) - 1; + + if (vol_id >= 0 && ubi_num >= 0) + ret = ubi_open_volume(ubi_num, vol_id, mode); + else + ret = ERR_PTR(-ENODEV); + + path_put(&path); + return ret; +} +EXPORT_SYMBOL_GPL(ubi_open_volume_path); + +/** * ubi_close_volume - close UBI volume. * @desc: volume descriptor */ |