diff options
author | Alasdair Kergon <agk@redhat.com> | 2004-08-18 18:50:21 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2004-08-18 18:50:21 +0000 |
commit | cf076dd3663e3f612dd3bde0cfe284afb4bab505 (patch) | |
tree | 11162a46520a17e6c34c7ea8056780513ac5e2f3 /lib | |
parent | 9bd40d31d7ffbd0102427904579352ee8a8512ef (diff) | |
download | lvm2-cf076dd3663e3f612dd3bde0cfe284afb4bab505.tar.gz |
Cope with DT_UNKNOWN in sysfs.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/filters/filter-sysfs.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c index a13bd29b2..a37f5c281 100644 --- a/lib/filters/filter-sysfs.c +++ b/lib/filters/filter-sysfs.c @@ -169,6 +169,8 @@ static int _read_devs(struct dev_set *ds, const char *dir) { struct dirent *d; DIR *dr; + unsigned char dtype; + struct stat info; char path[PATH_MAX]; dev_t dev; int r = 1; @@ -189,19 +191,29 @@ static int _read_devs(struct dev_set *ds, const char *dir) continue; } - if (d->d_type == DT_DIR) { + dtype = d->d_type; + + if (dtype == DT_UNKNOWN) { + if (stat(path, &info) >= 0) { + if (S_ISDIR(info.st_mode)) + dtype = DT_DIR; + else if (S_ISREG(info.st_mode)) + dtype = DT_REG; + } + } + + if (dtype == DT_DIR) { if (!_read_devs(ds, path)) { r = 0; break; } } - if ((d->d_type == DT_REG && !strcmp(d->d_name, "dev"))) + if ((dtype == DT_REG && !strcmp(d->d_name, "dev"))) if (!_read_dev(path, &dev) || !_set_insert(ds, dev)) { r = 0; break; } - } if (closedir(dr)) |