aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-05 23:12:49 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-05 23:12:49 +0000
commitf4160c8703abe6ababd6915c656abecf4bfe92e5 (patch)
tree7e6806573a90e3b755203535990dd01bd82d98e9
parent445754ff183de68a177b8482cf6df237bc4d3532 (diff)
downloadbusybox-w32-f4160c8703abe6ababd6915c656abecf4bfe92e5.tar.gz
busybox-w32-f4160c8703abe6ababd6915c656abecf4bfe92e5.tar.bz2
busybox-w32-f4160c8703abe6ababd6915c656abecf4bfe92e5.zip
eject: -T fix
git-svn-id: svn://busybox.net/trunk/busybox@16314 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--miscutils/eject.c36
-rw-r--r--networking/tftp.c6
-rw-r--r--util-linux/rdate.c4
3 files changed, 24 insertions, 22 deletions
diff --git a/miscutils/eject.c b/miscutils/eject.c
index d49396be6..b07f536b1 100644
--- a/miscutils/eject.c
+++ b/miscutils/eject.c
@@ -19,7 +19,9 @@
19/* various defines swiped from linux/cdrom.h */ 19/* various defines swiped from linux/cdrom.h */
20#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ 20#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
21#define CDROMEJECT 0x5309 /* Ejects the cdrom media */ 21#define CDROMEJECT 0x5309 /* Ejects the cdrom media */
22#define DEFAULT_CDROM "/dev/cdrom" 22#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
23/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
24#define CDS_TRAY_OPEN 2
23 25
24#define FLAG_CLOSE 1 26#define FLAG_CLOSE 1
25#define FLAG_SMART 2 27#define FLAG_SMART 2
@@ -29,32 +31,34 @@ int eject_main(int argc, char **argv)
29 unsigned long flags; 31 unsigned long flags;
30 char *device; 32 char *device;
31 struct mntent *m; 33 struct mntent *m;
32 int dev; 34 int dev, cmd;
33 35
34 /*opt_complementary = "t--T:T--t";*/ 36 opt_complementary = "?:?1:t--T:T--t";
35 flags = getopt32(argc, argv, "tT"); 37 flags = getopt32(argc, argv, "tT");
36 device = argv[optind] ? : DEFAULT_CDROM; 38 device = argv[optind] ? : "/dev/cdrom";
37 39
40 // FIXME: what if something is mounted OVER our cdrom?
41 // We will unmount something else??!
42 // What if cdrom is mounted many times?
38 m = find_mount_point(device, bb_path_mtab_file); 43 m = find_mount_point(device, bb_path_mtab_file);
39 if (m) { 44 if (m) {
40 if (umount(m->mnt_dir)) { 45 if (umount(m->mnt_dir))
41 bb_error_msg_and_die("can't umount"); 46 bb_error_msg_and_die("can't umount %s", device);
42 } else if (ENABLE_FEATURE_MTAB_SUPPORT) { 47 if (ENABLE_FEATURE_MTAB_SUPPORT)
43 erase_mtab(m->mnt_fsname); 48 erase_mtab(m->mnt_fsname);
44 }
45 } 49 }
46 50
47 dev = xopen(device, O_RDONLY|O_NONBLOCK); 51 dev = xopen(device, O_RDONLY|O_NONBLOCK);
48 52 cmd = CDROMEJECT;
49 if (flags & FLAG_CLOSE) goto close_tray; 53 if (flags & FLAG_CLOSE
50 54 || (flags & FLAG_SMART && ioctl(dev, CDROM_DRIVE_STATUS) == CDS_TRAY_OPEN))
51 if (ioctl(dev, CDROMEJECT)) { 55 cmd = CDROMCLOSETRAY;
52close_tray: 56 if (ioctl(dev, cmd)) {
53 if (ioctl(dev, CDROMCLOSETRAY)) 57 bb_perror_msg_and_die("%s", device);
54 bb_perror_msg_and_die("%s", device);
55 } 58 }
56 59
57 if (ENABLE_FEATURE_CLEAN_UP) close(dev); 60 if (ENABLE_FEATURE_CLEAN_UP)
61 close(dev);
58 62
59 return EXIT_SUCCESS; 63 return EXIT_SUCCESS;
60} 64}
diff --git a/networking/tftp.c b/networking/tftp.c
index 5f0c190e2..bfe94aca2 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -502,9 +502,7 @@ int tftp_main(int argc, char **argv)
502 opt_complementary = GET_COMPL PUT_COMPL; 502 opt_complementary = GET_COMPL PUT_COMPL;
503#endif 503#endif
504 504
505 505 cmd = getopt32(argc, argv, GET PUT "l:r:" BS, &localfile, &remotefile BS_ARG);
506 cmd = getopt32(argc, argv, GET PUT "l:r:" BS,
507 &localfile, &remotefile BS_ARG);
508 506
509 cmd &= (tftp_cmd_get | tftp_cmd_put); 507 cmd &= (tftp_cmd_get | tftp_cmd_put);
510#ifdef CONFIG_FEATURE_TFTP_GET 508#ifdef CONFIG_FEATURE_TFTP_GET
@@ -559,5 +557,5 @@ int tftp_main(int argc, char **argv)
559 if (cmd == tftp_cmd_get && result != EXIT_SUCCESS) 557 if (cmd == tftp_cmd_get && result != EXIT_SUCCESS)
560 unlink(localfile); 558 unlink(localfile);
561 } 559 }
562 return (result); 560 return result;
563} 561}
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index c24465dc3..6ad055434 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -73,10 +73,10 @@ int rdate_main(int argc, char **argv)
73 73
74 time(&current_time); 74 time(&current_time);
75 if (current_time == remote_time) 75 if (current_time == remote_time)
76 bb_error_msg("Current time matches remote time."); 76 bb_error_msg("current time matches remote time");
77 else 77 else
78 if (stime(&remote_time) < 0) 78 if (stime(&remote_time) < 0)
79 bb_perror_msg_and_die("Could not set time of day"); 79 bb_perror_msg_and_die("cannot set time of day");
80 } 80 }
81 81
82 if ((flags & 1) == 0) 82 if ((flags & 1) == 0)