diff options
author | Florian Weimer <fweimer@redhat.com> | 2013-12-19 12:42:32 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-12-21 18:35:55 -0500 |
commit | bde1fdd773c5bc036370922e67ff3550a1f5cded (patch) | |
tree | 1872157206133be262de879d7ece32bf914faffe | |
parent | a2be63f9223ed1503ffc1e99bf21eee25e4ae014 (diff) |
journal: replace readdir_r with readdir
This commit also adds error handling for failures during
directory reading.
-rw-r--r-- | src/journal/sd-journal.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index bb116df047..283d593063 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -1442,10 +1442,16 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname) for (;;) { struct dirent *de; - union dirent_storage buf; - r = readdir_r(d, &buf.de, &de); - if (r != 0 || !de) + errno = 0; + de = readdir(d); + if (!de && errno != 0) { + r = -errno; + log_debug("Failed to read directory %s: %s", + m->path, strerror(errno)); + return r; + } + if (!de) break; if (dirent_is_file_with_suffix(de, ".journal") || @@ -1526,11 +1532,17 @@ static int add_root_directory(sd_journal *j, const char *p) { for (;;) { struct dirent *de; - union dirent_storage buf; sd_id128_t id; - r = readdir_r(d, &buf.de, &de); - if (r != 0 || !de) + errno = 0; + de = readdir(d); + if (!de && errno != 0) { + r = -errno; + log_debug("Failed to read directory %s: %s", + m->path, strerror(errno)); + return r; + } + if (!de) break; if (dirent_is_file_with_suffix(de, ".journal") || |