码迷,mamicode.com
首页 > 系统相关 > 详细

Linux下弹出和收回光驱

时间:2015-07-14 15:53:24      阅读:201      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!