[LTP] [PATCH 1/3] ioctl01: Add default tty device

Richard Palethorpe rpalethorpe@suse.de
Mon Feb 13 17:08:02 CET 2023


Petr Vorel <pvorel@suse.cz> writes:

> Hi Li,
>
>> > +#define        DEFAULT_TTY_DEVICE      "/dev/tty0"
>
>> Hidden the device path parameter is a good idea.
>
>> But maybe can we add a function to find available char devices
>instead

There is already something like this built into the kernel; you can
create a PTY on demand with /dev/ptmx.

See the kernel/pty tests.

>> of using the tty0 as default? In that function, we do the S_ISCHR() check
>> and return the valid path of it. Then the rest test (e.g. ioctl02) can make
>> use of it but not set the specified device as well. WDYT?
>
> FYI I'm using S_ISCHR() in other patches, which check if device can be used.
> Implementing search looks like a good idea. Are useful files any /dev/tty*
> (including /dev/tty, /dev/ttyACM0, /dev/ttyS0) or should I avoid any file
> or include other paths?

These are real serial devices except /dev/tty which could be a real
device or a pty IIUC. Same goes for /dev/hvc[0-9] and possibly some
others.

I'm going to put the patch set to changes requested because /dev/tty0 is
the current virtual console. It seems the test just overwrites the
permissions and starts sending ioctls to it.

I don't know if this is safe and probably it's no different from
creating a pty.

>
> Kind regards,
> Petr


-- 
Thank you,
Richard.


More information about the ltp mailing list