Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 4 | */ |
| 5 | #ifndef _FS_H |
| 6 | #define _FS_H |
| 7 | |
Heinrich Schuchardt | 236a2d1 | 2021-05-15 22:06:16 +0200 | [diff] [blame] | 8 | #include <rtc.h> |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 9 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 10 | struct cmd_tbl; |
| 11 | |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 12 | #define FS_TYPE_ANY 0 |
| 13 | #define FS_TYPE_FAT 1 |
| 14 | #define FS_TYPE_EXT 2 |
Simon Glass | 1184287 | 2012-12-26 09:53:35 +0000 | [diff] [blame] | 15 | #define FS_TYPE_SANDBOX 3 |
Hans de Goede | 690c796 | 2015-09-17 18:46:58 -0400 | [diff] [blame] | 16 | #define FS_TYPE_UBIFS 4 |
Marek BehĂșn | 98ec1d1 | 2017-09-03 17:00:29 +0200 | [diff] [blame] | 17 | #define FS_TYPE_BTRFS 5 |
Joao Marcos Costa | 29da374 | 2020-07-30 15:33:47 +0200 | [diff] [blame] | 18 | #define FS_TYPE_SQUASHFS 6 |
Huang Jianan | 024fb2f | 2022-02-26 15:05:47 +0800 | [diff] [blame] | 19 | #define FS_TYPE_EROFS 7 |
Sean Anderson | c678b32 | 2022-03-22 16:59:20 -0400 | [diff] [blame] | 20 | #define FS_TYPE_SEMIHOSTING 8 |
Marek Vasut | 894cf72 | 2025-03-17 04:12:46 +0100 | [diff] [blame] | 21 | #define FS_TYPE_EXFAT 9 |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 22 | |
Simon Glass | 655306c | 2020-05-10 11:39:58 -0600 | [diff] [blame] | 23 | struct blk_desc; |
| 24 | |
Simon Glass | 1b3f75f | 2019-12-28 10:44:44 -0700 | [diff] [blame] | 25 | /** |
| 26 | * do_fat_fsload - Run the fatload command |
| 27 | * |
| 28 | * @cmdtp: Command information for fatload |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 29 | * @flag: Command flags (CMD_FLAG\_...) |
Simon Glass | 1b3f75f | 2019-12-28 10:44:44 -0700 | [diff] [blame] | 30 | * @argc: Number of arguments |
| 31 | * @argv: List of arguments |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 32 | * Return: result (see enum command_ret_t) |
Simon Glass | 1b3f75f | 2019-12-28 10:44:44 -0700 | [diff] [blame] | 33 | */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 34 | int do_fat_fsload(struct cmd_tbl *cmdtp, int flag, int argc, |
| 35 | char *const argv[]); |
Simon Glass | 1b3f75f | 2019-12-28 10:44:44 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * do_ext2load - Run the ext2load command |
| 39 | * |
| 40 | * @cmdtp: Command information for ext2load |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 41 | * @flag: Command flags (CMD_FLAG\_...) |
Simon Glass | 1b3f75f | 2019-12-28 10:44:44 -0700 | [diff] [blame] | 42 | * @argc: Number of arguments |
| 43 | * @argv: List of arguments |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 44 | * Return: result (see enum command_ret_t) |
Simon Glass | 1b3f75f | 2019-12-28 10:44:44 -0700 | [diff] [blame] | 45 | */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 46 | int do_ext2load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); |
Simon Glass | 1b3f75f | 2019-12-28 10:44:44 -0700 | [diff] [blame] | 47 | |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 48 | /* |
Roger Knecht | 224d3c3 | 2022-08-25 12:12:01 +0000 | [diff] [blame] | 49 | * Tell the fs layer which block device and partition to use for future |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 50 | * commands. This also internally identifies the filesystem that is present |
| 51 | * within the partition. The identification process may be limited to a |
| 52 | * specific filesystem type by passing FS_* in the fstype parameter. |
| 53 | * |
| 54 | * Returns 0 on success. |
| 55 | * Returns non-zero if there is an error accessing the disk or partition, or |
| 56 | * no known filesystem type could be recognized on it. |
| 57 | */ |
| 58 | int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype); |
| 59 | |
Simon Glass | 896ed4b | 2022-04-24 23:31:04 -0600 | [diff] [blame] | 60 | /** |
| 61 | * fs_set_type() - Tell fs layer which filesystem type is used |
| 62 | * |
| 63 | * This is needed when reading from a non-block device such as sandbox. It does |
| 64 | * a similar job to fs_set_blk_dev() but just sets the filesystem type instead |
| 65 | * of detecting it and loading it on the block device |
| 66 | * |
| 67 | * @type: Filesystem type to use (FS_TYPE...) |
| 68 | */ |
| 69 | void fs_set_type(int type); |
| 70 | |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 71 | /* |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 72 | * fs_set_blk_dev_with_part - Set current block device + partition |
| 73 | * |
| 74 | * Similar to fs_set_blk_dev(), but useful for cases where you already |
| 75 | * know the blk_desc and part number. |
| 76 | * |
| 77 | * Returns 0 on success. |
| 78 | * Returns non-zero if invalid partition or error accessing the disk. |
| 79 | */ |
| 80 | int fs_set_blk_dev_with_part(struct blk_desc *desc, int part); |
| 81 | |
Alex Kiernan | 3a6163a | 2018-05-29 15:30:50 +0000 | [diff] [blame] | 82 | /** |
AKASHI Takahiro | ca8e377 | 2019-10-07 14:59:35 +0900 | [diff] [blame] | 83 | * fs_close() - Unset current block device and partition |
| 84 | * |
Heinrich Schuchardt | 63a5752 | 2019-10-13 10:26:26 +0200 | [diff] [blame] | 85 | * fs_close() closes the connection to a file system opened with either |
| 86 | * fs_set_blk_dev() or fs_set_dev_with_part(). |
| 87 | * |
| 88 | * Many file functions implicitly call fs_close(), e.g. fs_closedir(), |
| 89 | * fs_exist(), fs_ln(), fs_ls(), fs_mkdir(), fs_read(), fs_size(), fs_write(), |
Gabriel Dalimonte | a205e8e | 2025-02-17 13:26:43 -0500 | [diff] [blame] | 90 | * fs_unlink(), fs_rename(). |
AKASHI Takahiro | ca8e377 | 2019-10-07 14:59:35 +0900 | [diff] [blame] | 91 | */ |
| 92 | void fs_close(void); |
| 93 | |
| 94 | /** |
AKASHI Takahiro | 80ac734 | 2019-10-07 14:59:37 +0900 | [diff] [blame] | 95 | * fs_get_type() - Get type of current filesystem |
| 96 | * |
| 97 | * Return: filesystem type |
| 98 | * |
| 99 | * Returns filesystem type representing the current filesystem, or |
| 100 | * FS_TYPE_ANY for any unrecognised filesystem. |
| 101 | */ |
| 102 | int fs_get_type(void); |
| 103 | |
| 104 | /** |
Alex Kiernan | 3a6163a | 2018-05-29 15:30:50 +0000 | [diff] [blame] | 105 | * fs_get_type_name() - Get type of current filesystem |
| 106 | * |
| 107 | * Return: Pointer to filesystem name |
| 108 | * |
| 109 | * Returns a string describing the current filesystem, or the sentinel |
| 110 | * "unsupported" for any unrecognised filesystem. |
| 111 | */ |
| 112 | const char *fs_get_type_name(void); |
| 113 | |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 114 | /* |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 115 | * Print the list of files on the partition previously set by fs_set_blk_dev(), |
| 116 | * in directory "dirname". |
| 117 | * |
| 118 | * Returns 0 on success. Returns non-zero on error. |
| 119 | */ |
| 120 | int fs_ls(const char *dirname); |
| 121 | |
| 122 | /* |
Stephen Warren | d008fbb | 2014-02-03 13:21:00 -0700 | [diff] [blame] | 123 | * Determine whether a file exists |
| 124 | * |
| 125 | * Returns 1 if the file exists, 0 if it doesn't exist. |
| 126 | */ |
| 127 | int fs_exists(const char *filename); |
| 128 | |
| 129 | /* |
Suriyan Ramasami | 96171fb | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 130 | * fs_size - Determine a file's size |
Stephen Warren | 3eb58f5 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 131 | * |
Suriyan Ramasami | 96171fb | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 132 | * @filename: Name of the file |
| 133 | * @size: Size of file |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 134 | * Return: 0 if ok with valid *size, negative on error |
Stephen Warren | 3eb58f5 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 135 | */ |
Suriyan Ramasami | 96171fb | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 136 | int fs_size(const char *filename, loff_t *size); |
Stephen Warren | 3eb58f5 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 137 | |
Heinrich Schuchardt | 5f1d695 | 2019-04-25 20:36:39 +0200 | [diff] [blame] | 138 | /** |
| 139 | * fs_read() - read file from the partition previously set by fs_set_blk_dev() |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 140 | * |
Heinrich Schuchardt | 5f1d695 | 2019-04-25 20:36:39 +0200 | [diff] [blame] | 141 | * Note that not all filesystem drivers support either or both of offset != 0 |
| 142 | * and len != 0. |
| 143 | * |
| 144 | * @filename: full path of the file to read from |
| 145 | * @addr: address of the buffer to write to |
| 146 | * @offset: offset in the file from where to start reading |
| 147 | * @len: the number of bytes to read. Use 0 to read entire file. |
| 148 | * @actread: returns the actual number of bytes read |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 149 | * Return: 0 if OK with valid @actread, -1 on error conditions |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 150 | */ |
Suriyan Ramasami | 96171fb | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 151 | int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len, |
| 152 | loff_t *actread); |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 153 | |
Heinrich Schuchardt | 5f1d695 | 2019-04-25 20:36:39 +0200 | [diff] [blame] | 154 | /** |
| 155 | * fs_write() - write file to the partition previously set by fs_set_blk_dev() |
| 156 | * |
| 157 | * Note that not all filesystem drivers support offset != 0. |
Stephen Warren | 9df2580 | 2014-02-03 13:20:59 -0700 | [diff] [blame] | 158 | * |
Heinrich Schuchardt | 5f1d695 | 2019-04-25 20:36:39 +0200 | [diff] [blame] | 159 | * @filename: full path of the file to write to |
| 160 | * @addr: address of the buffer to read from |
| 161 | * @offset: offset in the file from where to start writing |
| 162 | * @len: the number of bytes to write |
| 163 | * @actwrite: returns the actual number of bytes written |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 164 | * Return: 0 if OK with valid @actwrite, -1 on error conditions |
Stephen Warren | 9df2580 | 2014-02-03 13:20:59 -0700 | [diff] [blame] | 165 | */ |
Suriyan Ramasami | 96171fb | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 166 | int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len, |
| 167 | loff_t *actwrite); |
Stephen Warren | 9df2580 | 2014-02-03 13:20:59 -0700 | [diff] [blame] | 168 | |
| 169 | /* |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 170 | * Directory entry types, matches the subset of DT_x in posix readdir() |
| 171 | * which apply to u-boot. |
| 172 | */ |
| 173 | #define FS_DT_DIR 4 /* directory */ |
| 174 | #define FS_DT_REG 8 /* regular file */ |
| 175 | #define FS_DT_LNK 10 /* symbolic link */ |
| 176 | |
Marek Vasut | 894cf72 | 2025-03-17 04:12:46 +0100 | [diff] [blame] | 177 | #define FS_DIRENT_NAME_LEN CONFIG_IS_ENABLED(FS_EXFAT, (1024), (256)) |
Miquel Raynal | a8e95fd | 2022-06-09 16:02:06 +0200 | [diff] [blame] | 178 | |
Heinrich Schuchardt | 236a2d1 | 2021-05-15 22:06:16 +0200 | [diff] [blame] | 179 | /** |
| 180 | * struct fs_dirent - directory entry |
| 181 | * |
| 182 | * A directory entry, returned by fs_readdir(). Returns information |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 183 | * about the file/directory at the current directory entry position. |
| 184 | */ |
| 185 | struct fs_dirent { |
Heinrich Schuchardt | 236a2d1 | 2021-05-15 22:06:16 +0200 | [diff] [blame] | 186 | /** @type: one of FS_DT_x (not a mask) */ |
| 187 | unsigned int type; |
| 188 | /** @size: file size */ |
| 189 | loff_t size; |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 190 | /** @attr: attribute flags (FS_ATTR_*) */ |
Heinrich Schuchardt | 236a2d1 | 2021-05-15 22:06:16 +0200 | [diff] [blame] | 191 | u32 attr; |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 192 | /** @create_time: time of creation */ |
Heinrich Schuchardt | 236a2d1 | 2021-05-15 22:06:16 +0200 | [diff] [blame] | 193 | struct rtc_time create_time; |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 194 | /** @access_time: time of last access */ |
Heinrich Schuchardt | 236a2d1 | 2021-05-15 22:06:16 +0200 | [diff] [blame] | 195 | struct rtc_time access_time; |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 196 | /** @change_time: time of last modification */ |
Heinrich Schuchardt | 236a2d1 | 2021-05-15 22:06:16 +0200 | [diff] [blame] | 197 | struct rtc_time change_time; |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 198 | /** @name: file name */ |
Miquel Raynal | a8e95fd | 2022-06-09 16:02:06 +0200 | [diff] [blame] | 199 | char name[FS_DIRENT_NAME_LEN]; |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 200 | }; |
| 201 | |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 202 | /** |
| 203 | * struct fs_dir_stream - Structure representing an opened directory |
| 204 | * |
| 205 | * Struct fs_dir_stream should be treated opaque to the user of fs layer. |
| 206 | * The fields @desc and @part are used by the fs layer. |
| 207 | * File system drivers pass additional private fields with the pointers |
| 208 | * to this structure. |
| 209 | * |
| 210 | * @desc: block device descriptor |
| 211 | * @part: partition number |
| 212 | */ |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 213 | struct fs_dir_stream { |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 214 | struct blk_desc *desc; |
| 215 | int part; |
| 216 | }; |
| 217 | |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 218 | /** |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 219 | * fs_opendir - Open a directory |
| 220 | * |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 221 | * .. note:: |
| 222 | * The returned struct fs_dir_stream should be treated opaque to the |
| 223 | * user of the fs layer. |
| 224 | * |
| 225 | * @filename: path to the directory to open |
| 226 | * Return: |
| 227 | * A pointer to the directory stream or NULL on error and errno set |
| 228 | * appropriately |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 229 | */ |
| 230 | struct fs_dir_stream *fs_opendir(const char *filename); |
| 231 | |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 232 | /** |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 233 | * fs_readdir - Read the next directory entry in the directory stream. |
| 234 | * |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 235 | * fs_readir works in an analogous way to posix readdir(). |
| 236 | * The previously returned directory entry is no longer valid after calling |
| 237 | * fs_readdir() again. |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 238 | * After fs_closedir() is called, the returned directory entry is no |
| 239 | * longer valid. |
| 240 | * |
| 241 | * @dirs: the directory stream |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 242 | * Return: |
| 243 | * the next directory entry (only valid until next fs_readdir() or |
| 244 | * fs_closedir() call, do not attempt to free()) or NULL if the end of |
| 245 | * the directory is reached. |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 246 | */ |
| 247 | struct fs_dirent *fs_readdir(struct fs_dir_stream *dirs); |
| 248 | |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 249 | /** |
Rob Clark | 2b7bfd9 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 250 | * fs_closedir - close a directory stream |
| 251 | * |
| 252 | * @dirs: the directory stream |
| 253 | */ |
| 254 | void fs_closedir(struct fs_dir_stream *dirs); |
| 255 | |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 256 | /** |
AKASHI Takahiro | 1ba4253 | 2018-09-11 15:59:13 +0900 | [diff] [blame] | 257 | * fs_unlink - delete a file or directory |
| 258 | * |
| 259 | * If a given name is a directory, it will be deleted only if it's empty |
| 260 | * |
| 261 | * @filename: Name of file or directory to delete |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 262 | * Return: 0 on success, -1 on error conditions |
AKASHI Takahiro | 1ba4253 | 2018-09-11 15:59:13 +0900 | [diff] [blame] | 263 | */ |
| 264 | int fs_unlink(const char *filename); |
| 265 | |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 266 | /** |
AKASHI Takahiro | adc8c9f | 2018-09-11 15:59:08 +0900 | [diff] [blame] | 267 | * fs_mkdir - Create a directory |
| 268 | * |
| 269 | * @filename: Name of directory to create |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 270 | * Return: 0 on success, -1 on error conditions |
AKASHI Takahiro | adc8c9f | 2018-09-11 15:59:08 +0900 | [diff] [blame] | 271 | */ |
| 272 | int fs_mkdir(const char *filename); |
| 273 | |
Gabriel Dalimonte | a205e8e | 2025-02-17 13:26:43 -0500 | [diff] [blame] | 274 | /** |
| 275 | * fs_rename - rename/move a file or directory |
| 276 | * |
| 277 | * @old_path: existing path of the file/directory to rename |
| 278 | * @new_path: new path of the file/directory. If this points to an existing |
| 279 | * file or empty directory, the existing file/directory will be unlinked. |
| 280 | * If this points to a non-empty directory, the rename will fail. |
| 281 | * |
| 282 | * Return: 0 on success, -1 on error conditions |
| 283 | */ |
| 284 | int fs_rename(const char *old_path, const char *new_path); |
| 285 | |
AKASHI Takahiro | adc8c9f | 2018-09-11 15:59:08 +0900 | [diff] [blame] | 286 | /* |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 287 | * Common implementation for various filesystem commands, optionally limited |
| 288 | * to a specific filesystem type via the fstype parameter. |
| 289 | */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 290 | int do_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], |
| 291 | int fstype); |
| 292 | int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], |
| 293 | int fstype); |
| 294 | int do_ls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], |
| 295 | int fstype); |
Stephen Warren | d008fbb | 2014-02-03 13:21:00 -0700 | [diff] [blame] | 296 | int file_exists(const char *dev_type, const char *dev_part, const char *file, |
| 297 | int fstype); |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 298 | int do_save(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], |
| 299 | int fstype); |
| 300 | int do_rm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], |
| 301 | int fstype); |
| 302 | int do_mkdir(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], |
| 303 | int fstype); |
| 304 | int do_ln(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], |
Jean-Jacques Hiblot | bc23748 | 2019-02-13 12:15:26 +0100 | [diff] [blame] | 305 | int fstype); |
Gabriel Dalimonte | 4b93d6e | 2025-02-17 13:26:44 -0500 | [diff] [blame] | 306 | int do_mv(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], |
| 307 | int fstype); |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 308 | |
Christian Gmeiner | 9f9eec3 | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 309 | /* |
| 310 | * Determine the UUID of the specified filesystem and print it. Optionally it is |
| 311 | * possible to store the UUID directly in env. |
| 312 | */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 313 | int do_fs_uuid(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], |
| 314 | int fstype); |
Christian Gmeiner | 9f9eec3 | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 315 | |
Sjoerd Simons | 7d9faf6 | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 316 | /* |
| 317 | * Determine the type of the specified filesystem and print it. Optionally it is |
| 318 | * possible to store the type directly in env. |
| 319 | */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 320 | int do_fs_type(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); |
Sjoerd Simons | 7d9faf6 | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 321 | |
Niel Fourie | 9252d70 | 2020-03-24 16:17:04 +0100 | [diff] [blame] | 322 | /** |
| 323 | * do_fs_types - List supported filesystems. |
| 324 | * |
| 325 | * @cmdtp: Command information for fstypes |
Heinrich Schuchardt | 9fe8558 | 2024-10-24 11:15:28 +0200 | [diff] [blame] | 326 | * @flag: Command flags (CMD_FLAG\_...) |
Niel Fourie | 9252d70 | 2020-03-24 16:17:04 +0100 | [diff] [blame] | 327 | * @argc: Number of arguments |
| 328 | * @argv: List of arguments |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 329 | * Return: result (see enum command_ret_t) |
Niel Fourie | 9252d70 | 2020-03-24 16:17:04 +0100 | [diff] [blame] | 330 | */ |
| 331 | int do_fs_types(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); |
| 332 | |
Simon Glass | e6c49fc | 2023-06-01 10:22:38 -0600 | [diff] [blame] | 333 | /** |
| 334 | * fs_read_alloc() - Allocate space for a file and read it |
| 335 | * |
| 336 | * You must call fs_set_blk_dev() or a similar function before calling this, |
| 337 | * since that sets up the block device to use. |
| 338 | * |
| 339 | * The file is terminated with a nul character |
| 340 | * |
| 341 | * @fname: Filename to read |
| 342 | * @size: Size of file to read (must be correct!) |
Nam Cao | 15bbb83 | 2024-11-07 16:01:06 +0100 | [diff] [blame] | 343 | * @align: Alignment to use for memory allocation (0 for default: ARCH_DMA_MINALIGN) |
Simon Glass | e6c49fc | 2023-06-01 10:22:38 -0600 | [diff] [blame] | 344 | * @bufp: On success, returns the allocated buffer with the nul-terminated file |
| 345 | * in it |
| 346 | * Return: 0 if OK, -ENOMEM if out of memory, -EIO if read failed |
| 347 | */ |
| 348 | int fs_read_alloc(const char *fname, ulong size, uint align, void **bufp); |
| 349 | |
| 350 | /** |
| 351 | * fs_load_alloc() - Load a file into allocated space |
| 352 | * |
| 353 | * The file is terminated with a nul character |
| 354 | * |
| 355 | * @ifname: Interface name to read from (e.g. "mmc") |
| 356 | * @dev_part_str: Device and partition string (e.g. "1:2") |
| 357 | * @fname: Filename to read |
| 358 | * @max_size: Maximum allowed size for the file (use 0 for 1GB) |
| 359 | * @align: Alignment to use for memory allocation (0 for default) |
| 360 | * @bufp: On success, returns the allocated buffer with the nul-terminated file |
| 361 | * in it |
| 362 | * @sizep: On success, returns the size of the file |
| 363 | * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if the file does not |
| 364 | * exist, -ENOMEDIUM if the device does not exist, -E2BIG if the file is too |
| 365 | * large (greater than @max_size), -EIO if read failed |
| 366 | */ |
| 367 | int fs_load_alloc(const char *ifname, const char *dev_part_str, |
| 368 | const char *fname, ulong max_size, ulong align, void **bufp, |
| 369 | ulong *sizep); |
| 370 | |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 371 | #endif /* _FS_H */ |