Yes, for example if I want to set the serial device baud rate(TCSETS),
should I open it with O_WRONLY?

Linux has the concept of read IOCTLs and write IOCTLs as determined by the IOCTL macros.  My understanding is that you much provide O_RDONLY or O_RDWR to use the read IOCTLs and O_WRONLY or O_RDWR to use the write IOCTLs.

But I am not sure of that and there are a lot of things I don't fully understand.  I have seen references to some mysterious Bit 3 in the open flags that can be used open IOCTL-only drivers.  Like https://github.com/NoHomey/open-ioctl:

   "Opens device file in non-blocking ioctl mode. File is opend with
   flags 3 | O_NONBLOCK.

   "Flag 3 means that only ioctl calls can be made for comunication
   with the device driver (remember read/write operations are expensive
   this is why open-ioctl was made in first place to make it easer for
   performance and command oriented device drivers)."

My gut feeling is that these things are too non-standard and poorly thought out to be useful.

Reply via email to