[求助]ioctl控制光驱命令
一个简单的控制光盘退出程序:
7L^6L{&B2vq6U6p0RS9\L'@-@
#include <unistd.h>
w3|0N+] Ay[q(O//closewww.linuxeden.comn:`m&oD+u{I~{f
#include <sys/types.h>
X5~R2Z@GD#include <sys/stat.h>9jS)U"xALT,\
#include <fcntl.h>
N7e"~m0W^@;~hLinux伊甸园论坛//open()
C`g5]:I
E q#include <stdio.h>
)u Uw5^]
@ h+f8G!af//perror()Linux伊甸园论坛&d4wK6uv;a9]4A
#include <stdlib.h>
5p)SJ ew%E#include <sys/ioctl.h>
nH&~/L{+|,x
iKLinux伊甸园论坛S\+Z&fs l^
#define DEVICE "/dev/cdrom",{7wi6F{!I
6sr5`TN:lrBP
int main()1gN+|pJ%J(@
{
[+Je:W DR int fd;Linux伊甸园论坛l7@(s,[k*~1k*f&M
int status;
Hx;e/[4Y"r:g
T3co'|em //打开设备
[L*] \A0pI(Y fd =open (DEVICE, O_RDONLY|O_NONBLOCK);
4P,Z@q d+zLinux伊甸园论坛 if(fd<0) {J_*I,p8j3z
perror("unable to open" DEVICE);
0nYZ+{1c9fr/` exit(1); |