summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-01-22 10:14:39 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-01-25 08:28:02 +0100
commit3f86edfc2b942e57d452feca0450a6fb14066fbd (patch)
tree7482d58d16663d64f333d0816c2612f0eb37ba64 /fs
parent573d6ae5bb909e1c887be558953d1fb2a0f7335a (diff)
downloadbarebox-3f86edfc2b942e57d452feca0450a6fb14066fbd.tar.gz
barebox-3f86edfc2b942e57d452feca0450a6fb14066fbd.tar.xz
fs: implement is_tftp_fs()
Some commands need files in which they can lseek backwards which is particularly not possible on TFTP. Instead of hiding this behind can_lseek_backward() create a function for it which tests if the file is on TFTP directly rather than using different lseek operations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/fs.c b/fs/fs.c
index 6f15e93ba9..e073e3577d 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1906,3 +1906,25 @@ char *path_get_linux_rootarg(const char *path)
return xstrdup(str);
}
+
+/**
+ * __is_tftp_fs() - return true when path is mounted on TFTP
+ * @path: The path
+ *
+ * Do not use directly, use is_tftp_fs instead.
+ *
+ * Return: true when @path is on TFTP, false otherwise
+ */
+bool __is_tftp_fs(const char *path)
+{
+ struct fs_device_d *fsdev;
+
+ fsdev = get_fsdevice_by_path(path);
+ if (!fsdev)
+ return false;
+
+ if (strcmp(fsdev->driver->drv.name, "tftp"))
+ return false;
+
+ return true;
+}