From: snitzer@sourceware.org <snitzer@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/lib/device dev-md.c device.c
Date: 1 Aug 2009 17:14:53 -0000 [thread overview]
Message-ID: <20090801171453.4548.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer at sourceware.org 2009-08-01 17:14:52
Modified files:
lib/device : dev-md.c device.c
Log message:
Fix error handling of device-related stat() calls to be ENOENT aware.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32
--- LVM2/lib/device/dev-md.c 2009/08/01 17:11:02 1.17
+++ LVM2/lib/device/dev-md.c 2009/08/01 17:14:52 1.18
@@ -151,7 +151,11 @@
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 */
ret = dm_snprintf(path, size, "%s/block/md%d/md/%s",
sysfs_dir, (int)MINOR(dev), attribute);
--- LVM2/lib/device/device.c 2009/08/01 17:11:02 1.31
+++ LVM2/lib/device/device.c 2009/08/01 17:14:52 1.32
@@ -304,8 +304,11 @@
return ret;
}
- if (stat(path, &info) < 0)
+ if (stat(path, &info) == -1) {
+ if (errno != ENOENT)
+ log_sys_error("stat", path);
return ret;
+ }
/*
* extract parent's path from the partition's symlink, e.g.:
@@ -326,8 +329,11 @@
}
/* finally, parse 'dev' attribute and create corresponding dev_t */
- if (stat(path, &info) < 0) {
- log_error("sysfs file %s does not exist", path);
+ if (stat(path, &info) == -1) {
+ if (errno == ENOENT)
+ log_error("sysfs file %s does not exist", path);
+ else
+ log_sys_error("stat", path);
return ret;
}
@@ -386,7 +392,11 @@
* - if not: either the kernel doesn't have topology support
* 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))
return 0;
@@ -397,8 +407,11 @@
log_error("primary dm_snprintf %s failed", attribute);
return 0;
}
- if (stat(path, &info) < 0)
+ if (stat(path, &info) == -1) {
+ if (errno != ENOENT)
+ log_sys_error("stat", path);
return 0;
+ }
}
if (!(fp = fopen(path, "r"))) {
reply other threads:[~2009-08-01 17:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090801171453.4548.qmail@sourceware.org \
--to=snitzer@sourceware.org \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.