Of all the uses for ioctl(), that is probably the weakest one. The simplest solution is to have specialized calls to handle the terminal independent from stdin. You know, like how DOS does it, which might have been a big inspiration for someone called RDOS.kerravon wrote:How do you suggest switching stdin from line mode to character mode, so that I can use a full-screen application like a text editor?
No, I do agree that ioctl() is a pretty big wart, but I see no other way to solve the problems it solves (namely driver-specific requests for device files), without breaking up all those requests into their own system calls, which has its own warts.
That does not allow you to insert data. It allows you to overwrite data in the middle, but not insert it.kerravon wrote:You are presumably aware of the utility "dd".
The point I was trying to make is that every OS I am aware of only allows you to read and write in the middle or the end of a file, but not insert stuff. If you want to take an existing file and insert a new block some place in the middle, the only option you have is to create a new file, copy the data from the old file you want to keep, insert the new block, copy the tail of the file, then replace the old file with the new one. This is true on DOS, Windows, UNIX, OS-9, managarm, Fuchsia, and probably RDOS. I have yet to see anyone trying for an insert() system call. And for removal it is basically the same thing.
And indeed, that is how I would try to solve this problem, by adding a new system call that inserts new data at the current position, moving back the tail of the file. Or removes data at the current position, moving the tail of the file forward.
Can't say I'm a fan. It adds another special character that now cannot be used in file names anymore. This is a design limitation that will fall on your feet sooner or later. On Linux, the solution would have been to set up a loop device with a size limit, i.e. to create a new special device file that mirrors all the properties of the source file but has a smaller size. I think in this case the special problem requires a special solution rather than a general one.kerravon wrote:It is the ";" (semicolon) that separates the normal filename from the modifiers.