From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 3/4] fs: Implement links to directories
Date: Thu, 11 May 2017 21:34:36 +0200 [thread overview]
Message-ID: <20170511193436.kjigsnnk23d5ppzy@pengutronix.de> (raw)
In-Reply-To: <20170511091101.5821-4-s.hauer@pengutronix.de>
On Thu, May 11, 2017 at 11:11:00AM +0200, Sascha Hauer wrote:
> So far links can only point to files. Implement links to
> directories. With this all kinds of links are supported:
>
> - relative links
> - absolute links
> - links including ".."
> - link loops (are detected, return -EMLINK)
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> commands/readlink.c | 2 +-
> fs/fs.c | 272 +++++++++++++++++++++++++++++-----------------------
> include/fs.h | 3 +-
> 3 files changed, 157 insertions(+), 120 deletions(-)
>
> diff --git a/commands/readlink.c b/commands/readlink.c
> index 4ac576f16f..a19c8e0041 100644
> --- a/commands/readlink.c
> +++ b/commands/readlink.c
[...]
> int stat(const char *filename, struct stat *s)
> {
> - char *f;
> + char *path = canonicalize_path(filename);
> + int ret;
>
> - f = realfile(filename, s);
> - if (IS_ERR(f))
> - return PTR_ERR(f);
> + if (IS_ERR(path))
> + return PTR_ERR(path);
>
> - free(f);
> - return 0;
> + ret = lstat(path, s);
> +
> + free(path);
> +
> + return ret;
> }
The following is missing in this patch, it slipped into a debug
patch I removed from this series:
int lstat(const char *filename, struct stat *s)
{
char *f = canonicalize_dir(filename);
int ret;
if (IS_ERR(f))
return PTR_ERR(f);
ret = __lstat(f, s);
free(f);
return ret;
}
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
next prev parent reply other threads:[~2017-05-11 19:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-11 9:10 Implement symlinks " Sascha Hauer
2017-05-11 9:10 ` [PATCH 1/4] errno: Include string for ELOOP Sascha Hauer
2017-05-11 9:10 ` [PATCH 2/4] fs: drop path_check_prereq() Sascha Hauer
2017-05-11 9:11 ` [PATCH 3/4] fs: Implement links to directories Sascha Hauer
2017-05-11 19:34 ` Sascha Hauer [this message]
2017-05-11 9:11 ` [PATCH 4/4] ls: Fix showing " Sascha Hauer
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=20170511193436.kjigsnnk23d5ppzy@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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