[PATCH 1/3] devfs: add symlink support
Sascha Hauer
s.hauer at pengutronix.de
Mon Oct 21 04:42:30 EDT 2013
On Fri, Oct 18, 2013 at 06:33:10PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> this will allow have symlink for any device such as named partition
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
> fs/devfs-core.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
> fs/devfs.c | 42 ++++++++++++++++++++++++++++++++++++++++--
> include/driver.h | 4 ++++
> 3 files changed, 88 insertions(+), 3 deletions(-)
>
> diff --git a/fs/devfs-core.c b/fs/devfs-core.c
> index a92d434..0e1ac9a 100644
> --- a/fs/devfs-core.c
> +++ b/fs/devfs-core.c
> @@ -45,13 +45,56 @@ int devfs_partition_complete(struct string_list *sl, char *instr)
> }
> #endif
>
> +struct cdev *devfs_add_symlink_index(const char *filename, struct cdev *src)
> +{
> + struct cdev *cdev;
> + int ret;
> +
> + if (!filename || !src)
> + return ERR_PTR(-EIO);
> +
> + ret = cdev_find_free_index(filename);
> + if (ret == -1)
> + return ERR_PTR(-ENOMEM);
> +
> + cdev = xzalloc(sizeof(*cdev));
> + cdev->name = asprintf("%s%d", filename, ret);
> + cdev->symlink = src;
> + ret = devfs_create(cdev);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + return cdev;
> +}
> +
> +struct cdev *devfs_add_symlink(const char *filename, struct cdev *src)
> +{
> + struct cdev *cdev;
> + int ret;
> +
> + if (!filename || !src)
> + return ERR_PTR(-EIO);
> +
> + cdev = xzalloc(sizeof(*cdev));
> + cdev->name = xstrdup(filename);
> + cdev->symlink = src;
This is not nice.
- You only allow a single symlink
- No check whether this symlink already exists
- calling devfs_remove leaves dangling symlinks behind
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list