chiark / gitweb /
util-lib: make verbose_mount() grok MS_MOVE
[elogind.git] / src / basic / fs-util.c
index be4c6a9faf41343f46a710ea827b33edfc18b0b1..05f10c86f827a9c9f86aa73794f8f014dddf6138 100644 (file)
@@ -17,7 +17,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <dirent.h>
 #include <errno.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -450,6 +449,7 @@ int mkfifo_atomic(const char *path, mode_t mode) {
 
 int get_files_in_directory(const char *path, char ***list) {
         _cleanup_closedir_ DIR *d = NULL;
+        struct dirent *de;
         size_t bufsize = 0, n = 0;
         _cleanup_strv_free_ char **l = NULL;
 
@@ -463,16 +463,7 @@ int get_files_in_directory(const char *path, char ***list) {
         if (!d)
                 return -errno;
 
-        for (;;) {
-                struct dirent *de;
-
-                errno = 0;
-                de = readdir(d);
-                if (!de && errno > 0)
-                        return -errno;
-                if (!de)
-                        break;
-
+        FOREACH_DIRENT_ALL(de, d, return -errno) {
                 dirent_ensure_type(d, de);
 
                 if (!dirent_is_file(de))
@@ -716,10 +707,10 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
                 if (child < 0) {
 
                         if (errno == ENOENT &&
-                            (flags & CHASE_NON_EXISTING) &&
+                            (flags & CHASE_NONEXISTENT) &&
                             (isempty(todo) || path_is_safe(todo))) {
 
-                                /* If CHASE_NON_EXISTING is set, and the path does not exist, then that's OK, return
+                                /* If CHASE_NONEXISTENT is set, and the path does not exist, then that's OK, return
                                  * what we got so far. But don't allow this if the remaining path contains "../ or "./"
                                  * or something else weird. */