master - coverity: use wider type for whole expression
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=447daa9179d94f...
Commit: 447daa9179d94f86a972598e42eaab8b6913f3f7
Parent: edcb3e65c6398d4c4c70812b8209c8400c374099
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 22 00:14:40 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Apr 22 01:12:34 2016 +0200
coverity: use wider type for whole expression
Coverity likes when the types are same through the whole expression.
And since dev_t is 64b - widen int type early.
---
lib/device/dev-cache.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 7a124d0..06d44ce 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -491,7 +491,7 @@ static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *dev
return NULL;
}
- devno = MKDEV(major, minor);
+ devno = MKDEV((dev_t)major, (dev_t)minor);
if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devno))) {
/*
* If we get here, it means the device is referenced in sysfs, but it's not yet in /dev.
@@ -851,7 +851,7 @@ static int _dev_cache_iterate_sysfs_for_index(const char *path)
continue;
}
- devno = MKDEV(major, minor);
+ devno = MKDEV((dev_t)major, (dev_t)minor);
if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devno)) &&
!(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) devno))) {
if (!dm_device_get_name(major, minor, 1, devname, sizeof(devname)) ||
6 years, 11 months
master - coverity: drop unused header file
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=edcb3e65c6398d...
Commit: edcb3e65c6398d4c4c70812b8209c8400c374099
Parent: 99e96f3ce9d14e30b7150d3d4614cf9ab810e264
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 21 20:20:13 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Apr 22 01:12:34 2016 +0200
coverity: drop unused header file
---
lib/notify/lvmnotify.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/lib/notify/lvmnotify.c b/lib/notify/lvmnotify.c
index 3bcf5ae..afad93b 100644
--- a/lib/notify/lvmnotify.c
+++ b/lib/notify/lvmnotify.c
@@ -10,7 +10,6 @@
#include "lib.h"
#include "toolcontext.h"
-#include "metadata.h"
#include "lvmnotify.h"
#define LVM_DBUS_DESTINATION "com.redhat.lvmdbus1"
6 years, 11 months
master - coverity: fix error paths
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=99e96f3ce9d14e...
Commit: 99e96f3ce9d14e30b7150d3d4614cf9ab810e264
Parent: cbf99be43a70e872b5040ffa0193a8f4961a7068
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 21 20:19:24 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Apr 22 01:12:34 2016 +0200
coverity: fix error paths
Patch 74e704bb4465960b361711c890733cbae1f06e42 missed to update
error path. Since now we just need to 'return_0' as 'dmt is NULL
and thus may not be destroyed.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ffc83f5..d088560 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.151 -
=================================
+ Fix error path after reusing of _setup_task (2.02.150).
Fix memory access for empty sysfs values (2.02.149).
Disable lvmetad when lvm1 metadata is seen, so commands revert to scanning.
Suppress errors when snapshot merge gets delayed because volume is in use.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 5b1e226..c07af2d 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -381,7 +381,7 @@ static int _device_is_suspended(int major, int minor)
if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_INFO,
major, minor, 0)))
- goto_out;
+ return_0;
if (!dm_task_run(dmt) ||
!dm_task_get_info(dmt, &info)) {
@@ -406,7 +406,7 @@ static int _ignore_suspended_snapshot_component(struct device *dev)
if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_TABLE,
MAJOR(dev->dev), MINOR(dev->dev), 0)))
- goto_out;
+ return_0;
if (!dm_task_run(dmt)) {
log_error("Failed to get state of snapshot or snapshot origin device");
@@ -529,7 +529,7 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_STATUS,
MAJOR(dev->dev), MINOR(dev->dev), 0)))
- goto_out;
+ return_0;
/* Non-blocking status read */
if (!dm_task_no_flush(dmt))
6 years, 11 months
master - coverity: fix memory access
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cbf99be43a70e8...
Commit: cbf99be43a70e872b5040ffa0193a8f4961a7068
Parent: 556eba183520821e6fb709253e3e12ba48a5fcdf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 21 20:21:59 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Apr 22 01:11:57 2016 +0200
coverity: fix memory access
Commit 52e0d0db4460d90172e9bd45b9ef30e7f4f75ae7 introduced regression
as code may access buf[0 - 1].
Reorder code to first remove '\n' and then check buffer size for
empty.
---
WHATS_NEW | 1 +
lib/device/dev-cache.c | 16 ++++++----------
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1e47c20..ffc83f5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.151 -
=================================
+ Fix memory access for empty sysfs values (2.02.149).
Disable lvmetad when lvm1 metadata is seen, so commands revert to scanning.
Suppress errors when snapshot merge gets delayed because volume is in use.
Avoid internal snapshot LV names in messages.
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index b5f2152..7a124d0 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -379,17 +379,13 @@ static int _get_sysfs_value(const char *path, char *buf, size_t buf_size, int er
goto out;
}
- if (!(len = strlen(buf)) || (len == 1 && buf[0] == '\n')) {
- if (error_if_no_value) {
- log_error("_get_sysfs_value: %s: no value", path);
- goto out;
- }
- }
+ if ((len = strlen(buf)) && buf[len - 1] == '\n')
+ buf[--len] = '\0';
- if (buf[len - 1] == '\n')
- buf[len - 1] = '\0';
-
- r = 1;
+ if (!len && error_if_no_value)
+ log_error("_get_sysfs_value: %s: no value", path);
+ else
+ r = 1;
out:
if (fclose(fp))
log_sys_error("fclose", path);
6 years, 11 months
master - cleanup: use kdev_t header in lvm tree
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=556eba18352082...
Commit: 556eba183520821e6fb709253e3e12ba48a5fcdf
Parent: 9d4f9defc31f0459f91979909a0c94bbb87af9c0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 21 20:52:12 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Apr 22 00:23:28 2016 +0200
cleanup: use kdev_t header in lvm tree
Reuse libdm header in lvm so we have single definition
of MAJOR/MINOR/MKDEV macros in use.
---
lib/device/dev-type.h | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/lib/device/dev-type.h b/lib/device/dev-type.h
index 5494511..6438b44 100644
--- a/lib/device/dev-type.h
+++ b/lib/device/dev-type.h
@@ -21,9 +21,7 @@
#define NUMBER_OF_MAJORS 4096
#ifdef __linux__
-# define MAJOR(dev) (((dev) & 0xfff00) >> 8)
-# define MINOR(dev) (((dev) & 0xff) | (((dev) >> 12) & 0xfff00))
-# define MKDEV(ma,mi) (((mi) & 0xff) | ((ma) << 8) | (((mi) & ~0xff) << 12))
+# include "kdev_t.h"
#else
# define MAJOR(x) major((x))
# define MINOR(x) minor((x))
6 years, 11 months
master - cleanup: simplify code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9d4f9defc31f04...
Commit: 9d4f9defc31f0459f91979909a0c94bbb87af9c0
Parent: c9373a0c2ad42d51db6036fc506b9369264d29e6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 21 20:19:53 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Apr 22 00:22:02 2016 +0200
cleanup: simplify code
dm_strncpy() also check the size fits.
---
lib/locking/file_locking.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index a8d041a..230303b 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.c
@@ -148,13 +148,11 @@ int init_file_locking(struct locking_type *locking, struct cmd_context *cmd,
/* Get lockfile directory from config file */
locking_dir = find_config_tree_str(cmd, global_locking_dir_CFG, NULL);
- if (strlen(locking_dir) >= sizeof(_lock_dir)) {
+ if (!dm_strncpy(_lock_dir, locking_dir, sizeof(_lock_dir))) {
log_error("Path for locking_dir %s is invalid.", locking_dir);
return 0;
}
- strcpy(_lock_dir, locking_dir);
-
(void) dm_prepare_selinux_context(_lock_dir, S_IFDIR);
r = dm_create_dir(_lock_dir);
(void) dm_prepare_selinux_context(NULL, 0);
6 years, 11 months
master - WHATS_NEW: disable lvmetad for lvm1
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c9373a0c2ad42d...
Commit: c9373a0c2ad42d51db6036fc506b9369264d29e6
Parent: 01181a299eb26121c963895e3443105eca1e1c60
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 21 16:40:44 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Apr 21 16:40:44 2016 -0500
WHATS_NEW: disable lvmetad for lvm1
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9c15797..1e47c20 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.151 -
=================================
+ Disable lvmetad when lvm1 metadata is seen, so commands revert to scanning.
Suppress errors when snapshot merge gets delayed because volume is in use.
Avoid internal snapshot LV names in messages.
Autodetect and use /run/lock dir when available instead of /var/lock.
6 years, 11 months
master - activate: Hide errors when snapshot merge delayed.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=01181a299eb261...
Commit: 01181a299eb26121c963895e3443105eca1e1c60
Parent: 4d095c2fbb4383fc4830b9b714f8a7fd45b40fcd
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Apr 21 22:14:10 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Apr 21 22:14:10 2016 +0100
activate: Hide errors when snapshot merge delayed.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 29 ++++++++++++++++++++---------
lib/activate/activate.h | 2 +-
lib/metadata/lv_manip.c | 2 +-
tools/lvchange.c | 2 +-
tools/lvconvert.c | 10 +++++-----
tools/vgchange.c | 2 +-
7 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 65fefa1..9c15797 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.151 -
=================================
+ Suppress errors when snapshot merge gets delayed because volume is in use.
Avoid internal snapshot LV names in messages.
Autodetect and use /run/lock dir when available instead of /var/lock.
lvchange --refresh for merging thin origin will retry to deactivate snapshot.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index ac547ce..76afc3d 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -763,7 +763,8 @@ int lv_info_with_seg_status(struct cmd_context *cmd, const struct logical_volume
#define OPEN_COUNT_CHECK_RETRIES 25
#define OPEN_COUNT_CHECK_USLEEP_DELAY 200000
-int lv_check_not_in_use(const struct logical_volume *lv)
+/* Only report error if error_if_used is set */
+int lv_check_not_in_use(const struct logical_volume *lv, int error_if_used)
{
struct lvinfo info;
unsigned int open_count_check_retries;
@@ -774,14 +775,22 @@ int lv_check_not_in_use(const struct logical_volume *lv)
/* If sysfs is not used, use open_count information only. */
if (dm_sysfs_dir()) {
if (dm_device_has_holders(info.major, info.minor)) {
- log_error("Logical volume %s is used by another device.",
- display_lvname(lv));
+ if (error_if_used)
+ log_error("Logical volume %s is used by another device.",
+ display_lvname(lv));
+ else
+ log_debug_activation("Logical volume %s is used by another device.",
+ display_lvname(lv));
return 0;
}
if (dm_device_has_mounted_fs(info.major, info.minor)) {
- log_error("Logical volume %s contains a filesystem in use.",
- display_lvname(lv));
+ if (error_if_used)
+ log_error("Logical volume %s contains a filesystem in use.",
+ display_lvname(lv));
+ else
+ log_debug_activation("Logical volume %s contains a filesystem in use.",
+ display_lvname(lv));
return 0;
}
}
@@ -789,8 +798,10 @@ int lv_check_not_in_use(const struct logical_volume *lv)
open_count_check_retries = retry_deactivation() ? OPEN_COUNT_CHECK_RETRIES : 1;
while (info.open_count > 0 && open_count_check_retries--) {
if (!open_count_check_retries) {
- log_error("Logical volume %s in use.",
- display_lvname(lv));
+ if (error_if_used)
+ log_error("Logical volume %s in use.", display_lvname(lv));
+ else
+ log_debug_activation("Logical volume %s in use.", display_lvname(lv));
return 0;
}
@@ -2118,7 +2129,7 @@ static int _lv_has_open_snapshots(const struct logical_volume *lv)
int r = 0;
dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs, origin_list)
- if (!lv_check_not_in_use(snap_seg->cow))
+ if (!lv_check_not_in_use(snap_seg->cow, 1))
r++;
if (r)
@@ -2172,7 +2183,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logi
if (lv_is_visible(lv) || lv_is_virtual_origin(lv) ||
lv_is_merging_thin_snapshot(lv)) {
- if (!lv_check_not_in_use(lv))
+ if (!lv_check_not_in_use(lv, 1))
goto_out;
if (lv_is_origin(lv) && _lv_has_open_snapshots(lv))
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 880689c..089355d 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -147,7 +147,7 @@ int lv_info_with_seg_status(struct cmd_context *cmd, const struct logical_volume
struct lv_with_info_and_seg_status *status,
int with_open_count, int with_read_ahead);
-int lv_check_not_in_use(const struct logical_volume *lv);
+int lv_check_not_in_use(const struct logical_volume *lv, int error_if_used);
/*
* Returns 1 if activate_lv has been set: 1 = activate; 0 = don't.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 1baf548..4bce808 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5802,7 +5802,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
if (!lv_is_cache_pool(lv) && /* cache pool cannot be active */
lv_is_active(lv)) {
- if (!lv_check_not_in_use(lv))
+ if (!lv_check_not_in_use(lv, 1))
return_0;
if ((force == PROMPT) &&
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 3a050e9..631d7f8 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -344,7 +344,7 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
}
if (lv_is_active_locally(lv)) {
- if (!lv_check_not_in_use(lv)) {
+ if (!lv_check_not_in_use(lv, 1)) {
log_error("Can't resync open logical volume \"%s\"",
lv->name);
return 0;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index f7a3df6..c544e36 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1876,7 +1876,7 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
}
if (lv_is_active_locally(cow)) {
- if (!lv_check_not_in_use(cow))
+ if (!lv_check_not_in_use(cow, 1))
return_0;
if ((lp->force == PROMPT) && !lp->yes &&
@@ -2232,11 +2232,11 @@ static int _lvconvert_merge_old_snapshot(struct cmd_context *cmd,
* being open.
*/
if (lv_is_active_locally(origin)) {
- if (!lv_check_not_in_use(origin)) {
- log_print_unless_silent("Can't merge over open origin volume.");
+ if (!lv_check_not_in_use(origin, 0)) {
+ log_print_unless_silent("Can't merge until origin volume is closed.");
merge_on_activate = 1;
- } else if (!lv_check_not_in_use(lv)) {
- log_print_unless_silent("Can't merge when snapshot is open.");
+ } else if (!lv_check_not_in_use(lv, 0)) {
+ log_print_unless_silent("Can't merge until snapshot is closed.");
merge_on_activate = 1;
}
} else if (vg_is_clustered(origin->vg) && lv_is_active(origin)) {
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 372f881..49c64b9 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -219,7 +219,7 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
if (!do_activate && (lv_open = lvs_in_vg_opened(vg))) {
dm_list_iterate_items(lvl, &vg->lvs)
if (lv_is_visible(lvl->lv) &&
- !lv_check_not_in_use(lvl->lv)) {
+ !lv_check_not_in_use(lvl->lv, 1)) {
log_error("Can't deactivate volume group \"%s\" with %d open "
"logical volume(s)", vg->name, lv_open);
return 0;
6 years, 11 months
master - poll daemon: only call lvmetad_connect when needed
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4d095c2fbb4383...
Commit: 4d095c2fbb4383fc4830b9b714f8a7fd45b40fcd
Parent: 11dd36245450ed664c4a6bd177f17a8077c820a1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 21 15:58:34 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Apr 21 15:58:34 2016 -0500
poll daemon: only call lvmetad_connect when needed
When lvm is not using lvmetad, the lvmetad_connect()
in the forked polling process is not needed and was
generating unwanted warnings.
---
tools/polldaemon.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index c2211d7..6b15a0d 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -597,7 +597,7 @@ static int _poll_daemon(struct cmd_context *cmd, struct poll_operation_id *id,
/* FIXME Use wait_event (i.e. interval = 0) and */
/* fork one daemon per copy? */
- if (daemon_mode == 1) {
+ if ((daemon_mode == 1) && find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
if (!lvmetad_connect(cmd))
log_warn("WARNING: lvm polling process %d cannot connect to lvmetad.", getpid());
}
6 years, 11 months
master - tests: GLIBC decided to obsolete readdir_r
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=11dd36245450ed...
Commit: 11dd36245450ed664c4a6bd177f17a8077c820a1
Parent: 1134ab63240de66850c30fe1576bbb8b4f3e7052
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 21 15:30:14 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 21 17:48:19 2016 +0200
tests: GLIBC decided to obsolete readdir_r
Keep the code compilatible without warnings on newer glibc.
---
test/lib/brick-shelltest.h | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/test/lib/brick-shelltest.h b/test/lib/brick-shelltest.h
index be7c3fe..b48253b 100644
--- a/test/lib/brick-shelltest.h
+++ b/test/lib/brick-shelltest.h
@@ -122,11 +122,17 @@ inline Listing listdir( std::string p, bool recurse = false, std::string prefix
Listing r;
dir d( p );
+#if !defined(__GLIBC__) || (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 23))
+ /* readdir_r is deprecated with newer GLIBC */
struct dirent entry, *iter = 0;
- int readerr;
-
- while ( (readerr = readdir_r( d.d, &entry, &iter )) == 0 && iter ) {
+ while ( (errno = readdir_r( d.d, &entry, &iter )) == 0 && iter ) {
std::string ename( entry.d_name );
+#else
+ struct dirent *entry;
+ errno = 0;
+ while ( (entry = readdir( d.d )) ) {
+ std::string ename( entry->d_name );
+#endif
if ( ename == "." || ename == ".." )
continue;
@@ -134,8 +140,10 @@ inline Listing listdir( std::string p, bool recurse = false, std::string prefix
if ( recurse ) {
struct stat64 stat;
std::string s = p + "/" + ename;
- if ( ::stat64( s.c_str(), &stat ) == -1 )
+ if ( ::stat64( s.c_str(), &stat ) == -1 ) {
+ errno = 0;
continue;
+ }
if ( S_ISDIR(stat.st_mode) ) {
Listing sl = listdir( s, true, prefix + ename + "/" );
for ( Listing::iterator i = sl.begin(); i != sl.end(); ++i )
@@ -146,7 +154,7 @@ inline Listing listdir( std::string p, bool recurse = false, std::string prefix
r.push_back( ename );
};
- if ( readerr != 0 )
+ if ( errno != 0 )
throw syserr( "error reading directory", p );
return r;
6 years, 11 months