From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/7] fs: implement is_tftp_fs()
Date: Wed, 24 Jan 2018 08:45:29 +0100 [thread overview]
Message-ID: <20180124074534.7966-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20180124074534.7966-1-s.hauer@pengutronix.de>
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>
---
fs/fs.c | 22 ++++++++++++++++++++++
include/fs.h | 10 ++++++++++
2 files changed, 32 insertions(+)
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;
+}
diff --git a/include/fs.h b/include/fs.h
index 3d88bfad4a..5a50d9b9e4 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -121,6 +121,16 @@ static inline int can_lseek_backward(int fd)
return 1;
}
+bool __is_tftp_fs(const char *path);
+
+static inline bool is_tftp_fs(const char *path)
+{
+ if (!IS_ENABLED(CONFIG_FS_TFTP))
+ return 0;
+
+ return __is_tftp_fs(path);
+}
+
#define drv_to_fs_driver(d) container_of(d, struct fs_driver_d, drv)
int flush(int fd);
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-01-24 7:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-24 7:45 [PATCH 0/7] Make TFTP detection more convenient Sascha Hauer
2018-01-24 7:45 ` [PATCH 1/7] startup: create /tmp Sascha Hauer
2018-01-24 7:45 ` Sascha Hauer [this message]
2018-01-24 19:12 ` [PATCH 2/7] fs: implement is_tftp_fs() Stefan Lengfeld
2018-01-25 7:46 ` Sascha Hauer
2018-01-24 7:45 ` [PATCH 3/7] libfile: implement make_temp Sascha Hauer
2018-01-24 7:45 ` [PATCH 4/7] libfile: implement a function to cache a file Sascha Hauer
2018-01-24 19:23 ` Stefan Lengfeld
2018-01-24 7:45 ` [PATCH 5/7] uimage: Use is_tftp_fs() and cache_file() to ease TFTP workaround Sascha Hauer
2018-01-24 19:39 ` Stefan Lengfeld
2018-01-24 7:45 ` [PATCH 6/7] fs/uimagefs: " Sascha Hauer
2018-01-24 19:56 ` Stefan Lengfeld
2018-01-24 7:45 ` [PATCH 7/7] fs: remove now unused function can_lseek_backward() Sascha Hauer
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=20180124074534.7966-3-s.hauer@pengutronix.de \
--to=s.hauer@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