{"id":8748,"url":"https://patchwork.libcamera.org/api/patches/8748/?format=json","web_url":"https://patchwork.libcamera.org/patch/8748/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200712144419.21457-4-laurent.pinchart@ideasonboard.com>","date":"2020-07-12T14:44:19","name":"[libcamera-devel,4/4] libcamera: file: Create the file on open() if it doesn't exist","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"2ab703fdc607bc3fa7d73ce07908495a0b9b88a1","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8748/mbox/","series":[{"id":1098,"url":"https://patchwork.libcamera.org/api/series/1098/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1098","date":"2020-07-12T14:44:16","name":"[libcamera-devel,1/4] libcamera: file: Add read/write support","version":1,"mbox":"https://patchwork.libcamera.org/series/1098/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8748/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8748/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9293ABDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 12 Jul 2020 14:44:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 00217605A9;\n\tSun, 12 Jul 2020 16:44:49 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 76F2660553\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 12 Jul 2020 16:44:46 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 19162514\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 12 Jul 2020 16:44:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"m38qBXQT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594565086;\n\tbh=P8w89z8xbNHDF349DY+fLiUMnmCNQQdr8/6RU2YdgfY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=m38qBXQTtW08hPA3IljWpZU242PdgVFOs+IC2UTactlbhEgHQykD//EJnk6DV3dAl\n\tH0oQQsltVBhi5NdjHGp7Cj+Fz2XKvqUL5MKAhCsWfBvnug7r+F90zp5xvF6OdG477s\n\tE/+wR658AEuh0I6088GezhGpRBTDYXZm3XCGnGu0=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 12 Jul 2020 17:44:19 +0300","Message-Id":"<20200712144419.21457-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200712144419.21457-1-laurent.pinchart@ideasonboard.com>","References":"<20200712144419.21457-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 4/4] libcamera: file: Create the file on\n\topen() if it doesn't exist","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"When a file is opened in WriteOnly or ReadWrite mode, create it if it\ndoesn't exist.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/file.cpp | 9 ++++++---\n 1 file changed, 6 insertions(+), 3 deletions(-)","diff":"diff --git a/src/libcamera/file.cpp b/src/libcamera/file.cpp\nindex 8bd109090919..77701666e438 100644\n--- a/src/libcamera/file.cpp\n+++ b/src/libcamera/file.cpp\n@@ -148,8 +148,9 @@ bool File::exists() const\n  * \\param[in] mode The open mode\n  *\n  * This function opens the file specified by fileName() in \\a mode. If the file\n- * doesn't exist and the mode is WriteOnly or ReadWrite, this\n- * function will attempt to create the file.\n+ * doesn't exist and the mode is WriteOnly or ReadWrite, this function will\n+ * attempt to create the file with initial permissions set to 0666 (modified by\n+ * the process' umask).\n  *\n  * The error() status is updated.\n  *\n@@ -163,8 +164,10 @@ bool File::open(File::OpenMode mode)\n \t}\n \n \tint flags = (mode & ReadWrite) - 1;\n+\tif (mode & WriteOnly)\n+\t\tflags |= O_CREAT;\n \n-\tfd_ = ::open(name_.c_str(), flags);\n+\tfd_ = ::open(name_.c_str(), flags, 0666);\n \tif (fd_ < 0) {\n \t\terror_ = -errno;\n \t\treturn false;\n","prefixes":["libcamera-devel","4/4"]}