
From: Simon Glass <sjg@chromium.org> Some parts of fs_legacy.h are useful for the new fs subsystem. Add a common header and move the filesystem types and some definition into it. Use an enum for the filesystem type, to permit type checking. Signed-off-by: Simon Glass <sjg@chromium.org> --- include/fs_common.h | 72 +++++++++++++++++++++++++++++++++++++++++++++ include/fs_legacy.h | 61 +------------------------------------- 2 files changed, 73 insertions(+), 60 deletions(-) create mode 100644 include/fs_common.h diff --git a/include/fs_common.h b/include/fs_common.h new file mode 100644 index 00000000000..30e8b6737b3 --- /dev/null +++ b/include/fs_common.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. + */ +#ifndef _FS_COMMON_H +#define _FS_COMMON_H + +#include <rtc.h> + +enum fs_type_t { + FS_TYPE_ANY = 0, + FS_TYPE_FAT, + FS_TYPE_EXT, + FS_TYPE_SANDBOX, + FS_TYPE_UBIFS, + FS_TYPE_BTRFS, + FS_TYPE_SQUASHFS, + FS_TYPE_EROFS, + FS_TYPE_SEMIHOSTING, + FS_TYPE_EXFAT, +}; + +/* + * Directory entry types, matches the subset of DT_x in posix readdir() + * which apply to u-boot. + */ +#define FS_DT_DIR 4 /* directory */ +#define FS_DT_REG 8 /* regular file */ +#define FS_DT_LNK 10 /* symbolic link */ + +#define FS_DIRENT_NAME_LEN CONFIG_IS_ENABLED(FS_EXFAT, (1024), (256)) + +/** + * struct fs_dirent - directory entry + * + * A directory entry, returned by fs_readdir(). Returns information + * about the file/directory at the current directory entry position. + */ +struct fs_dirent { + /** @type: one of FS_DT_x (not a mask) */ + unsigned int type; + /** @size: file size */ + loff_t size; + /** @attr: attribute flags (FS_ATTR_*) */ + u32 attr; + /** @create_time: time of creation */ + struct rtc_time create_time; + /** @access_time: time of last access */ + struct rtc_time access_time; + /** @change_time: time of last modification */ + struct rtc_time change_time; + /** @name: file name */ + char name[FS_DIRENT_NAME_LEN]; +}; + +/** + * struct fs_dir_stream - Structure representing an opened directory + * + * Struct fs_dir_stream should be treated opaque to the user of fs layer. + * The fields @desc and @part are used by the fs layer. + * File system drivers pass additional private fields with the pointers + * to this structure. + * + * @desc: block device descriptor + * @part: partition number + */ +struct fs_dir_stream { + struct blk_desc *desc; + int part; +}; + +#endif diff --git a/include/fs_legacy.h b/include/fs_legacy.h index 5cd9114f33b..1a01fb09aa1 100644 --- a/include/fs_legacy.h +++ b/include/fs_legacy.h @@ -5,22 +5,12 @@ #ifndef _FS_H #define _FS_H +#include <fs_common.h> #include <rtc.h> struct abuf; struct cmd_tbl; -#define FS_TYPE_ANY 0 -#define FS_TYPE_FAT 1 -#define FS_TYPE_EXT 2 -#define FS_TYPE_SANDBOX 3 -#define FS_TYPE_UBIFS 4 -#define FS_TYPE_BTRFS 5 -#define FS_TYPE_SQUASHFS 6 -#define FS_TYPE_EROFS 7 -#define FS_TYPE_SEMIHOSTING 8 -#define FS_TYPE_EXFAT 9 - struct blk_desc; /** @@ -167,55 +157,6 @@ int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len, int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len, loff_t *actwrite); -/* - * Directory entry types, matches the subset of DT_x in posix readdir() - * which apply to u-boot. - */ -#define FS_DT_DIR 4 /* directory */ -#define FS_DT_REG 8 /* regular file */ -#define FS_DT_LNK 10 /* symbolic link */ - -#define FS_DIRENT_NAME_LEN CONFIG_IS_ENABLED(FS_EXFAT, (1024), (256)) - -/** - * struct fs_dirent - directory entry - * - * A directory entry, returned by fs_readdir(). Returns information - * about the file/directory at the current directory entry position. - */ -struct fs_dirent { - /** @type: one of FS_DT_x (not a mask) */ - unsigned int type; - /** @size: file size */ - loff_t size; - /** @attr: attribute flags (FS_ATTR_*) */ - u32 attr; - /** @create_time: time of creation */ - struct rtc_time create_time; - /** @access_time: time of last access */ - struct rtc_time access_time; - /** @change_time: time of last modification */ - struct rtc_time change_time; - /** @name: file name */ - char name[FS_DIRENT_NAME_LEN]; -}; - -/** - * struct fs_dir_stream - Structure representing an opened directory - * - * Struct fs_dir_stream should be treated opaque to the user of fs layer. - * The fields @desc and @part are used by the fs layer. - * File system drivers pass additional private fields with the pointers - * to this structure. - * - * @desc: block device descriptor - * @part: partition number - */ -struct fs_dir_stream { - struct blk_desc *desc; - int part; -}; - /** * fs_opendir - Open a directory * -- 2.43.0