From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4564 invoked by alias); 1 Aug 2009 17:14:53 -0000 Received: (qmail 4550 invoked by uid 9805); 1 Aug 2009 17:14:53 -0000 Date: Sat, 01 Aug 2009 17:14:00 -0000 Message-ID: <20090801171453.4548.qmail@sourceware.org> From: snitzer@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/lib/device dev-md.c device.c Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00004.txt.bz2 CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: snitzer@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 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"))) {