From ecb3aaa23b09c41f2ac8364f5ca72779467762e3 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 27 Sep 2013 22:47:10 +0200 Subject: fs: cleanup backingstore handling All filesystem drivers which need a backingstore device do the same ignoring of '/dev/' in the backingstore followed by a cdev_open. Add a helper function for it and let the core handle the cdev. As a side effect this makes sure that fsdev->cdev is also set when a device is mounted without the leading '/dev/' which was previously ignored by the mount code. Signed-off-by: Sascha Hauer --- fs/ubifs/ubifs.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'fs/ubifs/ubifs.c') diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index 9df8dc5cbd..dfa6107458 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -553,25 +553,22 @@ static int ubifs_probe(struct device_d *dev) { struct fs_device_d *fsdev = dev_to_fs_device(dev); struct ubifs_priv *priv = xzalloc(sizeof(struct ubifs_priv)); - char *backingstore = fsdev->backingstore; int ret; dev->priv = priv; - if (!strncmp(backingstore , "/dev/", 5)) - backingstore += 5; - - priv->cdev = cdev_open(backingstore, O_RDONLY); - if (!priv->cdev) { - ret = -ENOENT; + ret = fsdev_open_cdev(fsdev); + if (ret) goto err_free; - } + + priv->cdev = fsdev->cdev; priv->ubi = ubi_open_volume_cdev(priv->cdev, UBI_READONLY); if (IS_ERR(priv->ubi)) { dev_err(dev, "failed to open ubi volume: %s\n", strerror(-PTR_ERR(priv->ubi))); - return PTR_ERR(priv->ubi); + ret = PTR_ERR(priv->ubi); + goto err_free; } priv->sb = ubifs_get_super(priv->ubi, 0); @@ -596,7 +593,6 @@ static void ubifs_remove(struct device_d *dev) ubifs_umount(c); ubi_close_volume(priv->ubi); - cdev_close(priv->cdev); free(c); free(sb); -- cgit v1.2.3