]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/journal/sd-journal.c
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / journal / sd-journal.c
index 7e1fda85964b3a68d4bc3c1a406e7b63cd1a05c6..f96d898b2df40ae0a973f3b1b38098b62854c6ba 100644 (file)
@@ -3,19 +3,6 @@
   This file is part of systemd.
 
   Copyright 2011 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
 #include <errno.h>
@@ -1303,14 +1290,10 @@ static int add_any_file(
                 r = log_debug_errno(errno, "Failed to fstat file '%s': %m", path);
                 goto finish;
         }
-        if (S_ISDIR(st.st_mode)) {
-                log_debug("Uh, file '%s' is a directory? Refusing.", path);
-                r = -EISDIR;
-                goto finish;
-        }
-        if (!S_ISREG(st.st_mode)) {
-                log_debug("Uh, file '%s' is not a regular file? Refusing.", path);
-                r = -EBADFD;
+
+        r = stat_verify_regular(&st);
+        if (r < 0) {
+                log_debug_errno(r, "Refusing to open '%s', as it is not a regular file.", path);
                 goto finish;
         }
 
@@ -1341,7 +1324,7 @@ static int add_any_file(
                 goto finish;
         }
 
-        r = journal_file_open(fd, path, O_RDONLY, 0, false, false, NULL, j->mmap, NULL, NULL, &f);
+        r = journal_file_open(fd, path, O_RDONLY, 0, false, 0, false, NULL, j->mmap, NULL, NULL, &f);
         if (r < 0) {
                 log_debug_errno(r, "Failed to open journal file %s: %m", path);
                 goto finish;
@@ -2074,14 +2057,9 @@ _public_ int sd_journal_open_files_fd(sd_journal **ret, int fds[], unsigned n_fd
                         goto fail;
                 }
 
-                if (S_ISDIR(st.st_mode)) {
-                        r = -EISDIR;
-                        goto fail;
-                }
-                if (!S_ISREG(st.st_mode)) {
-                        r = -EBADFD;
+                r = stat_verify_regular(&st);
+                if (r < 0)
                         goto fail;
-                }
 
                 r = add_any_file(j, fds[i], NULL);
                 if (r < 0)