fix: fw_env: Prevent writing error message on special files, which don't support fsync
PATCH 1/1 fix: fw_env: Prevent writing error message on special files, which don't support fsync
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
--- tools/env/fw_env.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/env/fw_env.c +4 -2
@@ -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));
Signature · 1 line
2.1.4
PATCH 1/1 fix: fw_env: Prevent writing error message on special files, which don't support fsync
Hi Lukasz,
Am Sonntag, 27. August 2017, 13:46:22 CEST schrieb Lukasz Majewski:
Quoted 22 lines
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 hasf_op->fsyncdefined. 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#L183Signed-off-by Lukasz Majewski <[email protected]>--- tools/env/fw_env.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/env/fw_env.c +0
-0
tools/env/fw_env.c static int flash_io (int mode) · line 1091
Quoted 5 lines
tools/env/fw_env.c +1
-1@@ -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) &&
nitpick: current coding style seems to be a single whitespace before the opening bracket
tools/env/fw_env.c static int flash_io (int mode) · line 1099
Quoted 9 lines
tools/env/fw_env.c +2
-1+ !(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) &&
dito
tools/env/fw_env.c static int flash_io (int mode) · line 1095
Quoted 4 lines
tools/env/fw_env.c +1
-0+ !(errno == EINVAL || errno == EROFS)) {fprintf (stderr,"fsync failed on %s: %s\n" ,DEVNAME (dev_current),strerror (errno));
Other than this nitpick:
Regards,
Michael
PATCH 1/1 fix: fw_env: Prevent writing error message on special files, which don't support fsync
Hi Michael,
Quoted 26 lines
Hi Lukasz,
Am Sonntag, 27. August 2017, 13:46:22 CEST schrieb Lukasz Majewski:
Quoted 23 lines
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 hasf_op->fsyncdefined. 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#L183Signed-off-by Lukasz Majewski <[email protected]>--- tools/env/fw_env.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/env/fw_env.c +0
-0@@ -1088,14 +1088,16 @@ static int flash_io (int mode)
Quoted 7 lines
tools/env/fw_env.c static int flash_io (int mode) · line 1091
Quoted 4 lines
tools/env/fw_env.c +1
-1rc =flash_write (fd_current, fd_target, dev_target); -if (fsync (fd_current)) { + if (fsync(fd_current) &&nitpick: current coding style seems to be a single whitespace before the opening bracket
I've run the patch through the ./scripts/checkpatch.pl and it was complaining about this space, so I've corrected it.
Does the fw_env.c use another coding style (not from the Linux kernel)?
Quoted 13 lines
tools/env/fw_env.c static int flash_io (int mode) · line 1099
Quoted 10 lines
tools/env/fw_env.c +2
-1+ !(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) &&dito
Quoted 8 lines
tools/env/fw_env.c static int flash_io (int mode) · line 1095
Quoted 4 lines
tools/env/fw_env.c +1
-0+ !(errno == EINVAL || errno == EROFS)) {fprintf (stderr,"fsync failed on %s: %s\n" ,DEVNAME (dev_current),strerror (errno));Other than this nitpick:
Acked-by Michael Heimpold <[email protected]>
Thanks :-)
Quoted 5 lines
Regards,
Michael
Signature · 9 lines
Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
PATCH 1/1 fix: fw_env: Prevent writing error message on special files, which don't support fsync
Quoted 36 lines · Å�ukasz Majewski
Hi Michael,
Quoted 26 lines
Hi Lukasz,
Am Sonntag, 27. August 2017, 13:46:22 CEST schrieb Lukasz Majewski:
Quoted 23 lines
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 hasf_op->fsyncdefined. 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#L183Signed-off-by Lukasz Majewski <[email protected]>---
tools/env/fw_env.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)tools/env/fw_env.c +0
-0@@ -1088,14 +1088,16 @@ static int flash_io (int mode)Quoted 7 lines
tools/env/fw_env.c static int flash_io (int mode) · line 1091
Quoted 4 lines
tools/env/fw_env.c +1
-1rc =flash_write (fd_current, fd_target, dev_target); -if (fsync (fd_current)) { + if (fsync(fd_current) &&nitpick: current coding style seems to be a single whitespace before the opening bracket
Quoted 4 lines
I've run the patch through the
./scripts/checkpatch.pland it was complaining about this space, so I've corrected it.Does the
fw_env.cuse another coding style (not from the Linux kernel)?
fw_env.c is another file that needs to be updated, stylistically to match the rest of U-Boot.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170827/113d581b/attachment.sig>
Quoted 6 lines · Lukasz Majewski
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 hasf_op->fsyncdefined. If not it returns EINVAL [2].
Quoted 8 lines
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#L183Signed-off-by Lukasz Majewski <[email protected]>Acked-by Michael Heimpold <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170903/d47dc28d/attachment.sig>