summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2025-03-17 04:12:46 +0100
committerTom Rini <[email protected]>2025-04-02 20:00:59 -0600
commitb86a651b646c0c676ab2746344edb2d7e5d81e98 (patch)
treec7c46389cf0b51f86c2945440021a8a0a5c1491a /include
parent88c1acd3579aa2ccc7d5c2cdd5f9a48e74ec7e8e (diff)
fs: exfat: Add U-Boot porting layer
Add U-Boot adjustments to the libexfat code and integrate the result into U-Boot filesystem layer. This provides full read-write exfat support for U-Boot available via generic filesystem interface. FS_DIRENT_NAME_LEN is increased to 1024 in case exfat is enabled, because EXFAT can use UTF16 names, which do not fit into current FS_DIRENT_NAME_LEN. To avoid affecting every configuration, increase FS_DIRENT_NAME_LEN only in case EXFAT is enabled. Example usage via sandbox, assuming disk.img with one exfat partition: Drive info: $ ./u-boot -Tc 'host bind 0 ../disk.img ; host info 0' dev blocks blksz label path 0 262144 512 0 ../disk.img List files: $ ./u-boot -Tc 'host bind 0 ../disk.img ; ls host 0:1 /api' 475 Kconfig 230 Makefile 1873 README ... 10 file(s), 0 dir(s) Load and checksum a file: $ ./u-boot -Tc 'host bind 0 ../disk.img ; load host 0:1 $loadaddr .config ; \ crc32 $loadaddr $filesize' 56724 bytes read in 1 ms (54.1 MiB/s) crc32 for 00000000 ... 0000dd93 ==> b2e847c9 $ crc32 .config b2e847c9 Load .config file to RAM, store the file into FS as /newconfig, load the /newconfig into RAM and checksum the file: $ ./u-boot -Tc 'host bind 0 ../disk.img ; load host 0:1 $loadaddr .config ; \ save host 0:1 $loadaddr /newconfig $filesize ; \ load host 0:1 0x10000 /newconfig ; \ crc32 0x10000 $filesize' 56724 bytes read in 1 ms (54.1 MiB/s) 56724 bytes written in 0 ms 56724 bytes read in 0 ms crc32 for 00010000 ... 0001dd93 ==> b2e847c9 Remove file 3.txt and create new directory /newdir: $ ./u-boot -Tc 'host bind 0 ../disk.img ; ls host 0:1 / ; \ rm host 0:1 3.txt ; mkdir host 0:1 /newdir ; \ ls host 0:1 /' ... 0 1.txt 0 2.txt 0 3.txt 0 4.txt 0 5.txt 7 file(s), 4 dir(s) ... 0 1.txt 0 2.txt newdir/ 0 4.txt 0 5.txt 6 file(s), 5 dir(s) Acked-by: Tom Rini <[email protected]> Signed-off-by: Marek Vasut <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/exfat.h24
-rw-r--r--include/fs.h3
2 files changed, 26 insertions, 1 deletions
diff --git a/include/exfat.h b/include/exfat.h
new file mode 100644
index 00000000000..7e43beeb348
--- /dev/null
+++ b/include/exfat.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _EXFAT_H_
+#define _EXFAT_H_
+
+struct disk_partition;
+
+int exfat_fs_opendir(const char *filename, struct fs_dir_stream **dirsp);
+int exfat_fs_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
+int exfat_fs_ls(const char *dirname);
+int exfat_fs_probe(struct blk_desc *fs_dev_desc,
+ struct disk_partition *fs_partition);
+int exfat_fs_read(const char *filename, void *buf, loff_t offset,
+ loff_t len, loff_t *actread);
+int exfat_fs_size(const char *filename, loff_t *size);
+int exfat_fs_exists(const char *filename);
+void exfat_fs_close(void);
+void exfat_fs_closedir(struct fs_dir_stream *dirs);
+
+int exfat_fs_unlink(const char *filename);
+int exfat_fs_mkdir(const char *dirname);
+int exfat_fs_write(const char *filename, void *buf, loff_t offset,
+ loff_t len, loff_t *actwrite);
+
+#endif /* _EXFAT_H */
diff --git a/include/fs.h b/include/fs.h
index 54449faf2e5..731aaa02637 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -18,6 +18,7 @@ struct cmd_tbl;
#define FS_TYPE_SQUASHFS 6
#define FS_TYPE_EROFS 7
#define FS_TYPE_SEMIHOSTING 8
+#define FS_TYPE_EXFAT 9
struct blk_desc;
@@ -173,7 +174,7 @@ int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len,
#define FS_DT_REG 8 /* regular file */
#define FS_DT_LNK 10 /* symbolic link */
-#define FS_DIRENT_NAME_LEN 256
+#define FS_DIRENT_NAME_LEN CONFIG_IS_ENABLED(FS_EXFAT, (1024), (256))
/**
* struct fs_dirent - directory entry