ioctl.h
Hi,
how do you use the ioctl.h? there seems to be little info on it on the web or in print. If you know of anything on the web please let me know.
thank you,
Mike
Quoted 9 lines · michael young
Hi,
how do you use theioctl.h? there seems to be little info on it on the web or in print. If you know of anything on the web please let me know.thank you,
Mike
Friday, March 04
ioctl is used for specific hardware control, it's use differs with each purpose. Could be rewinding tapes, opening your cd-rom player or set your serialport prefs.. Bit more info on what you want to accomplish ?
That said.. Each GNU/Linux system should have a ioctl_list somewhere in the manual page section. For example:
~: man -k ioctlioctl_list (2) - list of ioctl calls in Linux/i386 kernel
console ioctl (4) [console_ioctl] - ioctl's for console terminal and virtual consoles console ioctl's (4) [console_ioctls] - ioctl's for console terminal and virtual consolesconsole_ioctl (4) - ioctl's for console terminal and virtual consoles
.... etc..
~: man 2 ioctl_list
.......... BIG LIST .......
There should be enough IOCTL code on the www. search C and hardware control should return the most code I guess...
if((fd = open(dev, O_RDONLY|O_NONBLOCK)) == -1)
return -1;
if(ioctl(fd, CDROMEJECT) == -1)
return -1;
close(fd);
etc......
GoodLuck.. J.
hey Michael,
here just an example:
this small tool opens the cd tray
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/cdrom.h>
int main(){
int cdrom;
if ((cdrom = open("/dev/cdrom",O_RDONLY | O_NONBLOCK)) < 0) {
perror("open");
exit(1);
}
if (ioctl(cdrom,CDROMEJECT,0)<0) {
perror("ioctl");
exit(1);
}
close(cdrom);
return(0);
}simply build it with gcc tray.c -o tray
look at cdrom.h for more defined operations, you will also find CDROMEJECT in there, 0 is an argument see the manpage (man ioctl) for more infos..
Markus
Quoted 15 lines · michael young
Hi,
how do you use theioctl.h?
there seems to be little info on it
on the web or in print. If you know
of anything on the web please let me
know.thank you,
Mike-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
kool
thanks guys
i think can run with the info i have
Mike
Quoted 56 lines · Rechberger Markus
hey Michael,
here just an example:
this small tool opens the cd tray
#include <
sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/cdrom.h>int main(){ int cdrom; if ((cdrom = open("/dev/cdrom",O_RDONLY | O_NONBLOCK)) < 0) { perror("open"); exit(1); } if (ioctl(cdrom,CDROMEJECT,0)<0) { perror("ioctl"); exit(1); } close(cdrom); return(0); }simply build it with gcc
tray.c-o traylook at
cdrom.hfor more defined operations, you will also find CDROMEJECT in there, 0 is an argument see the manpage (man ioctl) for more infos..Markus
Quoted 17 lines · michael young
Hi,
how do you use theioctl.h?
there seems to be little info on it
on the web or in print. If you know
of anything on the web please let me
know.thank you,
Mike-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html