printf("Block device %s %d not supported\n", argv[1], dev);
return 1;
}
- if (init_fs(ext4_dev_desc))
- return 1;
fs = get_fs();
if (*ep) {
file_size = simple_strtoul(argv[5], NULL, 10);
/* set the device as block device */
- part_length = ext4fs_set_blk_dev(fs->dev_desc, part);
+ part_length = ext4fs_set_blk_dev(ext4_dev_desc, part);
if (part_length == 0) {
printf("Bad partition - %s %d:%lu\n", argv[1], dev, part);
goto fail;
}
/* register the device and partition */
- if (ext4_register_device(fs->dev_desc, part) != 0) {
+ if (ext4_register_device(ext4_dev_desc, part) != 0) {
printf("Unable to use %s %d:%lu for fattable\n",
argv[1], dev, part);
goto fail;
}
/* get the partition information */
- if (!get_partition_info(fs->dev_desc, part, &info)) {
+ if (!get_partition_info(ext4_dev_desc, part, &info)) {
total_sector = (info.size * info.blksz) / SECTOR_SIZE;
fs->total_sect = total_sector;
} else {
goto fail;
}
ext4fs_close();
- deinit_fs(fs->dev_desc);
return 0;
fail:
ext4fs_close();
- deinit_fs(fs->dev_desc);
return 1;
}
ulong part_length;
int filelen;
disk_partition_t info;
- struct ext_filesystem *fs;
char buf[12];
unsigned long count;
const char *addr_str;
printf("** Block device %s %d not supported\n", argv[1], dev);
return 1;
}
- if (init_fs(ext4_dev_desc))
- return 1;
- fs = get_fs();
if (*ep) {
if (*ep != ':') {
puts("** Invalid boot device, use `dev[:part]' **\n");
}
if (part != 0) {
- if (get_partition_info(fs->dev_desc, part, &info)) {
+ if (get_partition_info(ext4_dev_desc, part, &info)) {
printf("** Bad partition %lu **\n", part);
goto fail;
}
filename, argv[1], dev);
}
- part_length = ext4fs_set_blk_dev(fs->dev_desc, part);
+ part_length = ext4fs_set_blk_dev(ext4_dev_desc, part);
if (part_length == 0) {
printf("**Bad partition - %s %d:%lu **\n", argv[1], dev, part);
ext4fs_close();
}
ext4fs_close();
- deinit_fs(fs->dev_desc);
/* Loading ok, update default load address */
load_addr = addr;
return 0;
fail:
- deinit_fs(fs->dev_desc);
return 1;
}
int dev;
unsigned long part = 1;
char *ep;
- struct ext_filesystem *fs;
int part_length;
if (argc < 3)
return cmd_usage(cmdtp);
return 1;
}
- if (init_fs(ext4_dev_desc))
- return 1;
-
- fs = get_fs();
if (*ep) {
if (*ep != ':') {
puts("\n** Invalid boot device, use `dev[:part]' **\n");
if (argc == 4)
filename = argv[3];
- part_length = ext4fs_set_blk_dev(fs->dev_desc, part);
+ part_length = ext4fs_set_blk_dev(ext4_dev_desc, part);
if (part_length == 0) {
printf("** Bad partition - %s %d:%lu **\n", argv[1], dev, part);
ext4fs_close();
};
ext4fs_close();
- deinit_fs(fs->dev_desc);
return 0;
fail:
- deinit_fs(fs->dev_desc);
return 1;
}
int ext4fs_symlinknest;
block_dev_desc_t *ext4_dev_desc;
+struct ext_filesystem ext_fs;
struct ext_filesystem *get_fs(void)
{
- if (ext4_dev_desc == NULL || ext4_dev_desc->priv == NULL)
- printf("Invalid Input Arguments %s\n", __func__);
-
- return ext4_dev_desc->priv;
-}
-
-int init_fs(block_dev_desc_t *dev_desc)
-{
- struct ext_filesystem *fs;
- if (dev_desc == NULL) {
- printf("Invalid Input Arguments %s\n", __func__);
- return -EINVAL;
- }
-
- fs = zalloc(sizeof(struct ext_filesystem));
- if (fs == NULL) {
- printf("malloc failed: %s\n", __func__);
- return -ENOMEM;
- }
-
- fs->dev_desc = dev_desc;
- dev_desc->priv = fs;
-
- return 0;
-}
-
-void deinit_fs(block_dev_desc_t *dev_desc)
-{
- if (dev_desc == NULL) {
- printf("Invalid Input Arguments %s\n", __func__);
- return;
- }
- free(dev_desc->priv);
- dev_desc->priv = NULL;
+ return &ext_fs;
}
void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot)
#endif
struct ext_filesystem *get_fs(void);
-int init_fs(block_dev_desc_t *dev_desc);
-void deinit_fs(block_dev_desc_t *dev_desc);
int ext4fs_open(const char *filename);
int ext4fs_read(char *buf, unsigned len);
int ext4fs_mount(unsigned part_length);
struct zfs_filesystem *zfsget_fs(void);
-int init_fs(block_dev_desc_t *dev_desc);
-void deinit_fs(block_dev_desc_t *dev_desc);
int zfs_open(zfs_file_t, const char *filename);
uint64_t zfs_read(zfs_file_t, char *buf, uint64_t len);
struct zfs_data *zfs_mount(device_t);