Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1261749
  • 博文数量: 548
  • 博客积分: 7597
  • 博客等级: 少将
  • 技术积分: 4224
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-15 13:21
个人简介

嵌入式软件工程师&&太极拳

文章分类

全部博文(548)

文章存档

2014年(10)

2013年(76)

2012年(175)

2011年(287)

6.c

分类: LINUX

2011-03-05 21:20:34

  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>

  4. #include <sys/ioctl.h>
  5. #include <linux/cdrom.h>

  6. int main(void)
  7. {
  8.     int fd, ret;

  9.     fd = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
  10.     if (fd == -1)
  11.     {
  12.         perror("open");
  13.         return -1;
  14.     }

  15.     ret = ioctl(fd, CDROMEJECT);
  16.     if (ret == -1)
  17.     {
  18.         perror("ioctl");
  19.         return -1;
  20.     }

  21.     close(fd);

  22.     return 0;
  23. }
阅读(553) | 评论(0) | 转发(0) |
0

上一篇:5.c

下一篇:7.c

给主人留下些什么吧!~~