Question about kernel interfaces

Siddhartha De siddhartha.de87 at
Sat Feb 7 10:20:24 EST 2015

>(For bonus points, instead of EJECT, explain how you form a curl URL
>that does TCSETS. Yes, you *do* have to handle *all* the fields of a
>struct termios, for both 32 and 64 bit environments....)

I am new to termios programming so please correct me if I am wrong ...
I did a bit of googling and well here's a probable curl url and the
corresponding pseudocode that needs to be in our interpreter

curl http://localhost:7000/IOCTL/TCSETS2?file_descriptor=fd&cflag=something&ispeed=something&ospeed=something

And here's a little pseudocode for our interpreter :-

struct termios2 tio;
// ioctl(fd, TCGETS2, &tio);

// assuming get_from_url is a function which parses the incomming url
and returns the required parameters

cflag=get_from_url (cflag ) ;
ispeed = get_from_url ( ispeed ) ;

tio.c_cflag = cflag ;

tio.c_ispeed = ispeed;
tio.c_ospeed = ospeed;
ioctl(fd, TCSETS2, &tio);

Thanking you in anticipation ,

 Yours sincerely ,

  Kernel newbie

On Wed, Jan 21, 2015 at 11:14 PM, One Thousand Gnomes
<gnomes at> wrote:
> On Sun, 18 Jan 2015 15:03:55 +0530
>> Let's say you need to call an ioctl from a shell script ( I know its a
>> very rare use case but please bear with me ... :) )
>> So the current way of doing it is probably to write a C program which
>> actually calls the ioctl and then call the C program from the shell
>> script ...
> That's how Unix is designed yes. It means that the ioctl internals are
> hidden from the scripts and the tools provided can be used instead.
>> and the IOCTL_EJECT ioctl would get called on /dev/cdrom
>> that is ioctl ( &handle_to_/dev/cdrom , IOCTL_EJECT , &some_buffer )
>> would get called ( by our translator running as a separate program or
>> as a service daemon )
> You can just run "eject". It knows about all the details of doing an
> eject.
> The equivalent of a "library" in shell scripts is a program. Small,
> simple tools that do one job and do it right, or at least before GNU got
> hold of them 8)
> Alan

More information about the Kernelnewbies mailing list