diff options
author | Rob Herring | 2012-08-23 11:31:46 +0000 |
---|---|---|
committer | Tom Rini | 2012-09-25 14:46:55 -0700 |
commit | 81180819b842602f29f325298ee3e522beda3e0a (patch) | |
tree | 14c47ee7042a0e8b28f50c695d8b386f16cf6144 /fs/ext4 | |
parent | 945010629641b00cca95d1fed4f63009a2b4a113 (diff) |
cmd_extX: use common get_device_and_partition function
Convert ext2/4 load, ls, and write functions to use common device and
partition parsing function. With the common function "dev:part" can come
from the environment and a '-' can be used in that case.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/dev.c | 32 | ||||
-rw-r--r-- | fs/ext4/ext4_common.h | 1 | ||||
-rw-r--r-- | fs/ext4/ext4fs.c | 1 |
3 files changed, 13 insertions, 21 deletions
diff --git a/fs/ext4/dev.c b/fs/ext4/dev.c index 9e85228edac..1596a92b9ad 100644 --- a/fs/ext4/dev.c +++ b/fs/ext4/dev.c @@ -38,26 +38,20 @@ #include <common.h> #include <config.h> +#include <ext4fs.h> #include <ext_common.h> +unsigned long part_offset; + static block_dev_desc_t *ext4fs_block_dev_desc; -static disk_partition_t part_info; +static disk_partition_t *part_info; -int ext4fs_set_blk_dev(block_dev_desc_t *rbdd, int part) +void ext4fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info) { ext4fs_block_dev_desc = rbdd; - - if (part == 0) { - /* disk doesn't use partition table */ - part_info.start = 0; - part_info.size = rbdd->lba; - part_info.blksz = rbdd->blksz; - } else { - if (get_partition_info(ext4fs_block_dev_desc, - part, &part_info)) - return 0; - } - return part_info.size; + part_info = info; + part_offset = info->start; + get_fs()->total_sect = (info->size * info->blksz) / SECTOR_SIZE; } int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf) @@ -68,7 +62,7 @@ int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf) /* Check partition boundaries */ if ((sector < 0) || ((sector + ((byte_offset + byte_len - 1) >> SECTOR_BITS)) >= - part_info.size)) { + part_info->size)) { printf("%s read outside partition %d\n", __func__, sector); return 0; } @@ -88,7 +82,7 @@ int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf) /* read first part which isn't aligned with start of sector */ if (ext4fs_block_dev_desc-> block_read(ext4fs_block_dev_desc->dev, - part_info.start + sector, 1, + part_info->start + sector, 1, (unsigned long *) sec_buf) != 1) { printf(" ** ext2fs_devread() read error **\n"); return 0; @@ -111,14 +105,14 @@ int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf) block_len = SECTOR_SIZE; ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev, - part_info.start + sector, + part_info->start + sector, 1, (unsigned long *)p); memcpy(buf, p, byte_len); return 1; } if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev, - part_info.start + sector, + part_info->start + sector, block_len / SECTOR_SIZE, (unsigned long *) buf) != block_len / SECTOR_SIZE) { @@ -134,7 +128,7 @@ int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf) /* read rest of data which are not in whole sector */ if (ext4fs_block_dev_desc-> block_read(ext4fs_block_dev_desc->dev, - part_info.start + sector, 1, + part_info->start + sector, 1, (unsigned long *) sec_buf) != 1) { printf("* %s read error - last part\n", __func__); return 0; diff --git a/fs/ext4/ext4_common.h b/fs/ext4/ext4_common.h index 0af625db2ba..f7281341869 100644 --- a/fs/ext4/ext4_common.h +++ b/fs/ext4/ext4_common.h @@ -62,7 +62,6 @@ static inline void *zalloc(size_t size) return p; } -extern unsigned long part_offset; int ext4fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode); int ext4fs_read_file(struct ext2fs_node *node, int pos, diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index c366e6f0998..93dcb7e8fac 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -43,7 +43,6 @@ #include "ext4_common.h" int ext4fs_symlinknest; -block_dev_desc_t *ext4_dev_desc; struct ext_filesystem ext_fs; struct ext_filesystem *get_fs(void) |