Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
Tom Rini | 5b8031c | 2016-01-14 22:05:13 -0500 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <config.h> |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 8 | #include <errno.h> |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 9 | #include <common.h> |
Joe Hershberger | 0eb25b6 | 2015-03-22 17:08:59 -0500 | [diff] [blame] | 10 | #include <mapmem.h> |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 11 | #include <part.h> |
| 12 | #include <ext4fs.h> |
| 13 | #include <fat.h> |
| 14 | #include <fs.h> |
Simon Glass | 92ccc96 | 2012-12-26 09:53:35 +0000 | [diff] [blame] | 15 | #include <sandboxfs.h> |
Hans de Goede | 251cee0 | 2015-09-17 18:46:58 -0400 | [diff] [blame] | 16 | #include <ubifs_uboot.h> |
Simon Glass | 117e050 | 2012-12-26 09:53:32 +0000 | [diff] [blame] | 17 | #include <asm/io.h> |
Tom Rini | 9e374e7 | 2014-11-24 11:50:46 -0500 | [diff] [blame] | 18 | #include <div64.h> |
| 19 | #include <linux/math64.h> |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 20 | |
Stephen Warren | a1b231c | 2012-10-30 07:50:47 +0000 | [diff] [blame] | 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Simon Glass | 4101f68 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 23 | static struct blk_desc *fs_dev_desc; |
Rob Clark | 4bbcc96 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 24 | static int fs_dev_part; |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 25 | static disk_partition_t fs_partition; |
| 26 | static int fs_type = FS_TYPE_ANY; |
| 27 | |
Simon Glass | 4101f68 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 28 | static inline int fs_probe_unsupported(struct blk_desc *fs_dev_desc, |
Simon Glass | 2ded0d4 | 2012-12-26 09:53:31 +0000 | [diff] [blame] | 29 | disk_partition_t *fs_partition) |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 30 | { |
| 31 | printf("** Unrecognized filesystem type **\n"); |
| 32 | return -1; |
| 33 | } |
| 34 | |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 35 | static inline int fs_ls_unsupported(const char *dirname) |
| 36 | { |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 37 | return -1; |
| 38 | } |
| 39 | |
Rob Clark | 89191d6 | 2017-09-09 13:15:58 -0400 | [diff] [blame] | 40 | /* generic implementation of ls in terms of opendir/readdir/closedir */ |
| 41 | __maybe_unused |
| 42 | static int fs_ls_generic(const char *dirname) |
| 43 | { |
| 44 | struct fs_dir_stream *dirs; |
| 45 | struct fs_dirent *dent; |
| 46 | int nfiles = 0, ndirs = 0; |
| 47 | |
| 48 | dirs = fs_opendir(dirname); |
| 49 | if (!dirs) |
| 50 | return -errno; |
| 51 | |
| 52 | while ((dent = fs_readdir(dirs))) { |
| 53 | if (dent->type == FS_DT_DIR) { |
| 54 | printf(" %s/\n", dent->name); |
| 55 | ndirs++; |
| 56 | } else { |
| 57 | printf(" %8lld %s\n", dent->size, dent->name); |
| 58 | nfiles++; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | fs_closedir(dirs); |
| 63 | |
| 64 | printf("\n%d file(s), %d dir(s)\n\n", nfiles, ndirs); |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |
Stephen Warren | 6152916 | 2014-02-03 13:21:00 -0700 | [diff] [blame] | 69 | static inline int fs_exists_unsupported(const char *filename) |
| 70 | { |
| 71 | return 0; |
| 72 | } |
| 73 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 74 | static inline int fs_size_unsupported(const char *filename, loff_t *size) |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 75 | { |
| 76 | return -1; |
| 77 | } |
| 78 | |
Simon Glass | 117e050 | 2012-12-26 09:53:32 +0000 | [diff] [blame] | 79 | static inline int fs_read_unsupported(const char *filename, void *buf, |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 80 | loff_t offset, loff_t len, |
| 81 | loff_t *actread) |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 82 | { |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 83 | return -1; |
| 84 | } |
| 85 | |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 86 | static inline int fs_write_unsupported(const char *filename, void *buf, |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 87 | loff_t offset, loff_t len, |
| 88 | loff_t *actwrite) |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 89 | { |
| 90 | return -1; |
| 91 | } |
| 92 | |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 93 | static inline void fs_close_unsupported(void) |
| 94 | { |
| 95 | } |
| 96 | |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 97 | static inline int fs_uuid_unsupported(char *uuid_str) |
| 98 | { |
| 99 | return -1; |
| 100 | } |
| 101 | |
Rob Clark | 4bbcc96 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 102 | static inline int fs_opendir_unsupported(const char *filename, |
| 103 | struct fs_dir_stream **dirs) |
| 104 | { |
| 105 | return -EACCES; |
| 106 | } |
| 107 | |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 108 | struct fstype_info { |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 109 | int fstype; |
Sjoerd Simons | 1a1ad8e | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 110 | char *name; |
Stephen Warren | 377202b | 2014-02-03 13:21:01 -0700 | [diff] [blame] | 111 | /* |
| 112 | * Is it legal to pass NULL as .probe()'s fs_dev_desc parameter? This |
| 113 | * should be false in most cases. For "virtual" filesystems which |
| 114 | * aren't based on a U-Boot block device (e.g. sandbox), this can be |
| 115 | * set to true. This should also be true for the dumm entry at the end |
| 116 | * of fstypes[], since that is essentially a "virtual" (non-existent) |
| 117 | * filesystem. |
| 118 | */ |
| 119 | bool null_dev_desc_ok; |
Simon Glass | 4101f68 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 120 | int (*probe)(struct blk_desc *fs_dev_desc, |
Simon Glass | 2ded0d4 | 2012-12-26 09:53:31 +0000 | [diff] [blame] | 121 | disk_partition_t *fs_partition); |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 122 | int (*ls)(const char *dirname); |
Stephen Warren | 6152916 | 2014-02-03 13:21:00 -0700 | [diff] [blame] | 123 | int (*exists)(const char *filename); |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 124 | int (*size)(const char *filename, loff_t *size); |
| 125 | int (*read)(const char *filename, void *buf, loff_t offset, |
| 126 | loff_t len, loff_t *actread); |
| 127 | int (*write)(const char *filename, void *buf, loff_t offset, |
| 128 | loff_t len, loff_t *actwrite); |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 129 | void (*close)(void); |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 130 | int (*uuid)(char *uuid_str); |
Rob Clark | 4bbcc96 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 131 | /* |
| 132 | * Open a directory stream. On success return 0 and directory |
| 133 | * stream pointer via 'dirsp'. On error, return -errno. See |
| 134 | * fs_opendir(). |
| 135 | */ |
| 136 | int (*opendir)(const char *filename, struct fs_dir_stream **dirsp); |
| 137 | /* |
| 138 | * Read next entry from directory stream. On success return 0 |
| 139 | * and directory entry pointer via 'dentp'. On error return |
| 140 | * -errno. See fs_readdir(). |
| 141 | */ |
| 142 | int (*readdir)(struct fs_dir_stream *dirs, struct fs_dirent **dentp); |
| 143 | /* see fs_closedir() */ |
| 144 | void (*closedir)(struct fs_dir_stream *dirs); |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | static struct fstype_info fstypes[] = { |
| 148 | #ifdef CONFIG_FS_FAT |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 149 | { |
| 150 | .fstype = FS_TYPE_FAT, |
Sjoerd Simons | 1a1ad8e | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 151 | .name = "fat", |
Stephen Warren | 377202b | 2014-02-03 13:21:01 -0700 | [diff] [blame] | 152 | .null_dev_desc_ok = false, |
Simon Glass | e6d5241 | 2012-12-26 09:53:33 +0000 | [diff] [blame] | 153 | .probe = fat_set_blk_dev, |
| 154 | .close = fat_close, |
Rob Clark | 89191d6 | 2017-09-09 13:15:58 -0400 | [diff] [blame] | 155 | .ls = fs_ls_generic, |
Stephen Warren | b7b5f31 | 2014-02-03 13:21:10 -0700 | [diff] [blame] | 156 | .exists = fat_exists, |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 157 | .size = fat_size, |
Simon Glass | e6d5241 | 2012-12-26 09:53:33 +0000 | [diff] [blame] | 158 | .read = fat_read_file, |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 159 | #ifdef CONFIG_FAT_WRITE |
| 160 | .write = file_fat_write, |
| 161 | #else |
Stephen Warren | bd6fb31 | 2014-02-03 13:20:59 -0700 | [diff] [blame] | 162 | .write = fs_write_unsupported, |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 163 | #endif |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 164 | .uuid = fs_uuid_unsupported, |
Rob Clark | 89191d6 | 2017-09-09 13:15:58 -0400 | [diff] [blame] | 165 | .opendir = fat_opendir, |
| 166 | .readdir = fat_readdir, |
| 167 | .closedir = fat_closedir, |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 168 | }, |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 169 | #endif |
| 170 | #ifdef CONFIG_FS_EXT4 |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 171 | { |
| 172 | .fstype = FS_TYPE_EXT, |
Sjoerd Simons | 1a1ad8e | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 173 | .name = "ext4", |
Stephen Warren | 377202b | 2014-02-03 13:21:01 -0700 | [diff] [blame] | 174 | .null_dev_desc_ok = false, |
Simon Glass | e6d5241 | 2012-12-26 09:53:33 +0000 | [diff] [blame] | 175 | .probe = ext4fs_probe, |
| 176 | .close = ext4fs_close, |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 177 | .ls = ext4fs_ls, |
Stephen Warren | 55af5c9 | 2014-02-03 13:21:09 -0700 | [diff] [blame] | 178 | .exists = ext4fs_exists, |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 179 | .size = ext4fs_size, |
Simon Glass | e6d5241 | 2012-12-26 09:53:33 +0000 | [diff] [blame] | 180 | .read = ext4_read_file, |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 181 | #ifdef CONFIG_CMD_EXT4_WRITE |
| 182 | .write = ext4_write_file, |
| 183 | #else |
Stephen Warren | bd6fb31 | 2014-02-03 13:20:59 -0700 | [diff] [blame] | 184 | .write = fs_write_unsupported, |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 185 | #endif |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 186 | .uuid = ext4fs_uuid, |
Rob Clark | 4bbcc96 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 187 | .opendir = fs_opendir_unsupported, |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 188 | }, |
| 189 | #endif |
Simon Glass | 92ccc96 | 2012-12-26 09:53:35 +0000 | [diff] [blame] | 190 | #ifdef CONFIG_SANDBOX |
| 191 | { |
| 192 | .fstype = FS_TYPE_SANDBOX, |
Sjoerd Simons | 1a1ad8e | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 193 | .name = "sandbox", |
Stephen Warren | 377202b | 2014-02-03 13:21:01 -0700 | [diff] [blame] | 194 | .null_dev_desc_ok = true, |
Simon Glass | 92ccc96 | 2012-12-26 09:53:35 +0000 | [diff] [blame] | 195 | .probe = sandbox_fs_set_blk_dev, |
| 196 | .close = sandbox_fs_close, |
| 197 | .ls = sandbox_fs_ls, |
Stephen Warren | 0a30aa1 | 2014-02-03 13:21:07 -0700 | [diff] [blame] | 198 | .exists = sandbox_fs_exists, |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 199 | .size = sandbox_fs_size, |
Simon Glass | 92ccc96 | 2012-12-26 09:53:35 +0000 | [diff] [blame] | 200 | .read = fs_read_sandbox, |
Simon Glass | 7eb2c8d | 2013-04-20 08:42:51 +0000 | [diff] [blame] | 201 | .write = fs_write_sandbox, |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 202 | .uuid = fs_uuid_unsupported, |
Rob Clark | 4bbcc96 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 203 | .opendir = fs_opendir_unsupported, |
Simon Glass | 92ccc96 | 2012-12-26 09:53:35 +0000 | [diff] [blame] | 204 | }, |
| 205 | #endif |
Hans de Goede | 251cee0 | 2015-09-17 18:46:58 -0400 | [diff] [blame] | 206 | #ifdef CONFIG_CMD_UBIFS |
| 207 | { |
| 208 | .fstype = FS_TYPE_UBIFS, |
| 209 | .name = "ubifs", |
| 210 | .null_dev_desc_ok = true, |
| 211 | .probe = ubifs_set_blk_dev, |
| 212 | .close = ubifs_close, |
| 213 | .ls = ubifs_ls, |
| 214 | .exists = ubifs_exists, |
| 215 | .size = ubifs_size, |
| 216 | .read = ubifs_read, |
| 217 | .write = fs_write_unsupported, |
| 218 | .uuid = fs_uuid_unsupported, |
Rob Clark | 4bbcc96 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 219 | .opendir = fs_opendir_unsupported, |
Hans de Goede | 251cee0 | 2015-09-17 18:46:58 -0400 | [diff] [blame] | 220 | }, |
| 221 | #endif |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 222 | { |
| 223 | .fstype = FS_TYPE_ANY, |
Sjoerd Simons | 1a1ad8e | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 224 | .name = "unsupported", |
Stephen Warren | 377202b | 2014-02-03 13:21:01 -0700 | [diff] [blame] | 225 | .null_dev_desc_ok = true, |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 226 | .probe = fs_probe_unsupported, |
| 227 | .close = fs_close_unsupported, |
| 228 | .ls = fs_ls_unsupported, |
Stephen Warren | 6152916 | 2014-02-03 13:21:00 -0700 | [diff] [blame] | 229 | .exists = fs_exists_unsupported, |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 230 | .size = fs_size_unsupported, |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 231 | .read = fs_read_unsupported, |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 232 | .write = fs_write_unsupported, |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 233 | .uuid = fs_uuid_unsupported, |
Rob Clark | 4bbcc96 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 234 | .opendir = fs_opendir_unsupported, |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 235 | }, |
| 236 | }; |
| 237 | |
Simon Glass | c6f548d | 2012-12-26 09:53:30 +0000 | [diff] [blame] | 238 | static struct fstype_info *fs_get_info(int fstype) |
| 239 | { |
| 240 | struct fstype_info *info; |
| 241 | int i; |
| 242 | |
| 243 | for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes) - 1; i++, info++) { |
| 244 | if (fstype == info->fstype) |
| 245 | return info; |
| 246 | } |
| 247 | |
| 248 | /* Return the 'unsupported' sentinel */ |
| 249 | return info; |
| 250 | } |
| 251 | |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 252 | int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype) |
| 253 | { |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 254 | struct fstype_info *info; |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 255 | int part, i; |
Stephen Warren | a1b231c | 2012-10-30 07:50:47 +0000 | [diff] [blame] | 256 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
| 257 | static int relocated; |
| 258 | |
| 259 | if (!relocated) { |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 260 | for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes); |
| 261 | i++, info++) { |
Sjoerd Simons | 1a1ad8e | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 262 | info->name += gd->reloc_off; |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 263 | info->probe += gd->reloc_off; |
| 264 | info->close += gd->reloc_off; |
| 265 | info->ls += gd->reloc_off; |
| 266 | info->read += gd->reloc_off; |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 267 | info->write += gd->reloc_off; |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 268 | } |
Stephen Warren | a1b231c | 2012-10-30 07:50:47 +0000 | [diff] [blame] | 269 | relocated = 1; |
| 270 | } |
| 271 | #endif |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 272 | |
Simon Glass | e35929e | 2016-02-29 15:25:44 -0700 | [diff] [blame] | 273 | part = blk_get_device_part_str(ifname, dev_part_str, &fs_dev_desc, |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 274 | &fs_partition, 1); |
| 275 | if (part < 0) |
| 276 | return -1; |
| 277 | |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 278 | for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes); i++, info++) { |
| 279 | if (fstype != FS_TYPE_ANY && info->fstype != FS_TYPE_ANY && |
| 280 | fstype != info->fstype) |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 281 | continue; |
| 282 | |
Stephen Warren | 377202b | 2014-02-03 13:21:01 -0700 | [diff] [blame] | 283 | if (!fs_dev_desc && !info->null_dev_desc_ok) |
| 284 | continue; |
| 285 | |
Simon Glass | 2ded0d4 | 2012-12-26 09:53:31 +0000 | [diff] [blame] | 286 | if (!info->probe(fs_dev_desc, &fs_partition)) { |
Simon Glass | 436e2b7 | 2012-12-26 09:53:29 +0000 | [diff] [blame] | 287 | fs_type = info->fstype; |
Rob Clark | 4bbcc96 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 288 | fs_dev_part = part; |
| 289 | return 0; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | return -1; |
| 294 | } |
| 295 | |
| 296 | /* set current blk device w/ blk_desc + partition # */ |
| 297 | int fs_set_blk_dev_with_part(struct blk_desc *desc, int part) |
| 298 | { |
| 299 | struct fstype_info *info; |
| 300 | int ret, i; |
| 301 | |
| 302 | if (part >= 1) |
| 303 | ret = part_get_info(desc, part, &fs_partition); |
| 304 | else |
| 305 | ret = part_get_info_whole_disk(desc, &fs_partition); |
| 306 | if (ret) |
| 307 | return ret; |
| 308 | fs_dev_desc = desc; |
| 309 | |
| 310 | for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes); i++, info++) { |
| 311 | if (!info->probe(fs_dev_desc, &fs_partition)) { |
| 312 | fs_type = info->fstype; |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 313 | return 0; |
| 314 | } |
| 315 | } |
| 316 | |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 317 | return -1; |
| 318 | } |
| 319 | |
| 320 | static void fs_close(void) |
| 321 | { |
Simon Glass | c6f548d | 2012-12-26 09:53:30 +0000 | [diff] [blame] | 322 | struct fstype_info *info = fs_get_info(fs_type); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 323 | |
Simon Glass | c6f548d | 2012-12-26 09:53:30 +0000 | [diff] [blame] | 324 | info->close(); |
Simon Glass | e6d5241 | 2012-12-26 09:53:33 +0000 | [diff] [blame] | 325 | |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 326 | fs_type = FS_TYPE_ANY; |
| 327 | } |
| 328 | |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 329 | int fs_uuid(char *uuid_str) |
| 330 | { |
| 331 | struct fstype_info *info = fs_get_info(fs_type); |
| 332 | |
| 333 | return info->uuid(uuid_str); |
| 334 | } |
| 335 | |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 336 | int fs_ls(const char *dirname) |
| 337 | { |
| 338 | int ret; |
| 339 | |
Simon Glass | c6f548d | 2012-12-26 09:53:30 +0000 | [diff] [blame] | 340 | struct fstype_info *info = fs_get_info(fs_type); |
| 341 | |
| 342 | ret = info->ls(dirname); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 343 | |
Simon Glass | e6d5241 | 2012-12-26 09:53:33 +0000 | [diff] [blame] | 344 | fs_type = FS_TYPE_ANY; |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 345 | fs_close(); |
| 346 | |
| 347 | return ret; |
| 348 | } |
| 349 | |
Stephen Warren | 6152916 | 2014-02-03 13:21:00 -0700 | [diff] [blame] | 350 | int fs_exists(const char *filename) |
| 351 | { |
| 352 | int ret; |
| 353 | |
| 354 | struct fstype_info *info = fs_get_info(fs_type); |
| 355 | |
| 356 | ret = info->exists(filename); |
| 357 | |
| 358 | fs_close(); |
| 359 | |
| 360 | return ret; |
| 361 | } |
| 362 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 363 | int fs_size(const char *filename, loff_t *size) |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 364 | { |
| 365 | int ret; |
| 366 | |
| 367 | struct fstype_info *info = fs_get_info(fs_type); |
| 368 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 369 | ret = info->size(filename, size); |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 370 | |
| 371 | fs_close(); |
| 372 | |
| 373 | return ret; |
| 374 | } |
| 375 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 376 | int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len, |
| 377 | loff_t *actread) |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 378 | { |
Simon Glass | c6f548d | 2012-12-26 09:53:30 +0000 | [diff] [blame] | 379 | struct fstype_info *info = fs_get_info(fs_type); |
Simon Glass | 117e050 | 2012-12-26 09:53:32 +0000 | [diff] [blame] | 380 | void *buf; |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 381 | int ret; |
| 382 | |
Simon Glass | 117e050 | 2012-12-26 09:53:32 +0000 | [diff] [blame] | 383 | /* |
| 384 | * We don't actually know how many bytes are being read, since len==0 |
| 385 | * means read the whole file. |
| 386 | */ |
| 387 | buf = map_sysmem(addr, len); |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 388 | ret = info->read(filename, buf, offset, len, actread); |
Simon Glass | 117e050 | 2012-12-26 09:53:32 +0000 | [diff] [blame] | 389 | unmap_sysmem(buf); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 390 | |
Simon Glass | c6f548d | 2012-12-26 09:53:30 +0000 | [diff] [blame] | 391 | /* If we requested a specific number of bytes, check we got it */ |
Max Krummenacher | 7a3e70c | 2015-08-05 17:16:58 +0200 | [diff] [blame] | 392 | if (ret == 0 && len && *actread != len) |
| 393 | printf("** %s shorter than offset + len **\n", filename); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 394 | fs_close(); |
| 395 | |
| 396 | return ret; |
| 397 | } |
| 398 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 399 | int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len, |
| 400 | loff_t *actwrite) |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 401 | { |
| 402 | struct fstype_info *info = fs_get_info(fs_type); |
| 403 | void *buf; |
| 404 | int ret; |
| 405 | |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 406 | buf = map_sysmem(addr, len); |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 407 | ret = info->write(filename, buf, offset, len, actwrite); |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 408 | unmap_sysmem(buf); |
| 409 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 410 | if (ret < 0 && len != *actwrite) { |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 411 | printf("** Unable to write file %s **\n", filename); |
| 412 | ret = -1; |
| 413 | } |
| 414 | fs_close(); |
| 415 | |
| 416 | return ret; |
| 417 | } |
| 418 | |
Rob Clark | 4bbcc96 | 2017-09-09 13:15:55 -0400 | [diff] [blame] | 419 | struct fs_dir_stream *fs_opendir(const char *filename) |
| 420 | { |
| 421 | struct fstype_info *info = fs_get_info(fs_type); |
| 422 | struct fs_dir_stream *dirs = NULL; |
| 423 | int ret; |
| 424 | |
| 425 | ret = info->opendir(filename, &dirs); |
| 426 | fs_close(); |
| 427 | if (ret) { |
| 428 | errno = -ret; |
| 429 | return NULL; |
| 430 | } |
| 431 | |
| 432 | dirs->desc = fs_dev_desc; |
| 433 | dirs->part = fs_dev_part; |
| 434 | |
| 435 | return dirs; |
| 436 | } |
| 437 | |
| 438 | struct fs_dirent *fs_readdir(struct fs_dir_stream *dirs) |
| 439 | { |
| 440 | struct fstype_info *info; |
| 441 | struct fs_dirent *dirent; |
| 442 | int ret; |
| 443 | |
| 444 | fs_set_blk_dev_with_part(dirs->desc, dirs->part); |
| 445 | info = fs_get_info(fs_type); |
| 446 | |
| 447 | ret = info->readdir(dirs, &dirent); |
| 448 | fs_close(); |
| 449 | if (ret) { |
| 450 | errno = -ret; |
| 451 | return NULL; |
| 452 | } |
| 453 | |
| 454 | return dirent; |
| 455 | } |
| 456 | |
| 457 | void fs_closedir(struct fs_dir_stream *dirs) |
| 458 | { |
| 459 | struct fstype_info *info; |
| 460 | |
| 461 | if (!dirs) |
| 462 | return; |
| 463 | |
| 464 | fs_set_blk_dev_with_part(dirs->desc, dirs->part); |
| 465 | info = fs_get_info(fs_type); |
| 466 | |
| 467 | info->closedir(dirs); |
| 468 | fs_close(); |
| 469 | } |
| 470 | |
| 471 | |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 472 | int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], |
| 473 | int fstype) |
| 474 | { |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 475 | loff_t size; |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 476 | |
| 477 | if (argc != 4) |
| 478 | return CMD_RET_USAGE; |
| 479 | |
| 480 | if (fs_set_blk_dev(argv[1], argv[2], fstype)) |
| 481 | return 1; |
| 482 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 483 | if (fs_size(argv[3], &size) < 0) |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 484 | return CMD_RET_FAILURE; |
| 485 | |
Simon Glass | 018f530 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 486 | env_set_hex("filesize", size); |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 487 | |
| 488 | return 0; |
| 489 | } |
| 490 | |
Stephen Warren | f9b55e2 | 2012-10-31 11:05:07 +0000 | [diff] [blame] | 491 | int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], |
Wolfgang Denk | b770e88 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 492 | int fstype) |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 493 | { |
| 494 | unsigned long addr; |
| 495 | const char *addr_str; |
| 496 | const char *filename; |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 497 | loff_t bytes; |
| 498 | loff_t pos; |
| 499 | loff_t len_read; |
| 500 | int ret; |
Andreas Bießmann | da1fd96 | 2012-11-14 13:32:37 +0100 | [diff] [blame] | 501 | unsigned long time; |
Pavel Machek | 949bbd7 | 2014-07-09 22:42:57 +0200 | [diff] [blame] | 502 | char *ep; |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 503 | |
Stephen Warren | e9b0f99 | 2012-10-30 12:04:17 +0000 | [diff] [blame] | 504 | if (argc < 2) |
| 505 | return CMD_RET_USAGE; |
| 506 | if (argc > 7) |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 507 | return CMD_RET_USAGE; |
| 508 | |
Stephen Warren | e9b0f99 | 2012-10-30 12:04:17 +0000 | [diff] [blame] | 509 | if (fs_set_blk_dev(argv[1], (argc >= 3) ? argv[2] : NULL, fstype)) |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 510 | return 1; |
| 511 | |
| 512 | if (argc >= 4) { |
Pavel Machek | 949bbd7 | 2014-07-09 22:42:57 +0200 | [diff] [blame] | 513 | addr = simple_strtoul(argv[3], &ep, 16); |
| 514 | if (ep == argv[3] || *ep != '\0') |
| 515 | return CMD_RET_USAGE; |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 516 | } else { |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 517 | addr_str = env_get("loadaddr"); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 518 | if (addr_str != NULL) |
| 519 | addr = simple_strtoul(addr_str, NULL, 16); |
| 520 | else |
| 521 | addr = CONFIG_SYS_LOAD_ADDR; |
| 522 | } |
| 523 | if (argc >= 5) { |
| 524 | filename = argv[4]; |
| 525 | } else { |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 526 | filename = env_get("bootfile"); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 527 | if (!filename) { |
| 528 | puts("** No boot file defined **\n"); |
| 529 | return 1; |
| 530 | } |
| 531 | } |
| 532 | if (argc >= 6) |
Wolfgang Denk | b770e88 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 533 | bytes = simple_strtoul(argv[5], NULL, 16); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 534 | else |
| 535 | bytes = 0; |
| 536 | if (argc >= 7) |
Wolfgang Denk | b770e88 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 537 | pos = simple_strtoul(argv[6], NULL, 16); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 538 | else |
| 539 | pos = 0; |
| 540 | |
Andreas Bießmann | da1fd96 | 2012-11-14 13:32:37 +0100 | [diff] [blame] | 541 | time = get_timer(0); |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 542 | ret = fs_read(filename, addr, pos, bytes, &len_read); |
Andreas Bießmann | da1fd96 | 2012-11-14 13:32:37 +0100 | [diff] [blame] | 543 | time = get_timer(time); |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 544 | if (ret < 0) |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 545 | return 1; |
| 546 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 547 | printf("%llu bytes read in %lu ms", len_read, time); |
Andreas Bießmann | da1fd96 | 2012-11-14 13:32:37 +0100 | [diff] [blame] | 548 | if (time > 0) { |
| 549 | puts(" ("); |
Tom Rini | 9e374e7 | 2014-11-24 11:50:46 -0500 | [diff] [blame] | 550 | print_size(div_u64(len_read, time) * 1000, "/s"); |
Andreas Bießmann | da1fd96 | 2012-11-14 13:32:37 +0100 | [diff] [blame] | 551 | puts(")"); |
| 552 | } |
| 553 | puts("\n"); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 554 | |
Simon Glass | 018f530 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 555 | env_set_hex("fileaddr", addr); |
| 556 | env_set_hex("filesize", len_read); |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 557 | |
| 558 | return 0; |
| 559 | } |
| 560 | |
| 561 | int do_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], |
| 562 | int fstype) |
| 563 | { |
| 564 | if (argc < 2) |
| 565 | return CMD_RET_USAGE; |
Stephen Warren | e9b0f99 | 2012-10-30 12:04:17 +0000 | [diff] [blame] | 566 | if (argc > 4) |
| 567 | return CMD_RET_USAGE; |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 568 | |
| 569 | if (fs_set_blk_dev(argv[1], (argc >= 3) ? argv[2] : NULL, fstype)) |
| 570 | return 1; |
| 571 | |
Stephen Warren | e9b0f99 | 2012-10-30 12:04:17 +0000 | [diff] [blame] | 572 | if (fs_ls(argc >= 4 ? argv[3] : "/")) |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 573 | return 1; |
| 574 | |
| 575 | return 0; |
| 576 | } |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 577 | |
Stephen Warren | 6152916 | 2014-02-03 13:21:00 -0700 | [diff] [blame] | 578 | int file_exists(const char *dev_type, const char *dev_part, const char *file, |
| 579 | int fstype) |
| 580 | { |
| 581 | if (fs_set_blk_dev(dev_type, dev_part, fstype)) |
| 582 | return 0; |
| 583 | |
| 584 | return fs_exists(file); |
| 585 | } |
| 586 | |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 587 | int do_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], |
Wolfgang Denk | b770e88 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 588 | int fstype) |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 589 | { |
| 590 | unsigned long addr; |
| 591 | const char *filename; |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 592 | loff_t bytes; |
| 593 | loff_t pos; |
| 594 | loff_t len; |
| 595 | int ret; |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 596 | unsigned long time; |
| 597 | |
| 598 | if (argc < 6 || argc > 7) |
| 599 | return CMD_RET_USAGE; |
| 600 | |
| 601 | if (fs_set_blk_dev(argv[1], argv[2], fstype)) |
| 602 | return 1; |
| 603 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 604 | addr = simple_strtoul(argv[3], NULL, 16); |
| 605 | filename = argv[4]; |
Wolfgang Denk | b770e88 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 606 | bytes = simple_strtoul(argv[5], NULL, 16); |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 607 | if (argc >= 7) |
Wolfgang Denk | b770e88 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 608 | pos = simple_strtoul(argv[6], NULL, 16); |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 609 | else |
| 610 | pos = 0; |
| 611 | |
| 612 | time = get_timer(0); |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 613 | ret = fs_write(filename, addr, pos, bytes, &len); |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 614 | time = get_timer(time); |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 615 | if (ret < 0) |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 616 | return 1; |
| 617 | |
Suriyan Ramasami | d455d87 | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 618 | printf("%llu bytes written in %lu ms", len, time); |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 619 | if (time > 0) { |
| 620 | puts(" ("); |
Tom Rini | 9e374e7 | 2014-11-24 11:50:46 -0500 | [diff] [blame] | 621 | print_size(div_u64(len, time) * 1000, "/s"); |
Simon Glass | a8f6ab5 | 2013-04-20 08:42:50 +0000 | [diff] [blame] | 622 | puts(")"); |
| 623 | } |
| 624 | puts("\n"); |
| 625 | |
| 626 | return 0; |
| 627 | } |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 628 | |
| 629 | int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], |
| 630 | int fstype) |
| 631 | { |
| 632 | int ret; |
| 633 | char uuid[37]; |
| 634 | memset(uuid, 0, sizeof(uuid)); |
| 635 | |
| 636 | if (argc < 3 || argc > 4) |
| 637 | return CMD_RET_USAGE; |
| 638 | |
| 639 | if (fs_set_blk_dev(argv[1], argv[2], fstype)) |
| 640 | return 1; |
| 641 | |
| 642 | ret = fs_uuid(uuid); |
| 643 | if (ret) |
| 644 | return CMD_RET_FAILURE; |
| 645 | |
| 646 | if (argc == 4) |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 647 | env_set(argv[3], uuid); |
Christian Gmeiner | 59e890e | 2014-11-12 14:35:04 +0100 | [diff] [blame] | 648 | else |
| 649 | printf("%s\n", uuid); |
| 650 | |
| 651 | return CMD_RET_SUCCESS; |
| 652 | } |
Sjoerd Simons | 1a1ad8e | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 653 | |
| 654 | int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 655 | { |
| 656 | struct fstype_info *info; |
| 657 | |
| 658 | if (argc < 3 || argc > 4) |
| 659 | return CMD_RET_USAGE; |
| 660 | |
| 661 | if (fs_set_blk_dev(argv[1], argv[2], FS_TYPE_ANY)) |
| 662 | return 1; |
| 663 | |
| 664 | info = fs_get_info(fs_type); |
| 665 | |
| 666 | if (argc == 4) |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 667 | env_set(argv[3], info->name); |
Sjoerd Simons | 1a1ad8e | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 668 | else |
| 669 | printf("%s\n", info->name); |
| 670 | |
| 671 | return CMD_RET_SUCCESS; |
| 672 | } |
| 673 | |