Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796141002; b=4CFe/4EtCttsM6QPAmlNH30KfBSFAP5PECb5Q5UooTMPOaOBOcUTTQPJQf8W78+pKclV BauDy5ddth88PHA6Bekn51ZfExjHtWlBOrOyxKy0GlPfRol3ECz3+2EWbryNXFJrSLTy9 jv/oYilstC0V7QQg8pArQYhRqyPr1eHPhB7qSTcKn7Ar+xtW0ahbfswFmvi2g5uTZYMCc OV6EEJN2uR67GcEWAu7np4U33gNNeligyYih7bZtYK3XfnZjV/DB74d7MWu4V91DbRf4i oP2662FEwoHs5LMHEwGhlNqv2ydzWIkGnKp908zyRILq9mKxEHqQhXOEUkfamLpOYCQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796141002; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg: X-Received:X-Received:Received:From:Subject:Date:Message-Id: MIME-Version:Content-Type:Content-Transfer-Encoding:X-B4-Tracking: X-Change-ID:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Authority-Analysis:X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=H030OqviX4sfHeTTr6O6UCozX4C2P8aEFMEsOb9bUSs=; b=I/OJyckeoT4U2p5reC9r5ZigJzLjWfEFWtDzQsDlDHxwK0tl6JMBA+f0/93QD83NzmFO xpgQV9rqcmAacnE2AcqoFSkwEeuBzpLg9Cih7OTjCtu9ZW7YyaJrC8LFQUf/jNiEZwRvD wNAwvl8vrtz+qu6E2iu9Ek/yOnpnQ3P4XBNgTDgq489vFSbaPT/B5sdQEysRbVer8x+cy UqVXKN57GPJy4QVqg5KME5k7Iq8N6mapNX1zVAYbGu5hdMNjrFy5KiCFPayziuBDCnduN lEZtPI71EcJEvL/1IIOdamMWyt4RHCqNOrBoQbXX6HutLQYAvVto/XEByRYaJszB9Mw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=TQmjzrEu; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b="alJU/gUb"; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A75A0606A320 for ; Tue, 1 Dec 2026 16:03:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A75A0606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=TQmjzrEu; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=alJU/gUb Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1F6mWW1575206 for ; Tue, 1 Dec 2026 16:03:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=H030OqviX4sfHeTTr6O6UC ozX4C2P8aEFMEsOb9bUSs=; b=TQmjzrEua4SrHezvxjZvDJKuBYTNDcrUlkOkoZ dSzn9CP0mcT/aWcVLloOtd3q8w93RE+mJgjhTdI1uSFbhn5VFb0er3sshrA4g1kh kn+dMv2Dd9eAhq8xrmXXCGszRnr5ya5i3zFBawShA5ls5e4qDFCFwgqNdm+SZ4D5 Fdme5Fyg3mnVtYC+fc/z+5oYE2Uz9fddtXLL52Ho9Oge4bnwIVzV4phGfbmNduJT BoHXshY8hJVIUBVLKWK5ZbucgkoI+HO2WrCBlRkBCswf6dySJzxD5afyFQoaQP+Q txFvb1x+ATPd0Vt65litl/2DIfqwov7DmE3Jt218LXeWGRoQ== Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9sa22944-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 16:03:17 +0000 (GMT) Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-71b793871dcso7178212eaf.2 for ; Tue, 01 Dec 2026 08:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796140997; x=1796745797; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=H030OqviX4sfHeTTr6O6UCozX4C2P8aEFMEsOb9bUSs=; b=alJU/gUbEyqC5sBX6d8FQXZDmu1R6h6G3I8i7WetyMSnYSWta6YEL1rh2ruQL5U8YC BgEUvPYLmp+EfQuwcsGA4CPXRXo3uRHHDFuT3ywTMFNWAoH2iqfvPoxykCZv5ozKvuRC IpGAn1kfITfRRkwgih7+VaP+i+lUnsVFAuVhicmfWcZY9fzlF5pYzADhUcWzBN/Ci4dQ Fcv/jAJ+o0bcl08XbAGyLLqDL+wGTZ72PsUCdZLY+pQWa4BbvcqmHhEmoYJK1uqklBgg tSWOx4xzYUTzUKpB6QrLyITfNvsTsvEfPAYDl7CJ4eqp9+86TYLWDCyzmLRWFAVE+gij 2SHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796140997; x=1796745797; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=H030OqviX4sfHeTTr6O6UCozX4C2P8aEFMEsOb9bUSs=; b=wbK+d2vnTwOFjoBRjv4MvGOzmeZFgP3nHe8CDTotQ93XwOrE4HxstsIZriZUcHoNtV 1bRMJYLY6nA+wDA/hMfR7oFCCW8Ov68yVDkAJfoyeT3DlyMLB9J+8q/DeqGB/Ssfkehw liAm+Fdc5Lpju93UzzIyb9D3eQs//oQXdWbmr5WSPWMxvexbl6cUjIHDm14S/apylBH4 xT5J54B6gh2XOLA4mXbJyCko+c8783l+zyrtmpUnIEf6rEHTRr4v1TH6kYV12JL3Nz2b jPuHT7jOvn5haMvlWBJ9eKDkDDaXQhytJHmFqogs6cWEIQkm2YjQhnbnDyfpAmEFWT6l 6onw== X-Gm-Message-State: APuU4Z98D1WfOl7HBiqLZZkRemkDfU22m71C7Az3L/RzXSFlSC3L+r5p FaGopLMy9t1ZPMKQ5vhZgWCi1G10Fhp5ybUHEv+kFWMi1xAYqZOsT3lVZufDqUvSuUlB/q4ELFs xxKkrseK/Og+boRKDBpiVKShytHBvDqygUv+f2dUxG05fGGjYG5amOT+9u7Ye4AMY X-Gm-Gg: AZFdTZc69mP70KfYVXPexJ0j0BrCb9cs/hPgz/7HR+sQYlU9GLXO2yOiR7WI8PVp4Sa TvnrXTa8u7eZ/GX30CA0hl+4CFCNbH5rvqSLNzXIPdAeAlsRI3uD0BEb+HN1SvM/kX3hUSpi+mE iFx39OMIo9VqCT4LJevKK3ae+O1IhEGCqlogkqvRIyfEc+n2fUx6FERm8raEAubZ2OotcjM+JFn s6/shQR+oBXwR927VnknzscWX8/tev4OZMTtFc1AGxQG8ObG/p7yCh+ZirPudSnMUW6gfrDbazA TsYSXoZmZNdYx7OHKsNA6ACLNpgX4B6eubLojxMSvvZg/HiCpiy/ZTfcAle626kIi9Ho5H/g08Y Mw6JlfpGcH9XxgVAFMcwFj2vYXr5KefiIHknBsf/LRPaLN9Nu6T8GU504AjtJXnNWOMnyMSi9Fj HHDCBn20eyKVoKKgbbv/CcrWum2LdVbSSlOkJPt2H9PiQtnLnExt0eVwvvbc4W9xc= X-Received: by 2002:a05:6820:16a4:b0:716:f300:648e with SMTP id 006d021491bc7-71b47e3a848mr28277185eaf.5.1796140996873; Tue, 01 Dec 2026 08:03:16 -0800 (PST) X-Received: by 2002:a05:6820:16a4:b0:716:f300:648e with SMTP id 006d021491bc7-71b47e3a848mr28277108eaf.5.1796140996182; Tue, 01 Dec 2026 08:03:16 -0800 (PST) Received: from brgl-qcom.local (2a01cb1d00dc7e0089167b9b97a26c96.ipv6.abo.wanadoo.fr. [2a01:cb1d:dc:7e00:8916:7b9b:97a2:6c96]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ad644140b5sm68163833f8f.17.2026.12.01.08.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 08:03:15 -0800 (PST) From: Bartosz Golaszewski Subject: [PATCH libgpiod v3 0/6] tools: new tool - gpioctl Date: Tue, 01 Dec 2026 17:03:07 +0100 Message-Id: <20261201-gpioctl-v3-0-569754d2229d@oss.qualcomm.com> X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIALvvDmsC/22NQQ6DIBBFr2JYFzNAANtV79F0AYJKomLBkjbGu 5eyqJtuJvn5/73ZULTB2Ygu1YaCTS46P+fAThVqBzX3FjuTM6JAOQEguF+cb9cRMyY4F1YC7Qz K6yXYzr2K6YZGp787g+65GVxcfXiXF4mUPtsEASJ+tkQw4EZKEJQKedbN1cdYP55qbP001fkUV aIHToAdOM04EQKUYkZbrv/g+75/AFUaKsbuAAAA X-Change-ID: 20251001-gpioctl-336556e702fd To: Linus Walleij , Kent Gibson , Vincent Fazio , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, brgl@kernel.org, Bartosz Golaszewski , Linus Walleij X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6293; i=bartosz.golaszewski@oss.qualcomm.com; h=from:subject:message-id; bh=Fur5b+HVbUYHku0Kc1gNVqZCKOLmjdGTrJBQ0zVZdSY=; b=owEBbQKS/ZANAwAKAQWdLsv/NoTDAcsmYgBrDu/B2kp3TcDQV8DEABzCjGzcLHeWnQL67Bm2u mK3KTpdq0WJAjMEAAEKAB0WIQSR5RMt5bVGHXuiZfwFnS7L/zaEwwUCaw7vwQAKCRAFnS7L/zaE w6XLD/43jUrSjPRlagbaupfdMsSNrdX75uQbhyWp7Qi6hUwaJte3L0ACHPx4u0h+bI2octlguJr 3IJE+B8+uw5dsztiraXhCOrF9lou1HLv2ht3wCpd2NlT3v0q89/ZgtZTEw30lFTmpcdBGMHkElq n6kZPsWVa/J49IlEV/M//czDYPIM7XJVOP9oX7/KUchL047Sil34gsn5JeQ19XyxMDetbIdQvgt Cim/cUEaGa4ojGQji//Mzv5G4gcsLpEHiQztaEKDM8a1AKrUnW+WybnGHP9ZzXWq+a9ADPzZSwA WV9Q/adYFLlQ0l/FHNdlyo9ZObbRT5fpooPx5rI+HVrQcQctDeHe1yyFqNbjqy9b9zZT7R7AWqQ SPdqWPsASiO8cwzMNkTg+dCwE1RPag1KnoI9gM8r3cEmgilCVNmwSdMhr1re2Ktiusxz3QJGnrx /6+Xc7BmdsZecE06bnucZQWlpDfHmJmNLZvtg2kBsibpdxSd8/JzGr/aXNb9Zs61TUY6fZ3tyil PRpme1MPPcQ7TgDC8QuTVcyAZ9HKnX0NrjvhXgbCwnX3rpPDM95Peh/n/7s8xd210TPXFuSBlv8 hQG/mg9hiLWCKGGfoqFajrLWsexM6fpgQhQB9YWH3oaODKLFB3FJ4dqP4FexcyrM4DFCI09zRf/ AJB0szwrmdOdkBA== X-Developer-Key: i=bartosz.golaszewski@oss.qualcomm.com; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 X-Authority-Analysis: v=2.4 cv=A8/5rKWG c=1 sm=1 tr=0 ts=6b0eefc5 cx=c_pps a=lkkFf9KBb43tY3aOjL++dA==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=bC-a23v3AAAA:8 a=EUspDBNiAAAA:8 a=fcSQwD6axeZBqIxWpxoA:9 a=QEXdDO2ut3YA:10 a=k4UEASGLJojhI9HsvVT1:22 a=FO4_E8m0qiDe52t0p3_H:22 X-Proofpoint-ORIG-GUID: vU_aoGRnWIhTxBVzEtdxCY82TpAvPks3 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA2MyBTYWx0ZWRfX+eVABvkTxJcF 7u9LIBQsAAsESDahmctk5Y0O5sY237086is43RZKWyvPA0lHCBgcuI5g0+snT704Zuh/P78sYPN xod/EY8h//WckqhszgO1TBWObnDGqZw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA2MyBTYWx0ZWRfX6SGI3n8aw63B qUiGy6uL3o5CICVSF4fVXvxbdqUZNqvB+EvhVSXfCIOk5sEonM8zmh0jlwsn6yiYoe6EDIn9f/3 n23YORaLSazAqgAZ9N0a4R+D0msJOyt9Goot6BSrRWv81bfatVVvqiCsvQcUTS/PBS/FD9e6/mw R54pLkLZxwUiWCFe02wPs8bb3R+ZEikf5YgumSNzTa9lfQv8D8jcHVDwj6kxu3XNZoynOa85ko5 Hniq9XXqpf48JY1wXHZ0iLIFWJXt1HbNCgWItYIQIJ64Q5uRwH7TkuqtKn0lTqHZe9dHXekfspM w3By8kvxYmV5crZZMZ3B/Q2vmYrxv321nK67wUt09cNUvSkVjTkN0/ie5atQGgBGMlbhrIkxhDP UTMLvNN2R9mLNG9LnEeMJCYdbritYw== X-Proofpoint-GUID: vU_aoGRnWIhTxBVzEtdxCY82TpAvPks3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_03,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010063 Provide gpioctl, a new command-line tool for persistent GPIO line control. Unlike gpioget and gpioset which release lines on exit, gpioctl holds requested lines in a background daemon so their state survives across multiple client invocations. Before adding the new program: move some code we'll reuse out of gpioset and gpiomon and into tools-common. I think this version is in relatively good shape and I plan to merge it soon and continue to iron it out in tree. Signed-off-by: Bartosz Golaszewski --- Changes in v3: - Factor out splitting of line=value arguments into a reusable function and use it in gpioctl - Fix parsing of line=value arguments: verify the count of line=value pairs and fix parsing of line names containing '=' - Actually use the list of headers required by tools in meson.build - Drop monitors whose request went away - Unlink the server listening socket before closing it - Use the EMFILE trick when out of descriptors - Don't inherit anything from the client spawning the server process - Reject arguments to stop, ping and debug - Fix the invalid message size test cases by checking if the emitted log is the correct one - Run the tool tests in their own network namespace - Gracefully handle closed standard descriptors on server startup - Make --by-name apply to get, set and monitor as well - Require direction setting for `gpioctl reconfigure` - More code reuse/unduplication - Fix typos - Don't ignore the return value of write() when reporting a server startup failure - Fix helptext formatting for help2man - Fix parsing of request IDs: don't use strtoul() which accepts blanks and signs - Pick up review tags - Link to v2: https://patch.msgid.link/20261103-gpioctl-v2-0-1660aa3dbe5b@oss.qualcomm.com Changes in v2: - Make the server startup more robust: use lockfiles to rule out races between multiple processes starting a server on the same socket - Add a "startup" pipe allowing the server to communicate errors to client before the server is fully set up and the connection established - Don't let slow clients block the server: drop a client that doesn't read data sent to it fast enough and make client sockets non-blocking - Make the default output of `gpioctl monitor` (without the --format option) match that of gpiomon - Set output values together with settings in build_line_config() instead of having these ops split into two far from one another - Fix an unnecessary double fetch of the request list from monitor_resolve() - Prefer "positive" tests first - Map reconfigured values to lines by name on the daemon side and ensure the ordering libgpiod requires for a correct reconfigure - Update loop variables inside the for () statement - Unify the range of supported event format specifiers across gpiomon and gpioctl - Reword the docs to make it clear that the daemon stays alive as long as there are any active GPIO requests or client connections - Make examples in docs better match the actual behavior of gpioctl (they were mostly written earlier with the behavior changed since) - Use a single counter variable in validate_request_opts() - Don't let the server die on SIGPIPE - Don't dispatch pending epoll events to receivers removed while processing the same batch - Abstract socket names are not owned by anyone so make sure to verify credentials and only talk to servers and clients of the same user - Fix regressions introduced by moving event formatting code to tools-common - Only sent as many bytes as are needed per message type, not a fixed, almost 4k byte message even for small amounts of data like edge events - Fix several memory leaks - fix parsing of the -F command-line option in `gpioctl monitor` - Use the right die() variants in the server-only code - Don't look up the user name just to print it in a log message as a call to getpwuid() may block on a NSS request for no reason or drop a valid client with no passwd entry - Add error checking when redirecting FDs when daemonizing the server - Reset optind consistently in sub-command parsers - Reject empty offsets in `gpioctl set` - Add meson tests for new headers and functions used in gpioctl - Fix parsing of line=value pairs for corner-cases, allow '=' in line names in shunit2 helper - Reject too many lines given by name - Refactor the code handling the printing of line events: use less positional arguments in favor of structs and unduplicate parts of the logic - Rework the gpioctl-test-helper program, add more functionalities - Many other small tweaks and fixes... - Link to v1: https://patch.msgid.link/20261016-gpioctl-v1-0-8770622679b8@oss.qualcomm.com --- Bartosz Golaszewski (6): tools: factor out line value parsing into tools-common tools: factor out line event formatting into tools-common tests: bash: allow '=' in line names in shunit2 helper tools: factor out splitting of line=value arguments tests: bash: provide a helper for disabling GPIO sim chips tools: implement gpioctl TODO | 14 - docs/.gitignore | 2 + docs/conf.py | 8 + docs/gpio_tools.rst | 11 +- docs/gpioctl_top.rst | 213 ++ man/meson.build | 39 + meson.build | 10 + tests/scripts/gpiod-bash-test-helper.inc | 13 +- tools/gpio-tools-test.bash | 2730 ++++++++++++++++++++++ tools/gpioctl-test-helper.c | 232 ++ tools/gpioctl.c | 3701 ++++++++++++++++++++++++++++++ tools/gpiomon.c | 128 +- tools/gpioset.c | 89 - tools/meson.build | 21 +- tools/tools-common.c | 263 ++- tools/tools-common.h | 26 + 16 files changed, 7268 insertions(+), 232 deletions(-) --- base-commit: b1071a55288d595a80709204a73932eb19a0a400 change-id: 20251001-gpioctl-336556e702fd Best regards, -- Bartosz Golaszewski