[PATCH 03/18] fs: add symlink support

Sascha Hauer s.hauer at pengutronix.de
Mon Sep 3 04:17:44 EDT 2012


On Sat, Sep 01, 2012 at 02:37:18PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Limit it's support to existing file only
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  fs/fs.c      |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  include/fs.h |    3 +++
>  2 files changed, 47 insertions(+)
> 
> diff --git a/fs/fs.c b/fs/fs.c
> index f357a98..291e879 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -948,6 +948,50 @@ out:
>  }
>  EXPORT_SYMBOL(readlink);
>  
> +int symlink(const char *pathname, const char *newpath)
> +{
> +	struct fs_driver_d *fsdrv;
> +	struct fs_device_d *fsdev;
> +	char *p = normalise_path(pathname);
> +	int ret;
> +	struct stat s;
> +
> +	if (!stat(p, &s) && S_ISDIR(s.st_mode)) {
> +		ret = -ENOSYS;
> +		goto out;
> +	}

newpath has to be checked for existence, not pathname.

Also I noticed that links to directories do not work.

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