[H-GEN] [schoen at linuxcare.com: ioctl documentation]

Martin Pool mbp at linuxcare.com.au
Mon Sep 25 22:31:02 EDT 2000


----- Forwarded message from Seth David Schoen <schoen at linuxcare.com> -----

Date: Mon, 25 Sep 2000 19:08:06 -0700
From: Seth David Schoen <schoen at linuxcare.com>
Subject: ioctl documentation
User-Agent: Mutt/1.0.1i

An anonymous CSUA person was wondering how to simulate keyboard input
from software.  Someone pointed out the TIOCSTI ioctl.  The CSUA
person asked how to _use_ TIOCSTI.  So I figured it out and wrote some
sample code which makes the system think you typed "ls" on tty1.

OK, so a problem I noticed is that I couldn't find anywhere where
TIOCSTI was defined (in English, not with a #define) or described.  In
fact, even figuring out what the "STI" in "TIOCSTI" stands for
required somebody with FreeBSD sources (although there is a "Linux
ioctl list" on the net which gives the expansion).  (It's "Simulate
Terminal Input".)

In the discussion, I asserted that Linux terminal ioctls are extremely
undocumented.  As far as I've been able to tell, I was right to say
that, although some of the ioctls might be from POSIX or other Unix
standards.

So, is there any really good and comprehensive documentation for Linux
terminal ioctls, or Linux ioctls in general?  I don't consider the
ioctl list good enough, because it gives only ioctl names and argument
data types, without explaining why or how an ioctl would be used.

Is there good free documentation for standard Unix ioctls, outside
official standards documents (many of which are not free)?

I ask because, if there _isn't_ documentation for this, I might write
it.  It would be a good way to learn about ioctls. :-)


In case you're wondering how to use TIOCSTI, it's kind of like this:

#include <asm/ioctls.h>
#include <sys/types.h>
#include <fcntl.h>

void main(){

const char *foo = "ls\n";

int fd = open("/dev/tty1", O_RDWR);

/* only one character at a time; this would be easy to put into a loop */

printf("result = %i\n", ioctl(fd, TIOCSTI, foo+0));
printf("result = %i\n", ioctl(fd, TIOCSTI, foo+1));
printf("result = %i\n", ioctl(fd, TIOCSTI, foo+2));

/* a result of zero means the ioctl succeeds */

}


----- End forwarded message -----
-- 
Martin Pool, Linuxcare, Inc.
+61 2 6262 8990
mbp at linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20000926/6dfcf022/attachment.sig>


More information about the General mailing list