hush: initial stab at brace expansion support
[oweals/busybox.git] / miscutils / eject.c
index 94a36c0da3ea9ce87baadd695db047397e3c5fce..a869c6311cc6d427ea59a697a12e187cf14fae32 100644 (file)
  * Most of the dirty work blatantly ripped off from cat.c =)
  */
 
+#include <sys/mount.h>
 #include "libbb.h"
+/* Must be after libbb.h: they need size_t */
+#include "fix_u32.h"
+#include <scsi/sg.h>
+#include <scsi/scsi.h>
 
 /* various defines swiped from linux/cdrom.h */
 #define CDROMCLOSETRAY            0x5319  /* pendant of CDROMEJECT  */
@@ -27,9 +32,6 @@
 /* Code taken from the original eject (http://eject.sourceforge.net/),
  * refactored it a bit for busybox (ne-bb@nicoerfurth.de) */
 
-#include <scsi/sg.h>
-#include <scsi/scsi.h>
-
 static void eject_scsi(const char *dev)
 {
        static const char sg_commands[3][6] = {
@@ -74,7 +76,7 @@ static void eject_cdrom(unsigned flags, const char *dev)
        int cmd = CDROMEJECT;
 
        if (flags & FLAG_CLOSE
-        || (flags & FLAG_SMART && ioctl(dev_fd, CDROM_DRIVE_STATUS) == CDS_TRAY_OPEN)
+        || ((flags & FLAG_SMART) && ioctl(dev_fd, CDROM_DRIVE_STATUS) == CDS_TRAY_OPEN)
        ) {
                cmd = CDROMCLOSETRAY;
        }
@@ -102,7 +104,7 @@ int eject_main(int argc UNUSED_PARAM, char **argv)
           eject /dev/cdrom
        */
 
-       xmove_fd(xopen(device, O_RDONLY|O_NONBLOCK), dev_fd);
+       xmove_fd(xopen_nonblocking(device), dev_fd);
 
        if (ENABLE_FEATURE_EJECT_SCSI && (flags & FLAG_SCSI))
                eject_scsi(device);