#include <usb.h>
#endif
+int do_ext4_size(cmd_tbl_t *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ return do_size(cmdtp, flag, argc, argv, FS_TYPE_EXT);
+}
+
int do_ext4_load(cmd_tbl_t *cmdtp, int flag, int argc,
char *const argv[])
{
#endif
+U_BOOT_CMD(
+ ext4size, 4, 0, do_ext4_size,
+ "determine a file's size",
+ "<interface> <dev[:part]> <filename>\n"
+ " - Find file 'filename' from 'dev' on 'interface'\n"
+ " and determine its size."
+);
+
U_BOOT_CMD(ext4ls, 4, 1, do_ext4_ls,
"list files in a directory (default /)",
"<interface> <dev[:part]> [directory]\n"
#include <fat.h>
#include <fs.h>
+int do_fat_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ return do_size(cmdtp, flag, argc, argv, FS_TYPE_FAT);
+}
+
+U_BOOT_CMD(
+ fatsize, 4, 0, do_fat_size,
+ "determine a file's size",
+ "<interface> <dev[:part]> <filename>\n"
+ " - Find file 'filename' from 'dev' on 'interface'\n"
+ " and determine its size."
+);
+
int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return do_load(cmdtp, flag, argc, argv, FS_TYPE_FAT);
#include <command.h>
#include <fs.h>
+static int do_size_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ return do_size(cmdtp, flag, argc, argv, FS_TYPE_ANY);
+}
+
+U_BOOT_CMD(
+ size, 4, 0, do_size_wrapper,
+ "determine a file's size",
+ "<interface> <dev[:part]> <filename>\n"
+ " - Find file 'filename' from 'dev' on 'interface'\n"
+ " and determine its size."
+);
+
static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
return file_len >= 0;
}
+int ext4fs_size(const char *filename)
+{
+ return ext4fs_open(filename);
+}
+
int ext4fs_read(char *buf, unsigned len)
{
if (ext4fs_root == NULL || ext4fs_file == NULL)
return sz >= 0;
}
+int fat_size(const char *filename)
+{
+ return do_fat_read_at(filename, 0, NULL, 0, LS_NO, 1);
+}
+
long file_fat_read_at(const char *filename, unsigned long pos, void *buffer,
unsigned long maxsize)
{
return 0;
}
+static inline int fs_size_unsupported(const char *filename)
+{
+ return -1;
+}
+
static inline int fs_read_unsupported(const char *filename, void *buf,
int offset, int len)
{
disk_partition_t *fs_partition);
int (*ls)(const char *dirname);
int (*exists)(const char *filename);
+ int (*size)(const char *filename);
int (*read)(const char *filename, void *buf, int offset, int len);
int (*write)(const char *filename, void *buf, int offset, int len);
void (*close)(void);
.close = fat_close,
.ls = file_fat_ls,
.exists = fat_exists,
+ .size = fat_size,
.read = fat_read_file,
.write = fs_write_unsupported,
},
.close = ext4fs_close,
.ls = ext4fs_ls,
.exists = ext4fs_exists,
+ .size = ext4fs_size,
.read = ext4_read_file,
.write = fs_write_unsupported,
},
.close = sandbox_fs_close,
.ls = sandbox_fs_ls,
.exists = sandbox_fs_exists,
+ .size = sandbox_fs_size,
.read = fs_read_sandbox,
.write = fs_write_sandbox,
},
.close = fs_close_unsupported,
.ls = fs_ls_unsupported,
.exists = fs_exists_unsupported,
+ .size = fs_size_unsupported,
.read = fs_read_unsupported,
.write = fs_write_unsupported,
},
return ret;
}
+int fs_size(const char *filename)
+{
+ int ret;
+
+ struct fstype_info *info = fs_get_info(fs_type);
+
+ ret = info->size(filename);
+
+ fs_close();
+
+ return ret;
+}
+
int fs_read(const char *filename, ulong addr, int offset, int len)
{
struct fstype_info *info = fs_get_info(fs_type);
return ret;
}
+int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
+ int fstype)
+{
+ int size;
+
+ if (argc != 4)
+ return CMD_RET_USAGE;
+
+ if (fs_set_blk_dev(argv[1], argv[2], fstype))
+ return 1;
+
+ size = fs_size(argv[3]);
+ if (size < 0)
+ return CMD_RET_FAILURE;
+
+ setenv_hex("filesize", size);
+
+ return 0;
+}
+
int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
int fstype)
{
return sz >= 0;
}
+int sandbox_fs_size(const char *filename)
+{
+ return os_get_filesize(filename);
+}
+
void sandbox_fs_close(void)
{
}
void ext4fs_reinit_global(void);
int ext4fs_ls(const char *dirname);
int ext4fs_exists(const char *filename);
+int ext4fs_size(const char *filename);
void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot);
int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf);
void ext4fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
int file_fat_detectfs(void);
int file_fat_ls(const char *dir);
int fat_exists(const char *filename);
+int fat_size(const char *filename);
long file_fat_read_at(const char *filename, unsigned long pos, void *buffer,
unsigned long maxsize);
long file_fat_read(const char *filename, void *buffer, unsigned long maxsize);
*/
int fs_exists(const char *filename);
+/*
+ * Determine a file's size
+ *
+ * Returns the file's size in bytes, or a negative value if it doesn't exist.
+ */
+int fs_size(const char *filename);
+
/*
* Read file "filename" from the partition previously set by fs_set_blk_dev(),
* to address "addr", starting at byte offset "offset", and reading "len"
* Common implementation for various filesystem commands, optionally limited
* to a specific filesystem type via the fstype parameter.
*/
+int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
+ int fstype);
int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
int fstype);
int do_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
void sandbox_fs_close(void);
int sandbox_fs_ls(const char *dirname);
int sandbox_fs_exists(const char *filename);
+int sandbox_fs_size(const char *filename);
int fs_read_sandbox(const char *filename, void *buf, int offset, int len);
int fs_write_sandbox(const char *filename, void *buf, int offset, int len);