From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] commands: stat: print symlink destination when called without -L
Date: Thu, 1 Jun 2023 09:06:00 +0200 [thread overview]
Message-ID: <20230601070600.GE18491@pengutronix.de> (raw)
In-Reply-To: <20230531132331.2152268-1-a.fatoum@pengutronix.de>
On Wed, May 31, 2023 at 03:23:30PM +0200, Ahmad Fatoum wrote:
> This aligns behavior with usual implementations of stat.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> fs/fs.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/fs/fs.c b/fs/fs.c
> index 368458cc54f8..311571ba3088 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -130,8 +130,6 @@ void stat_print(const char *filename, const struct stat *st)
> case S_IFREG: type = "regular file"; break;
> }
>
> - printf(" File: %s\n", filename);
> -
> if (st->st_mode & S_IFCHR) {
> char *path;
>
> @@ -147,6 +145,21 @@ void stat_print(const char *filename, const struct stat *st)
> }
> }
>
> + printf(" File: %s", filename);
> +
> + if (S_ISLNK(st->st_mode)) {
> + char realname[PATH_MAX] = {};
> + int ret;
> +
> + ret = readlink(filename, realname, PATH_MAX - 1);
> + if (ret)
> + printf(" -> <readlink error %pe>", ERR_PTR(ret));
> + else
> + printf(" -> %s", realname);
> + }
> +
> + printf("\n");
> +
> printf(" Size: %-20llu", st->st_size);
> if (bdev)
> printf("Blocks: %llu\tIO Block: %u\t",
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2023-06-01 7:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 13:23 Ahmad Fatoum
2023-05-31 13:23 ` [PATCH 2/2] commands: stat: add basic handling for cdev links Ahmad Fatoum
2023-06-01 7:06 ` 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=20230601070600.GE18491@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@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