From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Dennis Menschel <menschel-d@posteo.de>
Subject: [PATCH 2/2] fs: Don't bother filesystems without link support with additional stat() calls
Date: Tue, 5 Sep 2017 10:00:21 +0200 [thread overview]
Message-ID: <20170905080021.22248-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170905080021.22248-1-s.hauer@pengutronix.de>
In __canonicalize_path() we only call stat() to know if the path
is a link or not. When the filesystem doesn't support links we
already know that it's not a link, so we do not need to call stat().
This helps the tftp filesystem since the parent directories of
a file to be opened won't be stat()ed anymore, something tftp
does not support.
Fixes: a602bebc fs: Implement links to directories
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/fs.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/fs.c b/fs/fs.c
index a5efdd1423..f61ee091b5 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -145,6 +145,7 @@ char *normalise_path(const char *pathname)
EXPORT_SYMBOL(normalise_path);
static int __lstat(const char *filename, struct stat *s);
+static struct fs_device_d *get_fsdevice_by_path(const char *path);
static char *__canonicalize_path(const char *_pathname, int level)
{
@@ -167,6 +168,7 @@ static char *__canonicalize_path(const char *_pathname, int level)
char *p = strsep(&path, "/");
char *tmp;
char link[PATH_MAX] = {};
+ struct fs_device_d *fsdev;
if (!p)
break;
@@ -185,6 +187,14 @@ static char *__canonicalize_path(const char *_pathname, int level)
free(outpath);
outpath = tmp;
+ /*
+ * Don't bother filesystems without link support
+ * with an additional stat() call.
+ */
+ fsdev = get_fsdevice_by_path(outpath);
+ if (!fsdev->driver->readlink)
+ continue;
+
ret = __lstat(outpath, &s);
if (ret)
goto out;
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2017-09-05 8:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 8:00 Fix tftpd-hpa support Sascha Hauer
2017-09-05 8:00 ` [PATCH 1/2] fs: avoid pathes with '//' in __canonicalize_path() Sascha Hauer
2017-09-05 8:00 ` 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=20170905080021.22248-3-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=menschel-d@posteo.de \
/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