diff options
author | AKASHI Takahiro | 2018-09-11 01:59:08 -0500 |
---|---|---|
committer | Alexander Graf | 2018-09-23 14:55:29 -0500 |
commit | e7074cffb8dccf862260e15b8de5297891c917a0 (patch) | |
tree | 5e70cd10b2780cb29c5e858a5587793031a484d1 /fs | |
parent | cda40b2aea39ec05683a2895f31c630ef2ce5131 (diff) | |
download | u-boot-e7074cffb8dccf862260e15b8de5297891c917a0.tar.gz u-boot-e7074cffb8dccf862260e15b8de5297891c917a0.tar.xz u-boot-e7074cffb8dccf862260e15b8de5297891c917a0.zip |
fs: add mkdir interface
"mkdir" interface is added to file operations.
This is a preparatory change as mkdir support for FAT file system
will be added in next patch.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs.c | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -105,6 +105,11 @@ static inline int fs_opendir_unsupported(const char *filename, | |||
105 | return -EACCES; | 105 | return -EACCES; |
106 | } | 106 | } |
107 | 107 | ||
108 | static inline int fs_mkdir_unsupported(const char *dirname) | ||
109 | { | ||
110 | return -1; | ||
111 | } | ||
112 | |||
108 | struct fstype_info { | 113 | struct fstype_info { |
109 | int fstype; | 114 | int fstype; |
110 | char *name; | 115 | char *name; |
@@ -142,6 +147,7 @@ struct fstype_info { | |||
142 | int (*readdir)(struct fs_dir_stream *dirs, struct fs_dirent **dentp); | 147 | int (*readdir)(struct fs_dir_stream *dirs, struct fs_dirent **dentp); |
143 | /* see fs_closedir() */ | 148 | /* see fs_closedir() */ |
144 | void (*closedir)(struct fs_dir_stream *dirs); | 149 | void (*closedir)(struct fs_dir_stream *dirs); |
150 | int (*mkdir)(const char *dirname); | ||
145 | }; | 151 | }; |
146 | 152 | ||
147 | static struct fstype_info fstypes[] = { | 153 | static struct fstype_info fstypes[] = { |
@@ -165,6 +171,7 @@ static struct fstype_info fstypes[] = { | |||
165 | .opendir = fat_opendir, | 171 | .opendir = fat_opendir, |
166 | .readdir = fat_readdir, | 172 | .readdir = fat_readdir, |
167 | .closedir = fat_closedir, | 173 | .closedir = fat_closedir, |
174 | .mkdir = fs_mkdir_unsupported, | ||
168 | }, | 175 | }, |
169 | #endif | 176 | #endif |
170 | #ifdef CONFIG_FS_EXT4 | 177 | #ifdef CONFIG_FS_EXT4 |
@@ -185,6 +192,7 @@ static struct fstype_info fstypes[] = { | |||
185 | #endif | 192 | #endif |
186 | .uuid = ext4fs_uuid, | 193 | .uuid = ext4fs_uuid, |
187 | .opendir = fs_opendir_unsupported, | 194 | .opendir = fs_opendir_unsupported, |
195 | .mkdir = fs_mkdir_unsupported, | ||
188 | }, | 196 | }, |
189 | #endif | 197 | #endif |
190 | #ifdef CONFIG_SANDBOX | 198 | #ifdef CONFIG_SANDBOX |
@@ -201,6 +209,7 @@ static struct fstype_info fstypes[] = { | |||
201 | .write = fs_write_sandbox, | 209 | .write = fs_write_sandbox, |
202 | .uuid = fs_uuid_unsupported, | 210 | .uuid = fs_uuid_unsupported, |
203 | .opendir = fs_opendir_unsupported, | 211 | .opendir = fs_opendir_unsupported, |
212 | .mkdir = fs_mkdir_unsupported, | ||
204 | }, | 213 | }, |
205 | #endif | 214 | #endif |
206 | #ifdef CONFIG_CMD_UBIFS | 215 | #ifdef CONFIG_CMD_UBIFS |
@@ -217,6 +226,7 @@ static struct fstype_info fstypes[] = { | |||
217 | .write = fs_write_unsupported, | 226 | .write = fs_write_unsupported, |
218 | .uuid = fs_uuid_unsupported, | 227 | .uuid = fs_uuid_unsupported, |
219 | .opendir = fs_opendir_unsupported, | 228 | .opendir = fs_opendir_unsupported, |
229 | .mkdir = fs_mkdir_unsupported, | ||
220 | }, | 230 | }, |
221 | #endif | 231 | #endif |
222 | #ifdef CONFIG_FS_BTRFS | 232 | #ifdef CONFIG_FS_BTRFS |
@@ -233,6 +243,7 @@ static struct fstype_info fstypes[] = { | |||
233 | .write = fs_write_unsupported, | 243 | .write = fs_write_unsupported, |
234 | .uuid = btrfs_uuid, | 244 | .uuid = btrfs_uuid, |
235 | .opendir = fs_opendir_unsupported, | 245 | .opendir = fs_opendir_unsupported, |
246 | .mkdir = fs_mkdir_unsupported, | ||
236 | }, | 247 | }, |
237 | #endif | 248 | #endif |
238 | { | 249 | { |
@@ -248,6 +259,7 @@ static struct fstype_info fstypes[] = { | |||
248 | .write = fs_write_unsupported, | 259 | .write = fs_write_unsupported, |
249 | .uuid = fs_uuid_unsupported, | 260 | .uuid = fs_uuid_unsupported, |
250 | .opendir = fs_opendir_unsupported, | 261 | .opendir = fs_opendir_unsupported, |
262 | .mkdir = fs_mkdir_unsupported, | ||
251 | }, | 263 | }, |
252 | }; | 264 | }; |
253 | 265 | ||
@@ -498,6 +510,20 @@ void fs_closedir(struct fs_dir_stream *dirs) | |||
498 | } | 510 | } |
499 | 511 | ||
500 | 512 | ||
513 | int fs_mkdir(const char *dirname) | ||
514 | { | ||
515 | int ret; | ||
516 | |||
517 | struct fstype_info *info = fs_get_info(fs_type); | ||
518 | |||
519 | ret = info->mkdir(dirname); | ||
520 | |||
521 | fs_type = FS_TYPE_ANY; | ||
522 | fs_close(); | ||
523 | |||
524 | return ret; | ||
525 | } | ||
526 | |||
501 | int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], | 527 | int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], |
502 | int fstype) | 528 | int fstype) |
503 | { | 529 | { |
@@ -700,3 +726,22 @@ int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) | |||
700 | return CMD_RET_SUCCESS; | 726 | return CMD_RET_SUCCESS; |
701 | } | 727 | } |
702 | 728 | ||
729 | int do_mkdir(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], | ||
730 | int fstype) | ||
731 | { | ||
732 | int ret; | ||
733 | |||
734 | if (argc != 4) | ||
735 | return CMD_RET_USAGE; | ||
736 | |||
737 | if (fs_set_blk_dev(argv[1], argv[2], fstype)) | ||
738 | return 1; | ||
739 | |||
740 | ret = fs_mkdir(argv[3]); | ||
741 | if (ret) { | ||
742 | printf("** Unable to create a directory \"%s\" **\n", argv[3]); | ||
743 | return 1; | ||
744 | } | ||
745 | |||
746 | return 0; | ||
747 | } | ||