diff mbox series

[v5,11/34] fs: Add a function to set the filesystem type

Message ID 20220425053127.19950-11-sjg@chromium.org
State Accepted
Commit c24e58f599085efa79a61cb62170b6b2164b8ce9
Delegated to: Tom Rini
Headers show
Series Initial implementation of standard boot | expand

Commit Message

Simon Glass April 25, 2022, 5:31 a.m. UTC
When sandbox is used with hostfs we won't have a block device, but still
must set up the filesystem type before any filesystem operation, such as
loading a file. Add a function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v4)

Changes in v4:
- Add new patch with a function to set the filesystem type

 fs/fs.c      |  5 +++++
 include/fs.h | 11 +++++++++++
 2 files changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/fs/fs.c b/fs/fs.c
index b812597ced9..6de1a3eb6d5 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -36,6 +36,11 @@  static int fs_dev_part;
 static struct disk_partition fs_partition;
 static int fs_type = FS_TYPE_ANY;
 
+void fs_set_type(int type)
+{
+	fs_type = type;
+}
+
 static inline int fs_probe_unsupported(struct blk_desc *fs_dev_desc,
 				      struct disk_partition *fs_partition)
 {
diff --git a/include/fs.h b/include/fs.h
index e2beba36b98..b43f16a692f 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -57,6 +57,17 @@  int do_ext2load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
  */
 int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype);
 
+/**
+ * fs_set_type() - Tell fs layer which filesystem type is used
+ *
+ * This is needed when reading from a non-block device such as sandbox. It does
+ * a similar job to fs_set_blk_dev() but just sets the filesystem type instead
+ * of detecting it and loading it on the block device
+ *
+ * @type: Filesystem type to use (FS_TYPE...)
+ */
+void fs_set_type(int type);
+
 /*
  * fs_set_blk_dev_with_part - Set current block device + partition
  *