首页 > 系统服务 > 详细

Linux下弹出和收回光驱

时间:2015-07-14 15:52:14      阅读:224      评论:0      收藏:0      [点我收藏+]

弹出光驱     
#include
#include
#include
#include
#include
#define DEVICE "/dev/cdrom"
int fd = open(DEVICE, O_RDONLY|O_NONBLOCK);
  if (fd < 0) {
    perror("unable to open "DEVICE);
    exit(1);
  }
  if (ioctl(fd, CDROMEJECT) != 0) {
    perror("CDROMEJECT ioctl failed");
    exit(1);
  }
  if (close(fd) != 0) {
    perror("unable to close "DEVICE);
    exit(1);
  }

收回光驱     
#include
#include
#include
#include
#include
#define DEVICE "/dev/cdrom"
int fd = open(DEVICE, O_RDONLY|O_NONBLOCK);
  if (fd < 0) {
    perror("unable to open "DEVICE);
    exit(1);
  }
  if (ioctl(fd, CDROMCLOSETRAY,0) != 0) {
    perror("CDROMCLOSETRAY ioctl failed");
    exit(1);
  }
  if (close(fd) != 0) {
    perror("unable to close "DEVICE);
    exit(1);

Linux下弹出和收回光驱

原文:http://my.oschina.net/u/2408048/blog/478325

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!