aboutsummaryrefslogtreecommitdiff
path: root/util-linux/volume_id/volume_id.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-02-15 05:51:19 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-02-15 05:51:19 +0000
commit28ea4298e380d73203890c0f42de68e9798396d8 (patch)
tree55c832fd42d8838f9d5f40d2b97bae93263e19e1 /util-linux/volume_id/volume_id.c
parent93b38208d1e7d759b3c8ed8e7eb91c10442033ff (diff)
downloadbusybox-w32-28ea4298e380d73203890c0f42de68e9798396d8.tar.gz
busybox-w32-28ea4298e380d73203890c0f42de68e9798396d8.tar.bz2
busybox-w32-28ea4298e380d73203890c0f42de68e9798396d8.zip
volume_id: abort early on read failures.
should help with probing missing fdd's
Diffstat (limited to 'util-linux/volume_id/volume_id.c')
-rw-r--r--util-linux/volume_id/volume_id.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/util-linux/volume_id/volume_id.c b/util-linux/volume_id/volume_id.c
index 6852a8203..1acd90596 100644
--- a/util-linux/volume_id/volume_id.c
+++ b/util-linux/volume_id/volume_id.c
@@ -45,8 +45,8 @@
45#define ENABLE_FEATURE_VOLUMEID_UFS 0 45#define ENABLE_FEATURE_VOLUMEID_UFS 0
46 46
47 47
48typedef int (*raid_probe_fptr)(struct volume_id *id, uint64_t off, uint64_t size); 48typedef int (*raid_probe_fptr)(struct volume_id *id, /*uint64_t off,*/ uint64_t size);
49typedef int (*probe_fptr)(struct volume_id *id, uint64_t off); 49typedef int (*probe_fptr)(struct volume_id *id /*, uint64_t off*/);
50 50
51static const raid_probe_fptr raid1[] = { 51static const raid_probe_fptr raid1[] = {
52#if ENABLE_FEATURE_VOLUMEID_LINUXRAID 52#if ENABLE_FEATURE_VOLUMEID_LINUXRAID
@@ -150,43 +150,49 @@ static const probe_fptr fs2[] = {
150#endif 150#endif
151}; 151};
152 152
153int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size) 153int volume_id_probe_all(struct volume_id *id, /*uint64_t off,*/ uint64_t size)
154{ 154{
155 unsigned i; 155 unsigned i;
156 156
157 if (id == NULL)
158 return -EINVAL;
159
160 /* probe for raid first, cause fs probes may be successful on raid members */ 157 /* probe for raid first, cause fs probes may be successful on raid members */
161 if (size) { 158 if (size) {
162 for (i = 0; i < ARRAY_SIZE(raid1); i++) 159 for (i = 0; i < ARRAY_SIZE(raid1); i++) {
163 if (raid1[i](id, off, size) == 0) 160 if (raid1[i](id, /*off,*/ size) == 0)
161 goto ret;
162 if (id->error)
164 goto ret; 163 goto ret;
164 }
165 } 165 }
166 166
167 for (i = 0; i < ARRAY_SIZE(raid2); i++) 167 for (i = 0; i < ARRAY_SIZE(raid2); i++) {
168 if (raid2[i](id, off) == 0) 168 if (raid2[i](id /*,off*/) == 0)
169 goto ret; 169 goto ret;
170 if (id->error)
171 goto ret;
172 }
170 173
171 /* signature in the first block, only small buffer needed */ 174 /* signature in the first block, only small buffer needed */
172 for (i = 0; i < ARRAY_SIZE(fs1); i++) 175 for (i = 0; i < ARRAY_SIZE(fs1); i++) {
173 if (fs1[i](id, off) == 0) 176 if (fs1[i](id /*,off*/) == 0)
174 goto ret; 177 goto ret;
178 if (id->error)
179 goto ret;
180 }
175 181
176 /* fill buffer with maximum */ 182 /* fill buffer with maximum */
177 volume_id_get_buffer(id, 0, SB_BUFFER_SIZE); 183 volume_id_get_buffer(id, 0, SB_BUFFER_SIZE);
178 184
179 for (i = 0; i < ARRAY_SIZE(fs2); i++) 185 for (i = 0; i < ARRAY_SIZE(fs2); i++) {
180 if (fs2[i](id, off) == 0) 186 if (fs2[i](id /*,off*/) == 0)
181 goto ret; 187 goto ret;
182 return -1; 188 if (id->error)
189 goto ret;
190 }
183 191
184 ret: 192 ret:
185 /* If the filestystem in recognized, we free the allocated buffers,
186 otherwise they will stay in place for the possible next probe call */
187 volume_id_free_buffer(id); 193 volume_id_free_buffer(id);
194 return (- id->error); /* 0 or -1 */
188 195
189 return 0;
190} 196}
191 197
192/* open volume by device node */ 198/* open volume by device node */