diff options
author | Andrew Bartlett <abartlet@samba.org> | 2003-02-11 21:56:38 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2003-02-11 21:56:38 +0000 |
commit | b9ca0b9ef39442726afd580dc38b6dafce542335 (patch) | |
tree | 09b35d2dcb004c36b26f7cee3346e41faccc3c9c /source/modules | |
parent | 41894489e82a474f4f8f66aa2c7a117ed05b33e1 (diff) | |
download | samba-b9ca0b9ef39442726afd580dc38b6dafce542335.tar.gz samba-b9ca0b9ef39442726afd580dc38b6dafce542335.tar.xz samba-b9ca0b9ef39442726afd580dc38b6dafce542335.zip |
Merge from HEAD: Patch by Anthony Liguori <aliguor@us.ibm.com> to replace scandir() with portable readdir() calls.
Andrew Bartlett
Diffstat (limited to 'source/modules')
-rw-r--r-- | source/modules/vfs_netatalk.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/source/modules/vfs_netatalk.c b/source/modules/vfs_netatalk.c index c869922a4c7..b69a900e144 100644 --- a/source/modules/vfs_netatalk.c +++ b/source/modules/vfs_netatalk.c @@ -161,27 +161,26 @@ static void atalk_add_to_list(name_compare_entry **list) static void atalk_rrmdir(TALLOC_CTX *ctx, char *path) { - int n; char *dpath; - struct dirent **namelist; + struct dirent *dent = 0; + DIR *dir; if (!path) return; - n = scandir(path, &namelist, 0, alphasort); - if (n < 0) { - return; - } else { - while (n --) { - if (strcmp(namelist[n]->d_name, ".") == 0 || - strcmp(namelist[n]->d_name, "..") == 0) - continue; - if (!(dpath = talloc_asprintf(ctx, "%s/%s", - path, namelist[n]->d_name))) - continue; - atalk_unlink_file(dpath); - free(namelist[n]); - } + dir = opendir(path); + if (!dir) return; + + while (NULL != (dent = readdir(dir))) { + if (strcmp(dent->d_name, ".") == 0 || + strcmp(dent->d_name, "..") == 0) + continue; + if (!(dpath = talloc_asprintf(ctx, "%s/%s", + path, dent->d_name))) + continue; + atalk_unlink_file(dpath); } + + closedir(dir); } /* Disk operations */ |