[PATCH 2/2] fs: Don't bother filesystems without link support with additional stat() calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux