]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: handle gracefully if fsync_full() is called on block devices and such 18864/head
authorLennart Poettering <lennart@poettering.net>
Fri, 26 Feb 2021 21:44:39 +0000 (22:44 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 3 Mar 2021 17:31:23 +0000 (18:31 +0100)
src/basic/fs-util.c

index 9423b9bf7ac0e7582c647bf3b7919dfb050070d2..48e5a96134b64c46e0a4b7dd5dc789d726a044a6 100644 (file)
@@ -1465,9 +1465,14 @@ int fsync_full(int fd) {
         /* Sync both the file and the directory */
 
         r = fsync(fd) < 0 ? -errno : 0;
-        q = fsync_directory_of_file(fd);
 
-        return r < 0 ? r : q;
+        q = fsync_directory_of_file(fd);
+        if (r < 0) /* Return earlier error */
+                return r;
+        if (q == -ENOTTY) /* Ignore if the 'fd' refers to a block device or so which doesn't really have a
+                           * parent dir */
+                return 0;
+        return q;
 }
 
 int fsync_path_at(int at_fd, const char *path) {