{"id":10843,"url":"https://patchwork.libcamera.org/api/1.1/patches/10843/?format=json","web_url":"https://patchwork.libcamera.org/patch/10843/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20210108170042.2849407-1-niklas.soderlund@ragnatech.se>","date":"2021-01-08T17:00:42","name":"[libcamera-devel] libcamera: sysfs: Fix directory exists check","commit_ref":"7415c139cd1cab73fdd91785a7816eab51e7a567","pull_url":null,"state":"accepted","archived":false,"hash":"420ad72a30120b20d26af1424a4d12f29c305e79","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":{"id":16,"url":"https://patchwork.libcamera.org/api/1.1/users/16/?format=json","username":"neg","first_name":"Niklas","last_name":"Söderlund","email":"niklas.soderlund@ragnatech.se"},"mbox":"https://patchwork.libcamera.org/patch/10843/mbox/","series":[{"id":1572,"url":"https://patchwork.libcamera.org/api/1.1/series/1572/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1572","date":"2021-01-08T17:00:42","name":"[libcamera-devel] libcamera: sysfs: Fix directory exists check","version":1,"mbox":"https://patchwork.libcamera.org/series/1572/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10843/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10843/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 2CD81C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 Jan 2021 17:01:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B8A1A68060;\n\tFri,  8 Jan 2021 18:01:21 +0100 (CET)","from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C29768056\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 Jan 2021 18:01:20 +0100 (CET)","from bismarck.berto.se (p4fca2458.dip0.t-ipconnect.de\n\t[79.202.36.88])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 0bdffa43-51d3-11eb-b73f-0050569116f7;\n\tFri, 08 Jan 2021 18:01:18 +0100 (CET)"],"X-Halon-ID":"0bdffa43-51d3-11eb-b73f-0050569116f7","Authorized-sender":"niklas.soderlund@fsdn.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  8 Jan 2021 18:00:42 +0100","Message-Id":"<20210108170042.2849407-1-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.30.0","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH] libcamera: sysfs: Fix directory exists\n\tcheck","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=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The scope of File::exists() was changed to only validate that a file\nexists and is therefore not usable to check if a directory exists. This\nbreaks the persistent name generation for DT based systems as it uses\nFile::exists() to check for directories, fix this by using stat()\ndirectly.\n\nOn Scarlet the persistent names of the cameras are impacted by this and\nwhere incorrectly reported as:\n\n    $ cam -l\n    Available cameras:\n    1: Internal front camera (platform/ff160000.i2c/i2c-7/7-003c ov2685)\n    2: Internal front camera (platform/ff160000.i2c/i2c-7/7-0036 ov5695\n\nWhile the expected ones are restored with this fix:\n\n    $ cam -l\n    Available cameras:\n    1: Internal front camera (/base/i2c@ff160000/camera@3c)\n    2: Internal front camera (/base/i2c@ff160000/camera@36)\n\nFixes: 8f4e16f014c820a0 (\"test: file: Check that directories are not treated as files\")\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/sysfs.cpp | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/sysfs.cpp b/src/libcamera/sysfs.cpp\nindex 3ebe66f8d69b61d4..e9004b2b59c8638d 100644\n--- a/src/libcamera/sysfs.cpp\n+++ b/src/libcamera/sysfs.cpp\n@@ -70,10 +70,11 @@ std::string charDevPath(const std::string &deviceNode)\n std::string firmwareNodePath(const std::string &device)\n {\n \tstd::string fwPath, node;\n+\tstruct stat st;\n \n \t/* Lookup for DT-based systems */\n \tnode = device + \"/of_node\";\n-\tif (File::exists(node)) {\n+\tif (!stat(node.c_str(), &st)) {\n \t\tchar *ofPath = realpath(node.c_str(), nullptr);\n \t\tif (!ofPath)\n \t\t\treturn {};\n","prefixes":["libcamera-devel"]}