Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/miscutils/eject.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 13  Line 13 
13   * Most of the dirty work blatantly ripped off from cat.c =)   * Most of the dirty work blatantly ripped off from cat.c =)
14   */   */
15    
16    #include <sys/mount.h>
17  #include "libbb.h"  #include "libbb.h"
18    /* Must be after libbb.h: they need size_t */
19    #include "fix_u32.h"
20    #include <scsi/sg.h>
21    #include <scsi/scsi.h>
22    
23  /* various defines swiped from linux/cdrom.h */  /* various defines swiped from linux/cdrom.h */
24  #define CDROMCLOSETRAY            0x5319  /* pendant of CDROMEJECT  */  #define CDROMCLOSETRAY            0x5319  /* pendant of CDROMEJECT  */
# Line 27  Line 32 
32  /* Code taken from the original eject (http://eject.sourceforge.net/),  /* Code taken from the original eject (http://eject.sourceforge.net/),
33   * refactored it a bit for busybox (ne-bb@nicoerfurth.de) */   * refactored it a bit for busybox (ne-bb@nicoerfurth.de) */
34    
 #include <scsi/sg.h>  
 #include <scsi/scsi.h>  
   
35  static void eject_scsi(const char *dev)  static void eject_scsi(const char *dev)
36  {  {
37   static const char sg_commands[3][6] = {   static const char sg_commands[3][6] = {
# Line 74  static void eject_cdrom(unsigned flags, Line 76  static void eject_cdrom(unsigned flags,
76   int cmd = CDROMEJECT;   int cmd = CDROMEJECT;
77    
78   if (flags & FLAG_CLOSE   if (flags & FLAG_CLOSE
79   || (flags & FLAG_SMART && ioctl(dev_fd, CDROM_DRIVE_STATUS) == CDS_TRAY_OPEN)   || ((flags & FLAG_SMART) && ioctl(dev_fd, CDROM_DRIVE_STATUS) == CDS_TRAY_OPEN)
80   ) {   ) {
81   cmd = CDROMCLOSETRAY;   cmd = CDROMCLOSETRAY;
82   }   }
# Line 89  int eject_main(int argc UNUSED_PARAM, ch Line 91  int eject_main(int argc UNUSED_PARAM, ch
91   const char *device;   const char *device;
92    
93   opt_complementary = "?1:t--T:T--t";   opt_complementary = "?1:t--T:T--t";
94   flags = getopt32(argv, "tT" USE_FEATURE_EJECT_SCSI("s"));   flags = getopt32(argv, "tT" IF_FEATURE_EJECT_SCSI("s"));
95   device = argv[optind] ? argv[optind] : "/dev/cdrom";   device = argv[optind] ? argv[optind] : "/dev/cdrom";
96    
97   /* We used to do "umount <device>" here, but it was buggy   /* We used to do "umount <device>" here, but it was buggy
# Line 102  int eject_main(int argc UNUSED_PARAM, ch Line 104  int eject_main(int argc UNUSED_PARAM, ch
104     eject /dev/cdrom     eject /dev/cdrom
105   */   */
106    
107   xmove_fd(xopen(device, O_RDONLY|O_NONBLOCK), dev_fd);   xmove_fd(xopen_nonblocking(device), dev_fd);
108    
109   if (ENABLE_FEATURE_EJECT_SCSI && (flags & FLAG_SCSI))   if (ENABLE_FEATURE_EJECT_SCSI && (flags & FLAG_SCSI))
110   eject_scsi(device);   eject_scsi(device);

Legend:
Removed from v.983  
changed lines
  Added in v.984