diff options
author | Matthew Booth <mbooth@redhat.com> | 2009-08-06 14:14:18 +0100 |
---|---|---|
committer | Matthew Booth <mbooth@redhat.com> | 2009-08-06 14:36:08 +0100 |
commit | 2b8019e56cf40fe8e8223b4e57cfd590495e8e60 (patch) | |
tree | dae84e0b08347e12991cdcda28681fd0cd36c590 | |
parent | 5d78de834c53bfe29d2cc0397ac093428abe8425 (diff) | |
download | libguestfs-2b8019e56cf40fe8e8223b4e57cfd590495e8e60.tar.gz libguestfs-2b8019e56cf40fe8e8223b4e57cfd590495e8e60.tar.xz libguestfs-2b8019e56cf40fe8e8223b4e57cfd590495e8e60.zip |
Fix errno check in readdir in devsparts.c
-rw-r--r-- | daemon/devsparts.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/daemon/devsparts.c b/daemon/devsparts.c index b89682c9..e9c5e8f7 100644 --- a/daemon/devsparts.c +++ b/daemon/devsparts.c @@ -40,7 +40,6 @@ foreach_block_device (block_dev_func_t func) int size = 0, alloc = 0; DIR *dir; - struct dirent *d; int err = 0; dir = opendir ("/sys/block"); @@ -49,8 +48,11 @@ foreach_block_device (block_dev_func_t func) return NULL; } - errno = 0; - while ((d = readdir (dir)) != NULL) { + while(1) { + errno = 0; + struct dirent *d = readdir(dir); + if(NULL == d) break; + if (strncmp (d->d_name, "sd", 2) == 0 || strncmp (d->d_name, "hd", 2) == 0 || strncmp (d->d_name, "vd", 2) == 0 || |