mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Fix error handling of device-related stat() calls to be ENOENT aware.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
This commit is contained in:
parent
e92d56a94d
commit
098c16c9df
@ -151,7 +151,11 @@ check_md_major:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(path, &info) < 0) {
|
if (stat(path, &info) == -1) {
|
||||||
|
if (errno != ENOENT) {
|
||||||
|
log_sys_error("stat", path);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
/* old sysfs structure */
|
/* old sysfs structure */
|
||||||
ret = dm_snprintf(path, size, "%s/block/md%d/md/%s",
|
ret = dm_snprintf(path, size, "%s/block/md%d/md/%s",
|
||||||
sysfs_dir, (int)MINOR(dev), attribute);
|
sysfs_dir, (int)MINOR(dev), attribute);
|
||||||
|
@ -304,8 +304,11 @@ int get_primary_dev(const char *sysfs_dir,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(path, &info) < 0)
|
if (stat(path, &info) == -1) {
|
||||||
|
if (errno != ENOENT)
|
||||||
|
log_sys_error("stat", path);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* extract parent's path from the partition's symlink, e.g.:
|
* extract parent's path from the partition's symlink, e.g.:
|
||||||
@ -326,8 +329,11 @@ int get_primary_dev(const char *sysfs_dir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* finally, parse 'dev' attribute and create corresponding dev_t */
|
/* finally, parse 'dev' attribute and create corresponding dev_t */
|
||||||
if (stat(path, &info) < 0) {
|
if (stat(path, &info) == -1) {
|
||||||
log_error("sysfs file %s does not exist", path);
|
if (errno == ENOENT)
|
||||||
|
log_error("sysfs file %s does not exist", path);
|
||||||
|
else
|
||||||
|
log_sys_error("stat", path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +392,11 @@ static unsigned long _dev_topology_attribute(const char *attribute,
|
|||||||
* - if not: either the kernel doesn't have topology support
|
* - if not: either the kernel doesn't have topology support
|
||||||
* or the device could be a partition
|
* or the device could be a partition
|
||||||
*/
|
*/
|
||||||
if (stat(path, &info) < 0) {
|
if (stat(path, &info) == -1) {
|
||||||
|
if (errno != ENOENT) {
|
||||||
|
log_sys_error("stat", path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!get_primary_dev(sysfs_dir, dev, &primary))
|
if (!get_primary_dev(sysfs_dir, dev, &primary))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -397,8 +407,11 @@ static unsigned long _dev_topology_attribute(const char *attribute,
|
|||||||
log_error("primary dm_snprintf %s failed", attribute);
|
log_error("primary dm_snprintf %s failed", attribute);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (stat(path, &info) < 0)
|
if (stat(path, &info) == -1) {
|
||||||
|
if (errno != ENOENT)
|
||||||
|
log_sys_error("stat", path);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(fp = fopen(path, "r"))) {
|
if (!(fp = fopen(path, "r"))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user