+struct fs_dir_stream *fs_opendir(const char *filename)
+{
+ struct fstype_info *info = fs_get_info(fs_type);
+ struct fs_dir_stream *dirs = NULL;
+ int ret;
+
+ ret = info->opendir(filename, &dirs);
+ fs_close();
+ if (ret) {
+ errno = -ret;
+ return NULL;
+ }
+
+ dirs->desc = fs_dev_desc;
+ dirs->part = fs_dev_part;
+
+ return dirs;
+}
+
+struct fs_dirent *fs_readdir(struct fs_dir_stream *dirs)
+{
+ struct fstype_info *info;
+ struct fs_dirent *dirent;
+ int ret;
+
+ fs_set_blk_dev_with_part(dirs->desc, dirs->part);
+ info = fs_get_info(fs_type);
+
+ ret = info->readdir(dirs, &dirent);
+ fs_close();
+ if (ret) {
+ errno = -ret;
+ return NULL;
+ }
+
+ return dirent;
+}
+
+void fs_closedir(struct fs_dir_stream *dirs)
+{
+ struct fstype_info *info;
+
+ if (!dirs)
+ return;
+
+ fs_set_blk_dev_with_part(dirs->desc, dirs->part);
+ info = fs_get_info(fs_type);
+
+ info->closedir(dirs);
+ fs_close();
+}
+
+
+int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
+ int fstype)
+{
+ loff_t size;
+
+ if (argc != 4)
+ return CMD_RET_USAGE;
+
+ if (fs_set_blk_dev(argv[1], argv[2], fstype))
+ return 1;
+
+ if (fs_size(argv[3], &size) < 0)
+ return CMD_RET_FAILURE;
+
+ env_set_hex("filesize", size);
+
+ return 0;
+}
+