]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fix: fw_env: Prevent writing error message on special files, which don't support...
authorLukasz Majewski <lukma@denx.de>
Sun, 27 Aug 2017 11:46:22 +0000 (13:46 +0200)
committerTom Rini <trini@konsulko.com>
Sun, 3 Sep 2017 19:30:31 +0000 (15:30 -0400)
According to fsync specification [1] some special files (e.g., a pipe, FIFO,
or socket) don't support synchronization and return either EROFS or EINVAL.

On the linux side the sys_fsync -> do_fsync() checks if the requested file
has f_op->fsync defined. If not it returns EINVAL [2].

This commit prevents writing error messages for files (devices), which
do not support fsync().

[1] - http://man7.org/linux/man-pages/man2/fsync.2.html
[2] - http://elixir.free-electrons.com/linux/v4.13-rc6/source/fs/sync.c#L183

Signed-off-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Michael Heimpold <mhei@heimpold.de>
tools/env/fw_env.c

index e50c0755597dab5cf8aa392336e6fa146ad754e4..965e1662d702e7d1aa785bd090f5c3af7a62b248 100644 (file)
@@ -1088,14 +1088,16 @@ static int flash_io (int mode)
 
                rc = flash_write (fd_current, fd_target, dev_target);
 
-               if (fsync (fd_current)) {
+               if (fsync(fd_current) &&
+                   !(errno == EINVAL || errno == EROFS)) {
                        fprintf (stderr,
                                 "fsync failed on %s: %s\n",
                                 DEVNAME (dev_current), strerror (errno));
                }
 
                if (HaveRedundEnv) {
-                       if (fsync (fd_target)) {
+                       if (fsync(fd_target) &&
+                           !(errno == EINVAL || errno == EROFS)) {
                                fprintf (stderr,
                                         "fsync failed on %s: %s\n",
                                         DEVNAME (dev_current), strerror (errno));