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

Petr Vorel pvorel@suse.cz
Tue Feb 14 00:25:38 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.

Thanks for a tip! According to man ptmx(4) the file /dev/ptmx creates
pseudoterminal (PTYs) in /dev/pts directory (e.g. /dev/pts/0).

> >> 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?
BTW /dev/ttySN are UART serial port TTY (it was familiar to me, although I
nowadays use /dev/ttyUSB0 :)).

> 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.

Sure.

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

Kernel doc [1] mentions more about the devices. I suppose it does not
matter for ioctl01 purpose, which TTY device we use, so I'll use
your suggestion.

Kind regards,
Petr

[1] https://www.kernel.org/doc/html/latest/admin-guide/devices.html

> > Kind regards,
> > Petr


More information about the ltp mailing list