mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] devfs: add symlink support
Date: Mon, 21 Oct 2013 10:42:30 +0200	[thread overview]
Message-ID: <20131021084229.GC30088@pengutronix.de> (raw)
In-Reply-To: <1382113992-9082-1-git-send-email-plagnioj@jcrosoft.com>

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@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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2013-10-21  8:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18 16:31 [PATCH 0/3] " Jean-Christophe PLAGNIOL-VILLARD
2013-10-18 16:33 ` [PATCH 1/3] " Jean-Christophe PLAGNIOL-VILLARD
2013-10-18 16:33   ` [PATCH 2/3] partition: use symlink for named partition Jean-Christophe PLAGNIOL-VILLARD
2013-10-18 16:33   ` [PATCH 3/3] USB: storage: register disks as usbdiskx symlink Jean-Christophe PLAGNIOL-VILLARD
2013-10-21  8:42   ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131021084229.GC30088@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox