From: Lennart Poettering Date: Fri, 26 Feb 2021 21:44:39 +0000 (+0100) Subject: fs-util: handle gracefully if fsync_full() is called on block devices and such X-Git-Tag: v248-rc3~71^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F18864%2Fhead;p=thirdparty%2Fsystemd.git fs-util: handle gracefully if fsync_full() is called on block devices and such --- diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 9423b9bf7ac..48e5a96134b 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -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) {