aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-05-09 15:23:38 +0100
committerRon Yorston <rmy@pobox.com>2012-05-09 15:23:38 +0100
commit7e572c27e15f5ca458dd02a745b20d1dbbc9f1f6 (patch)
tree2ff84ec9c7249a0a370da7cb187ac99ca5033863 /coreutils
parent4066aff5e481941585c5958460c39a1b1399ce88 (diff)
parentf1f8fcaad556ea2991e57bbb6132d80e86346e1e (diff)
downloadbusybox-w32-7e572c27e15f5ca458dd02a745b20d1dbbc9f1f6.tar.gz
busybox-w32-7e572c27e15f5ca458dd02a745b20d1dbbc9f1f6.tar.bz2
busybox-w32-7e572c27e15f5ca458dd02a745b20d1dbbc9f1f6.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/ln.c28
-rw-r--r--coreutils/mkdir.c3
-rw-r--r--coreutils/mv.c19
-rw-r--r--coreutils/rmdir.c8
4 files changed, 40 insertions, 18 deletions
diff --git a/coreutils/ln.c b/coreutils/ln.c
index 0eb3e6579..3b822e8c7 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -20,6 +20,8 @@
20//usage: "\n -n Don't dereference symlinks - treat like normal file" 20//usage: "\n -n Don't dereference symlinks - treat like normal file"
21//usage: "\n -b Make a backup of the target (if exists) before link operation" 21//usage: "\n -b Make a backup of the target (if exists) before link operation"
22//usage: "\n -S suf Use suffix instead of ~ when making backup files" 22//usage: "\n -S suf Use suffix instead of ~ when making backup files"
23//usage: "\n -T 2nd arg must be a DIR"
24//usage: "\n -v Verbose"
23//usage: 25//usage:
24//usage:#define ln_example_usage 26//usage:#define ln_example_usage
25//usage: "$ ln -s BusyBox /tmp/ls\n" 27//usage: "$ ln -s BusyBox /tmp/ls\n"
@@ -31,11 +33,13 @@
31/* This is a NOEXEC applet. Be very careful! */ 33/* This is a NOEXEC applet. Be very careful! */
32 34
33 35
34#define LN_SYMLINK 1 36#define LN_SYMLINK (1 << 0)
35#define LN_FORCE 2 37#define LN_FORCE (1 << 1)
36#define LN_NODEREFERENCE 4 38#define LN_NODEREFERENCE (1 << 2)
37#define LN_BACKUP 8 39#define LN_BACKUP (1 << 3)
38#define LN_SUFFIX 16 40#define LN_SUFFIX (1 << 4)
41#define LN_VERBOSE (1 << 5)
42#define LN_LINKFILE (1 << 6)
39 43
40int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 44int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
41int ln_main(int argc, char **argv) 45int ln_main(int argc, char **argv)
@@ -50,10 +54,15 @@ int ln_main(int argc, char **argv)
50 int (*link_func)(const char *, const char *); 54 int (*link_func)(const char *, const char *);
51 55
52 opt_complementary = "-1"; /* min one arg */ 56 opt_complementary = "-1"; /* min one arg */
53 opts = getopt32(argv, "sfnbS:", &suffix); 57 opts = getopt32(argv, "sfnbS:vT", &suffix);
54 58
55 last = argv[argc - 1]; 59 last = argv[argc - 1];
56 argv += optind; 60 argv += optind;
61 argc -= optind;
62
63 if ((opts & LN_LINKFILE) && argc > 2) {
64 bb_error_msg_and_die("-T accepts 2 args max");
65 }
57 66
58 if (!argv[1]) { 67 if (!argv[1]) {
59 /* "ln PATH/TO/FILE" -> "ln PATH/TO/FILE FILE" */ 68 /* "ln PATH/TO/FILE" -> "ln PATH/TO/FILE FILE" */
@@ -72,6 +81,9 @@ int ln_main(int argc, char **argv)
72 (opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE 81 (opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE
73 ) 82 )
74 ) { 83 ) {
84 if (opts & LN_LINKFILE) {
85 bb_error_msg_and_die("'%s' is a directory", src);
86 }
75 src_name = xstrdup(*argv); 87 src_name = xstrdup(*argv);
76 src = concat_path_file(src, bb_get_last_path_component_strip(src_name)); 88 src = concat_path_file(src, bb_get_last_path_component_strip(src_name));
77 free(src_name); 89 free(src_name);
@@ -112,6 +124,10 @@ int ln_main(int argc, char **argv)
112 link_func = symlink; 124 link_func = symlink;
113 } 125 }
114 126
127 if (opts & LN_VERBOSE) {
128 printf("'%s' -> '%s'\n", src, *argv);
129 }
130
115 if (link_func(*argv, src) != 0) { 131 if (link_func(*argv, src) != 0) {
116 bb_simple_perror_msg(src); 132 bb_simple_perror_msg(src);
117 status = EXIT_FAILURE; 133 status = EXIT_FAILURE;
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index b33b6bba3..4a8e43e43 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -48,6 +48,7 @@ static const char mkdir_longopts[] ALIGN1 =
48#if ENABLE_SELINUX 48#if ENABLE_SELINUX
49 "context\0" Required_argument "Z" 49 "context\0" Required_argument "Z"
50#endif 50#endif
51 "verbose\0" No_argument "v"
51 ; 52 ;
52#endif 53#endif
53 54
@@ -66,7 +67,7 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv)
66#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS 67#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
67 applet_long_options = mkdir_longopts; 68 applet_long_options = mkdir_longopts;
68#endif 69#endif
69 opt = getopt32(argv, "m:p" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext)); 70 opt = getopt32(argv, "m:p" IF_SELINUX("Z:") "v", &smode IF_SELINUX(,&scontext));
70 if (opt & 1) { 71 if (opt & 1) {
71 mode_t mmode = 0777; 72 mode_t mmode = 0777;
72 if (!bb_parse_mode(smode, &mmode)) { 73 if (!bb_parse_mode(smode, &mmode)) {
diff --git a/coreutils/mv.c b/coreutils/mv.c
index 87f4cd5a5..f127dfabd 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -33,12 +33,13 @@ static const char mv_longopts[] ALIGN1 =
33 "interactive\0" No_argument "i" 33 "interactive\0" No_argument "i"
34 "force\0" No_argument "f" 34 "force\0" No_argument "f"
35 "no-clobber\0" No_argument "n" 35 "no-clobber\0" No_argument "n"
36 "verbose\0" No_argument "v"
36 ; 37 ;
37#endif 38#endif
38 39
39#define OPT_FILEUTILS_FORCE 1 40#define OPT_FORCE (1 << 0)
40#define OPT_FILEUTILS_INTERACTIVE 2 41#define OPT_INTERACTIVE (1 << 1)
41#define OPT_FILEUTILS_NOCLOBBER 4 42#define OPT_NOCLOBBER (1 << 2)
42 43
43int mv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 44int mv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
44int mv_main(int argc, char **argv) 45int mv_main(int argc, char **argv)
@@ -56,9 +57,11 @@ int mv_main(int argc, char **argv)
56#endif 57#endif
57 /* Need at least two arguments. 58 /* Need at least two arguments.
58 * If more than one of -f, -i, -n is specified , only the final one 59 * If more than one of -f, -i, -n is specified , only the final one
59 * takes effect (it unsets previous options). */ 60 * takes effect (it unsets previous options).
61 * -v is accepted but ignored.
62 */
60 opt_complementary = "-2:f-in:i-fn:n-fi"; 63 opt_complementary = "-2:f-in:i-fn:n-fi";
61 flags = getopt32(argv, "fin"); 64 flags = getopt32(argv, "finv");
62 argc -= optind; 65 argc -= optind;
63 argv += optind; 66 argv += optind;
64 last = argv[argc - 1]; 67 last = argv[argc - 1];
@@ -84,11 +87,11 @@ int mv_main(int argc, char **argv)
84 87
85 DO_MOVE: 88 DO_MOVE:
86 if (dest_exists) { 89 if (dest_exists) {
87 if (flags & OPT_FILEUTILS_NOCLOBBER) 90 if (flags & OPT_NOCLOBBER)
88 goto RET_0; 91 goto RET_0;
89 if (!(flags & OPT_FILEUTILS_FORCE) 92 if (!(flags & OPT_FORCE)
90 && ((access(dest, W_OK) < 0 && isatty(0)) 93 && ((access(dest, W_OK) < 0 && isatty(0))
91 || (flags & OPT_FILEUTILS_INTERACTIVE)) 94 || (flags & OPT_INTERACTIVE))
92 ) { 95 ) {
93 if (fprintf(stderr, "mv: overwrite '%s'? ", dest) < 0) { 96 if (fprintf(stderr, "mv: overwrite '%s'? ", dest) < 0) {
94 goto RET_1; /* Ouch! fprintf failed! */ 97 goto RET_1; /* Ouch! fprintf failed! */
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index 2840d1cfa..cc2dea010 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -30,8 +30,9 @@
30/* This is a NOFORK applet. Be very careful! */ 30/* This is a NOFORK applet. Be very careful! */
31 31
32 32
33#define PARENTS 0x01 33#define PARENTS (1 << 0)
34#define IGNORE_NON_EMPTY 0x02 34//efine VERBOSE (1 << 1) //accepted but ignored
35#define IGNORE_NON_EMPTY (1 << 2)
35 36
36int rmdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 37int rmdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
37int rmdir_main(int argc UNUSED_PARAM, char **argv) 38int rmdir_main(int argc UNUSED_PARAM, char **argv)
@@ -43,13 +44,14 @@ int rmdir_main(int argc UNUSED_PARAM, char **argv)
43#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS 44#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
44 static const char rmdir_longopts[] ALIGN1 = 45 static const char rmdir_longopts[] ALIGN1 =
45 "parents\0" No_argument "p" 46 "parents\0" No_argument "p"
47 "verbose\0" No_argument "v"
46 /* Debian etch: many packages fail to be purged or installed 48 /* Debian etch: many packages fail to be purged or installed
47 * because they desperately want this option: */ 49 * because they desperately want this option: */
48 "ignore-fail-on-non-empty\0" No_argument "\xff" 50 "ignore-fail-on-non-empty\0" No_argument "\xff"
49 ; 51 ;
50 applet_long_options = rmdir_longopts; 52 applet_long_options = rmdir_longopts;
51#endif 53#endif
52 flags = getopt32(argv, "p"); 54 flags = getopt32(argv, "pv");
53 argv += optind; 55 argv += optind;
54 56
55 if (!*argv) { 57 if (!*argv) {