Re: [PATCH RESEND libgpiod v2 10/18] dbus: add the API definitions
Bartosz Golaszewski <brgl-ARrdPY/[email protected]> Mon, 1 Jul 2024 10:40:39 +0200
| Newsgroups | gmane.comp.freedesktop.dbus,gmane.linux.kernel.gpio |
|---|---|
| Message-ID | <CAMRc=MctT4bQpCy+M=RRtAHM4Z7L1SjEq7Pm_N9TsjeKNir=6Q@mail.gmail.com> |
On Sun, Jun 30, 2024 at 6:49=E2=80=AFPM Thiago Macieira <[email protected]> wr= ote: > > On Friday 28 June 2024 11:58:29 GMT-7 Bartosz Golaszewski wrote: > > + <!-- > > + Used: > > + > > + True if line is busy. > > + > > + Line can be used by gpio-manager, another user-space process, a > > kernel + driver or is hogged. The exact reason a line is busy cann= ot > > be determined + from user-space unless it's known to be managed by > > gpio-manager (see: + the Managed property of this interface). > > + --> > > + <property name=3D'Used' type=3D'b' access=3D'read'/> > > What's the point of this property? It looks racy, as the user (whichever = it > is) can stop using it soon after a true read, or the line can become used > right after a false read? The latter could lead to TOCTOU problems. > It can be used to inspect the state of the line without requesting it for exclusive usage. Please take a look at how `gpiocli info` uses it (dbus/client/info.c). There's no reason we'd want to force any real action on the HW just to check if a line is busy. > Wouldn't it be better to force users to RequestLine and get an error if t= he > line is busy? Because if it wasn't busy, now the calling application know= s > nothing else can grab it. > No because the user may want to just inspect the state. It's not racy: if the user wants to request the line, they will do it right away and see an error if the line is busy. > Speaking of, RequestLine should document the errors it may return. > That could be said about all of the methods but the error messages returned on failures are quite descriptive and by looking at the many DBus .xml on my system I can tell it's not that common to have a list of all possible errors in the docs. Bart > -- > Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org > Principal Engineer - Intel DCAI Platform & System Engineering > > >