summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-09-05 09:44:18 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-09-06 13:55:16 +0200
commitd79a81736f64eef5d19396ad04ee9391bc384a8e (patch)
tree55a6a2de53274e6885bc2cf544064bd1311a7e11 /fs
parenteed363f4479795a0d005dfd40d11a1936e62ab40 (diff)
downloadbarebox-d79a81736f64eef5d19396ad04ee9391bc384a8e.tar.gz
barebox-d79a81736f64eef5d19396ad04ee9391bc384a8e.tar.xz
fs: Don't bother filesystems without link support with additional stat() calls
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c10
1 files changed, 10 insertions, 0 deletions
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;