diff options
author | Rob Herring | 2012-08-23 06:31:49 -0500 |
---|---|---|
committer | Tom Rini | 2012-09-25 16:49:17 -0500 |
commit | 412045704477a9b4d46b7e1fddbd53ec5dcde155 (patch) | |
tree | 2be3c498fd374bbef140f8359d439fd18dffc3a4 /fs | |
parent | 475c7970c18526adb406f8bc648c44255b300225 (diff) | |
download | u-boot-412045704477a9b4d46b7e1fddbd53ec5dcde155.tar.gz u-boot-412045704477a9b4d46b7e1fddbd53ec5dcde155.tar.xz u-boot-412045704477a9b4d46b7e1fddbd53ec5dcde155.zip |
cmd_zfs: use common get_device_and_partition function
Convert zfsload and zfsls 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')
-rw-r--r-- | fs/zfs/dev.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/fs/zfs/dev.c b/fs/zfs/dev.c index d68372c808..36be8f5c80 100644 --- a/fs/zfs/dev.c +++ b/fs/zfs/dev.c | |||
@@ -26,23 +26,12 @@ | |||
26 | #include <zfs_common.h> | 26 | #include <zfs_common.h> |
27 | 27 | ||
28 | static block_dev_desc_t *zfs_block_dev_desc; | 28 | static block_dev_desc_t *zfs_block_dev_desc; |
29 | static disk_partition_t part_info; | 29 | static disk_partition_t *part_info; |
30 | 30 | ||
31 | int zfs_set_blk_dev(block_dev_desc_t *rbdd, int part) | 31 | void zfs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info) |
32 | { | 32 | { |
33 | zfs_block_dev_desc = rbdd; | 33 | zfs_block_dev_desc = rbdd; |
34 | 34 | part_info = info; | |
35 | if (part == 0) { | ||
36 | /* disk doesn't use partition table */ | ||
37 | part_info.start = 0; | ||
38 | part_info.size = rbdd->lba; | ||
39 | part_info.blksz = rbdd->blksz; | ||
40 | } else { | ||
41 | if (get_partition_info(zfs_block_dev_desc, part, &part_info)) | ||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | return part_info.size; | ||
46 | } | 35 | } |
47 | 36 | ||
48 | /* err */ | 37 | /* err */ |
@@ -57,7 +46,7 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf) | |||
57 | */ | 46 | */ |
58 | if ((sector < 0) || | 47 | if ((sector < 0) || |
59 | ((sector + ((byte_offset + byte_len - 1) >> SECTOR_BITS)) >= | 48 | ((sector + ((byte_offset + byte_len - 1) >> SECTOR_BITS)) >= |
60 | part_info.size)) { | 49 | part_info->size)) { |
61 | /* errnum = ERR_OUTSIDE_PART; */ | 50 | /* errnum = ERR_OUTSIDE_PART; */ |
62 | printf(" ** zfs_devread() read outside partition sector %d\n", sector); | 51 | printf(" ** zfs_devread() read outside partition sector %d\n", sector); |
63 | return 1; | 52 | return 1; |
@@ -79,8 +68,8 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf) | |||
79 | if (byte_offset != 0) { | 68 | if (byte_offset != 0) { |
80 | /* read first part which isn't aligned with start of sector */ | 69 | /* read first part which isn't aligned with start of sector */ |
81 | if (zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev, | 70 | if (zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev, |
82 | part_info.start + sector, 1, | 71 | part_info->start + sector, 1, |
83 | (unsigned long *) sec_buf) != 1) { | 72 | (unsigned long *)sec_buf) != 1) { |
84 | printf(" ** zfs_devread() read error **\n"); | 73 | printf(" ** zfs_devread() read error **\n"); |
85 | return 1; | 74 | return 1; |
86 | } | 75 | } |
@@ -102,17 +91,15 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf) | |||
102 | 91 | ||
103 | block_len = SECTOR_SIZE; | 92 | block_len = SECTOR_SIZE; |
104 | zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev, | 93 | zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev, |
105 | part_info.start + sector, | 94 | part_info->start + sector, |
106 | 1, (unsigned long *)p); | 95 | 1, (unsigned long *)p); |
107 | memcpy(buf, p, byte_len); | 96 | memcpy(buf, p, byte_len); |
108 | return 0; | 97 | return 0; |
109 | } | 98 | } |
110 | 99 | ||
111 | if (zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev, | 100 | if (zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev, |
112 | part_info.start + sector, | 101 | part_info->start + sector, block_len / SECTOR_SIZE, |
113 | block_len / SECTOR_SIZE, | 102 | (unsigned long *) buf) != block_len / SECTOR_SIZE) { |
114 | (unsigned long *) buf) != | ||
115 | block_len / SECTOR_SIZE) { | ||
116 | printf(" ** zfs_devread() read error - block\n"); | 103 | printf(" ** zfs_devread() read error - block\n"); |
117 | return 1; | 104 | return 1; |
118 | } | 105 | } |
@@ -126,7 +113,7 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf) | |||
126 | /* read rest of data which are not in whole sector */ | 113 | /* read rest of data which are not in whole sector */ |
127 | if (zfs_block_dev_desc-> | 114 | if (zfs_block_dev_desc-> |
128 | block_read(zfs_block_dev_desc->dev, | 115 | block_read(zfs_block_dev_desc->dev, |
129 | part_info.start + sector, 1, | 116 | part_info->start + sector, 1, |
130 | (unsigned long *) sec_buf) != 1) { | 117 | (unsigned long *) sec_buf) != 1) { |
131 | printf(" ** zfs_devread() read error - last part\n"); | 118 | printf(" ** zfs_devread() read error - last part\n"); |
132 | return 1; | 119 | return 1; |