aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2015-08-04 09:46:24 +0100
committerRon Yorston <rmy@pobox.com>2015-08-04 09:46:24 +0100
commit64fde14d12cc5e6182f114ecaf4340ec1854c2f6 (patch)
tree4d2cabca7865dd74e2344834d89503c534fb502c /coreutils
parent7aabb625005c642d6a30d6d97b51bf183429152e (diff)
parent16aa7a73c40ba5dfaabaedb8a5533619cb8b6cb6 (diff)
downloadbusybox-w32-64fde14d12cc5e6182f114ecaf4340ec1854c2f6.tar.gz
busybox-w32-64fde14d12cc5e6182f114ecaf4340ec1854c2f6.tar.bz2
busybox-w32-64fde14d12cc5e6182f114ecaf4340ec1854c2f6.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/Config.src14
-rw-r--r--coreutils/Kbuild.src1
-rw-r--r--coreutils/echo.c2
-rw-r--r--coreutils/sync.c78
-rw-r--r--coreutils/uname.c10
5 files changed, 86 insertions, 19 deletions
diff --git a/coreutils/Config.src b/coreutils/Config.src
index 68857b2cc..21b97d382 100644
--- a/coreutils/Config.src
+++ b/coreutils/Config.src
@@ -570,12 +570,6 @@ config SUM
570 help 570 help
571 checksum and count the blocks in a file 571 checksum and count the blocks in a file
572 572
573config SYNC
574 bool "sync"
575 default y
576 help
577 sync is used to flush filesystem buffers.
578
579config TAC 573config TAC
580 bool "tac" 574 bool "tac"
581 default y 575 default y
@@ -635,6 +629,14 @@ config UNAME
635 help 629 help
636 uname is used to print system information. 630 uname is used to print system information.
637 631
632config UNAME_OSNAME
633 string "Operating system name"
634 default "GNU/Linux"
635 depends on UNAME
636 help
637 Sets the operating system name reported by uname -o. The
638 default is "GNU/Linux".
639
638config UNEXPAND 640config UNEXPAND
639 bool "unexpand" 641 bool "unexpand"
640 default y 642 default y
diff --git a/coreutils/Kbuild.src b/coreutils/Kbuild.src
index ec4ef7df2..4ec075ac6 100644
--- a/coreutils/Kbuild.src
+++ b/coreutils/Kbuild.src
@@ -68,7 +68,6 @@ lib-$(CONFIG_SORT) += sort.o
68lib-$(CONFIG_STAT) += stat.o 68lib-$(CONFIG_STAT) += stat.o
69lib-$(CONFIG_STTY) += stty.o 69lib-$(CONFIG_STTY) += stty.o
70lib-$(CONFIG_SUM) += sum.o 70lib-$(CONFIG_SUM) += sum.o
71lib-$(CONFIG_SYNC) += sync.o
72lib-$(CONFIG_TAC) += tac.o 71lib-$(CONFIG_TAC) += tac.o
73lib-$(CONFIG_TEE) += tee.o 72lib-$(CONFIG_TEE) += tee.o
74lib-$(CONFIG_TRUE) += true.o 73lib-$(CONFIG_TRUE) += true.o
diff --git a/coreutils/echo.c b/coreutils/echo.c
index 9663894ec..1c4174559 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -72,7 +72,7 @@ int echo_main(int argc UNUSED_PARAM, char **argv)
72 unsigned buflen; 72 unsigned buflen;
73#if !ENABLE_FEATURE_FANCY_ECHO 73#if !ENABLE_FEATURE_FANCY_ECHO
74 enum { 74 enum {
75 eflag = '\\', 75 eflag = 0, /* 0 -- disable escape sequences */
76 nflag = 1, /* 1 -- print '\n' */ 76 nflag = 1, /* 1 -- print '\n' */
77 }; 77 };
78 78
diff --git a/coreutils/sync.c b/coreutils/sync.c
index 7d98a1e30..974e90452 100644
--- a/coreutils/sync.c
+++ b/coreutils/sync.c
@@ -3,16 +3,39 @@
3 * Mini sync implementation for busybox 3 * Mini sync implementation for busybox
4 * 4 *
5 * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>. 5 * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
6 * Copyright (C) 2015 by Ari Sundholm <ari@tuxera.com>
6 * 7 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 9 */
9 10
10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ 11/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
12//config:config SYNC
13//config: bool "sync"
14//config: default y
15//config: help
16//config: sync is used to flush filesystem buffers.
17//config:config FEATURE_SYNC_FANCY
18//config: bool "Enable -d and -f flags (requres syncfs(2) in libc)"
19//config: default y
20//config: depends on SYNC
21//config: help
22//config: sync -d FILE... executes fdatasync() on each FILE.
23//config: sync -f FILE... executes syncfs() on each FILE.
24
25//kbuild:lib-$(CONFIG_SYNC) += sync.o
26//applet:IF_SYNC(APPLET_NOFORK(sync, sync, BB_DIR_BIN, BB_SUID_DROP, sync))
11 27
12//usage:#define sync_trivial_usage 28//usage:#define sync_trivial_usage
13//usage: "" 29//usage: ""IF_FEATURE_SYNC_FANCY("[-df] [FILE]...")
14//usage:#define sync_full_usage "\n\n" 30//usage:#define sync_full_usage "\n\n"
31//usage: IF_NOT_FEATURE_SYNC_FANCY(
15//usage: "Write all buffered blocks to disk" 32//usage: "Write all buffered blocks to disk"
33//usage: )
34//usage: IF_FEATURE_SYNC_FANCY(
35//usage: "Write all buffered blocks (in FILEs) to disk"
36//usage: "\n -d Avoid syncing metadata"
37//usage: "\n -f Sync filesystems underlying FILEs"
38//usage: )
16 39
17#include "libbb.h" 40#include "libbb.h"
18 41
@@ -21,10 +44,59 @@
21int sync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 44int sync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
22int sync_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM)) 45int sync_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM))
23{ 46{
47#if !ENABLE_FEATURE_SYNC_FANCY
24 /* coreutils-6.9 compat */ 48 /* coreutils-6.9 compat */
25 bb_warn_ignoring_args(argv[1]); 49 bb_warn_ignoring_args(argv[1]);
26
27 sync(); 50 sync();
28
29 return EXIT_SUCCESS; 51 return EXIT_SUCCESS;
52#else
53 unsigned opts;
54 int ret = EXIT_SUCCESS;
55
56 enum {
57 OPT_DATASYNC = (1 << 0),
58 OPT_SYNCFS = (1 << 1),
59 };
60
61 opt_complementary = "d--f:f--d";
62 opts = getopt32(argv, "df");
63 argv += optind;
64
65 /* Handle the no-argument case. */
66 if (!argv[0])
67 sync();
68
69 while (*argv) {
70 int fd = open_or_warn(*argv, O_RDONLY);
71
72 if (fd < 0) {
73 ret = EXIT_FAILURE;
74 goto next;
75 }
76 if (opts & OPT_DATASYNC) {
77 if (fdatasync(fd))
78 goto err;
79 goto do_close;
80 }
81 if (opts & OPT_SYNCFS) {
82 /*
83 * syncfs is documented to only fail with EBADF,
84 * which can't happen here. So, no error checks.
85 */
86 syncfs(fd);
87 goto do_close;
88 }
89 if (fsync(fd)) {
90 err:
91 bb_simple_perror_msg(*argv);
92 ret = EXIT_FAILURE;
93 }
94 do_close:
95 close(fd);
96 next:
97 ++argv;
98 }
99
100 return ret;
101#endif
30} 102}
diff --git a/coreutils/uname.c b/coreutils/uname.c
index 56d985eb0..fd677d27c 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -70,17 +70,11 @@
70/* After libbb.h, since it needs sys/types.h on some systems */ 70/* After libbb.h, since it needs sys/types.h on some systems */
71#include <sys/utsname.h> 71#include <sys/utsname.h>
72 72
73#if ENABLE_PLATFORM_MINGW32
74# define OSNAME "MS/Windows"
75#else
76# define OSNAME "GNU/Linux"
77#endif
78
79typedef struct { 73typedef struct {
80 struct utsname name; 74 struct utsname name;
81 char processor[sizeof(((struct utsname*)NULL)->machine)]; 75 char processor[sizeof(((struct utsname*)NULL)->machine)];
82 char platform[sizeof(((struct utsname*)NULL)->machine)]; 76 char platform[sizeof(((struct utsname*)NULL)->machine)];
83 char os[sizeof(OSNAME)]; 77 char os[sizeof(CONFIG_UNAME_OSNAME)];
84} uname_info_t; 78} uname_info_t;
85 79
86static const char options[] ALIGN1 = "snrvmpioa"; 80static const char options[] ALIGN1 = "snrvmpioa";
@@ -147,7 +141,7 @@ int uname_main(int argc UNUSED_PARAM, char **argv)
147#endif 141#endif
148 strcpy(uname_info.processor, unknown_str); 142 strcpy(uname_info.processor, unknown_str);
149 strcpy(uname_info.platform, unknown_str); 143 strcpy(uname_info.platform, unknown_str);
150 strcpy(uname_info.os, OSNAME); 144 strcpy(uname_info.os, CONFIG_UNAME_OSNAME);
151#if 0 145#if 0
152 /* Fedora does something like this */ 146 /* Fedora does something like this */
153 strcpy(uname_info.processor, uname_info.name.machine); 147 strcpy(uname_info.processor, uname_info.name.machine);