summaryrefslogtreecommitdiff
path: root/util-linux/volume_id/volume_id.c
diff options
context:
space:
mode:
authorDenis Vlasenko2009-02-15 05:51:19 +0000
committerDenis Vlasenko2009-02-15 05:51:19 +0000
commit28ea4298e380d73203890c0f42de68e9798396d8 (patch)
tree55c832fd42d8838f9d5f40d2b97bae93263e19e1 /util-linux/volume_id/volume_id.c
parent93b38208d1e7d759b3c8ed8e7eb91c10442033ff (diff)
downloadbusybox-28ea4298e380d73203890c0f42de68e9798396d8.zip
busybox-28ea4298e380d73203890c0f42de68e9798396d8.tar.gz
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 6852a82..1acd905 100644
--- a/util-linux/volume_id/volume_id.c
+++ b/util-linux/volume_id/volume_id.c
@@ -45,8 +45,8 @@
#define ENABLE_FEATURE_VOLUMEID_UFS 0
-typedef int (*raid_probe_fptr)(struct volume_id *id, uint64_t off, uint64_t size);
-typedef int (*probe_fptr)(struct volume_id *id, uint64_t off);
+typedef int (*raid_probe_fptr)(struct volume_id *id, /*uint64_t off,*/ uint64_t size);
+typedef int (*probe_fptr)(struct volume_id *id /*, uint64_t off*/);
static const raid_probe_fptr raid1[] = {
#if ENABLE_FEATURE_VOLUMEID_LINUXRAID
@@ -150,43 +150,49 @@ static const probe_fptr fs2[] = {
#endif
};
-int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
+int volume_id_probe_all(struct volume_id *id, /*uint64_t off,*/ uint64_t size)
{
unsigned i;
- if (id == NULL)
- return -EINVAL;
-
/* probe for raid first, cause fs probes may be successful on raid members */
if (size) {
- for (i = 0; i < ARRAY_SIZE(raid1); i++)
- if (raid1[i](id, off, size) == 0)
+ for (i = 0; i < ARRAY_SIZE(raid1); i++) {
+ if (raid1[i](id, /*off,*/ size) == 0)
+ goto ret;
+ if (id->error)
goto ret;
+ }
}
- for (i = 0; i < ARRAY_SIZE(raid2); i++)
- if (raid2[i](id, off) == 0)
+ for (i = 0; i < ARRAY_SIZE(raid2); i++) {
+ if (raid2[i](id /*,off*/) == 0)
goto ret;
+ if (id->error)
+ goto ret;
+ }
/* signature in the first block, only small buffer needed */
- for (i = 0; i < ARRAY_SIZE(fs1); i++)
- if (fs1[i](id, off) == 0)
+ for (i = 0; i < ARRAY_SIZE(fs1); i++) {
+ if (fs1[i](id /*,off*/) == 0)
goto ret;
+ if (id->error)
+ goto ret;
+ }
/* fill buffer with maximum */
volume_id_get_buffer(id, 0, SB_BUFFER_SIZE);
- for (i = 0; i < ARRAY_SIZE(fs2); i++)
- if (fs2[i](id, off) == 0)
+ for (i = 0; i < ARRAY_SIZE(fs2); i++) {
+ if (fs2[i](id /*,off*/) == 0)
goto ret;
- return -1;
+ if (id->error)
+ goto ret;
+ }
ret:
- /* If the filestystem in recognized, we free the allocated buffers,
- otherwise they will stay in place for the possible next probe call */
volume_id_free_buffer(id);
+ return (- id->error); /* 0 or -1 */
- return 0;
}
/* open volume by device node */