📄 eject.c
字号:
/* * 代码清单1: eject.c */#include <unistd.h>#include <stdlib.h>#include <fcntl.h>#include <sys/ioctl.h>#include <linux/cdrom.h>/* CD驱动器对应的设备文件 */#define DEVICE "/dev/cdrom"int main() { int fd; int status; /* 打开设备 */ fd = open(DEVICE, O_RDONLY); if (fd < 0) { perror("unable to open " DEVICE); exit(1); } /* 退出光盘 */ status = ioctl(fd, CDROMEJECT); if (status != 0) { perror("CDROMEJECT ioctl failed"); exit(1); } /* 关闭设备 */ status = close(fd); if (status != 0) { perror("unable to close " DEVICE); exit(1); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -