{"id":806219,"url":"http://patchwork.ozlabs.org/api/1.0/patches/806219/?format=json","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.0/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<1503834382-19583-1-git-send-email-lukma@denx.de>","date":"2017-08-27T11:46:22","name":"[U-Boot] fix: fw_env: Prevent writing error message on special files, which don't support fsync","commit_ref":"40fe89c6e83791f1f9cd079d7d6b51598c4a5925","pull_url":null,"state":"accepted","archived":false,"hash":"1bb39030883bf39d3a790f962053bf08ed9e3f55","submitter":{"id":70701,"url":"http://patchwork.ozlabs.org/api/1.0/people/70701/?format=json","name":"Lukasz Majewski","email":"lukma@denx.de"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/1.0/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1503834382-19583-1-git-send-email-lukma@denx.de/mbox/","series":[{"id":12,"url":"http://patchwork.ozlabs.org/api/1.0/series/12/?format=json","date":"2017-08-27T11:46:22","name":"[U-Boot] fix: fw_env: Prevent writing error message on special files, which don't support fsync","version":1,"mbox":"http://patchwork.ozlabs.org/series/12/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806219/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xgCtp0L17z9s76\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 27 Aug 2017 21:52:17 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 6A6E0C22192; Sun, 27 Aug 2017 11:51:23 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id C6646C221A0;\n\tSun, 27 Aug 2017 11:51:19 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 8F100C2217C; Sun, 27 Aug 2017 11:51:06 +0000 (UTC)","from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9])\n\tby lists.denx.de (Postfix) with ESMTPS id C5B1FC221F6\n\tfor <u-boot@lists.denx.de>; Sun, 27 Aug 2017 11:46:49 +0000 (UTC)","from frontend01.mail.m-online.net (unknown [192.168.8.182])\n\tby mail-out.m-online.net (Postfix) with ESMTP id 3xgCmT3Hjxz1qqkr;\n\tSun, 27 Aug 2017 13:46:49 +0200 (CEST)","from localhost (dynscan1.mnet-online.de [192.168.6.70])\n\tby mail.m-online.net (Postfix) with ESMTP id 3xgCmT24vHz3jgYp;\n\tSun, 27 Aug 2017 13:46:49 +0200 (CEST)","from mail.mnet-online.de ([192.168.8.182])\n\tby localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new,\n\tport 10024)\n\twith ESMTP id 85iSmXdPU2MU; Sun, 27 Aug 2017 13:46:47 +0200 (CEST)","from localhost.localdomain (89-77-92-62.dynamic.chello.pl\n\t[89.77.92.62]) (using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mail.mnet-online.de (Postfix) with ESMTPSA;\n\tSun, 27 Aug 2017 13:46:47 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,\n\tRCVD_IN_MSPIKE_H3,\n\tRCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no\n\tversion=3.4.0","X-Virus-Scanned":"amavisd-new at mnet-online.de","X-Auth-Info":"JG/1KLCDUFGmN4ZfgnGa+kqWjvkrF+q+0tjCQsL4mZ4=","From":"Lukasz Majewski <lukma@denx.de>","To":"trini@konsulko.com","Date":"Sun, 27 Aug 2017 13:46:22 +0200","Message-Id":"<1503834382-19583-1-git-send-email-lukma@denx.de>","X-Mailer":"git-send-email 2.1.4","Cc":"Max Krummenacher <max.oss.09@gmail.com>, u-boot@lists.denx.de,\n\txypron.glpk@gmx.de","Subject":"[U-Boot] [PATCH] fix: fw_env: Prevent writing error message on\n\tspecial files, which don't support fsync","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"According to fsync specification [1] some special files (e.g., a pipe, FIFO,\nor socket) don't support synchronization and return either EROFS or EINVAL.\n\nOn the linux side the sys_fsync -> do_fsync() checks if the requested file\nhas f_op->fsync defined. If not it returns EINVAL [2].\n\nThis commit prevents writing error messages for files (devices), which\ndo not support fsync().\n\n[1] - http://man7.org/linux/man-pages/man2/fsync.2.html\n[2] - http://elixir.free-electrons.com/linux/v4.13-rc6/source/fs/sync.c#L183\n\nSigned-off-by: Lukasz Majewski <lukma@denx.de>\n---\n tools/env/fw_env.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)","diff":"diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c\nindex c9c79e0..ab7d85b 100644\n--- a/tools/env/fw_env.c\n+++ b/tools/env/fw_env.c\n@@ -1088,14 +1088,16 @@ static int flash_io (int mode)\n \n \t\trc = flash_write (fd_current, fd_target, dev_target);\n \n-\t\tif (fsync (fd_current)) {\n+\t\tif (fsync(fd_current) &&\n+\t\t    !(errno == EINVAL || errno == EROFS)) {\n \t\t\tfprintf (stderr,\n \t\t\t\t \"fsync failed on %s: %s\\n\",\n \t\t\t\t DEVNAME (dev_current), strerror (errno));\n \t\t}\n \n \t\tif (HaveRedundEnv) {\n-\t\t\tif (fsync (fd_target)) {\n+\t\t\tif (fsync(fd_target) &&\n+\t\t\t    !(errno == EINVAL || errno == EROFS)) {\n \t\t\t\tfprintf (stderr,\n \t\t\t\t\t \"fsync failed on %s: %s\\n\",\n \t\t\t\t\t DEVNAME (dev_current), strerror (errno));\n","prefixes":["U-Boot"]}