[systemd-commits] 2 commits - src/shared src/tmpfiles

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Tue May 5 21:12:38 PDT 2015


 src/shared/utmp-wtmp.h  |    2 +-
 src/tmpfiles/tmpfiles.c |   13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

New commits:
commit f44b28fda0a9ac88b0b20c475fc1d2f2036e7f71
Author: Michael Olbrich <m.olbrich at pengutronix.de>
Date:   Thu Apr 30 20:50:38 2015 +0200

    tmpfiles: try to handle read-only file systems gracefully
    
    On read-only filesystems trying to create the target will not fail with
    EEXIST but with EROFS. Handle EROFS by checking if the target already
    exists, and if empty when truncating.
    This avoids reporting errors if tmpfiles doesn't actually needs to do
    anything.
    
    [zj: revert condition to whitelist rather then blacklisting, and add goto
    to avoid stat'ting twice.]

diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index d574254..640ad47 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -984,8 +984,12 @@ static int write_one_file(Item *i, const char *path) {
                         return 0;
                 }
 
-                log_error_errno(errno, "Failed to create file %s: %m", path);
-                return -errno;
+                r = -errno;
+                if (!i->argument && errno == EROFS && stat(path, &st) == 0 &&
+                    (i->type == CREATE_FILE || st.st_size == 0))
+                        goto check_mode;
+
+                return log_error_errno(r, "Failed to create file %s: %m", path);
         }
 
         if (i->argument) {
@@ -1012,6 +1016,7 @@ static int write_one_file(Item *i, const char *path) {
         if (stat(path, &st) < 0)
                 return log_error_errno(errno, "stat(%s) failed: %m", path);
 
+ check_mode:
         if (!S_ISREG(st.st_mode)) {
                 log_error("%s is not a file.", path);
                 return -EEXIST;
@@ -1154,6 +1159,10 @@ static int create_item(Item *i) {
 
                 log_debug("Copying tree \"%s\" to \"%s\".", resolved, i->path);
                 r = copy_tree(resolved, i->path, false);
+
+                if (r == -EROFS && stat(i->path, &st) == 0)
+                        r = -EEXIST;
+
                 if (r < 0) {
                         struct stat a, b;
 

commit 3e7f33ada92ccc9da96b2b1c9af1f123d09ad954
Author: Michael Olbrich <m.olbrich at pengutronix.de>
Date:   Thu Apr 30 20:28:37 2015 +0200

    shared/utmp-wtmp: fix copy/paste error

diff --git a/src/shared/utmp-wtmp.h b/src/shared/utmp-wtmp.h
index 6ac2c7b..5d26ba6 100644
--- a/src/shared/utmp-wtmp.h
+++ b/src/shared/utmp-wtmp.h
@@ -65,7 +65,7 @@ static inline int utmp_wall(
                 const char *username,
                 const char *origin_tty,
                 bool (*match_tty)(const char *tty, void *userdata),
-                void *userdata);
+                void *userdata) {
         return 0;
 }
 



More information about the systemd-commits mailing list