diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-02 14:54:56 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-02 14:55:29 +0200 |
commit | 2f28b2bdbbe229b760e7c2a271d73a19f929ca76 (patch) | |
tree | d4607c6ac47cc0cfdde18109395777521142781a /coreutils/fsync.c | |
parent | 4f74bb6059b54df31b9a6cdaf844112a7003b0ff (diff) | |
download | busybox-w32-2f28b2bdbbe229b760e7c2a271d73a19f929ca76.tar.gz busybox-w32-2f28b2bdbbe229b760e7c2a271d73a19f929ca76.tar.bz2 busybox-w32-2f28b2bdbbe229b760e7c2a271d73a19f929ca76.zip |
fsync,sync: merge into one source module
With FEATURE_SYNC_FANCY not set:
function old new delta
fsync_main 130 123 -7
With FEATURE_SYNC_FANCY set, should be much larger code size savings.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/fsync.c')
-rw-r--r-- | coreutils/fsync.c | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/coreutils/fsync.c b/coreutils/fsync.c deleted file mode 100644 index 216cbcf41..000000000 --- a/coreutils/fsync.c +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Mini fsync implementation for busybox | ||
4 | * | ||
5 | * Copyright (C) 2008 Nokia Corporation. All rights reserved. | ||
6 | * | ||
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | ||
8 | */ | ||
9 | //config:config FSYNC | ||
10 | //config: bool "fsync (3.6 kb)" | ||
11 | //config: default y | ||
12 | //config: help | ||
13 | //config: fsync is used to flush file-related cached blocks to disk. | ||
14 | |||
15 | // APPLET_NOFORK:name main location suid_type help | ||
16 | //applet:IF_FSYNC(APPLET_NOFORK(fsync, fsync, BB_DIR_BIN, BB_SUID_DROP, fsync)) | ||
17 | |||
18 | //kbuild:lib-$(CONFIG_FSYNC) += fsync.o | ||
19 | |||
20 | //usage:#define fsync_trivial_usage | ||
21 | //usage: "[-d] FILE..." | ||
22 | //usage:#define fsync_full_usage "\n\n" | ||
23 | //usage: "Write all buffered blocks in FILEs to disk\n" | ||
24 | //usage: "\n -d Avoid syncing metadata" | ||
25 | |||
26 | #include "libbb.h" | ||
27 | |||
28 | /* This is a NOFORK applet. Be very careful! */ | ||
29 | |||
30 | int fsync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
31 | int fsync_main(int argc UNUSED_PARAM, char **argv) | ||
32 | { | ||
33 | int ret; | ||
34 | int opts; | ||
35 | |||
36 | opts = getopt32(argv, "d"); /* fdatasync */ | ||
37 | argv += optind; | ||
38 | if (!*argv) { | ||
39 | bb_show_usage(); | ||
40 | } | ||
41 | |||
42 | ret = EXIT_SUCCESS; | ||
43 | do { | ||
44 | /* GNU "sync FILE" uses O_NONBLOCK open */ | ||
45 | int fd = open_or_warn(*argv, /*O_NOATIME |*/ O_NOCTTY | O_RDONLY | O_NONBLOCK); | ||
46 | /* open(NOATIME) can only be used by owner or root, don't use NOATIME here */ | ||
47 | |||
48 | if (fd < 0) { | ||
49 | ret = EXIT_FAILURE; | ||
50 | goto next; | ||
51 | } | ||
52 | if ((opts ? fdatasync(fd) : fsync(fd)) != 0) { | ||
53 | bb_simple_perror_msg(*argv); | ||
54 | ret = EXIT_FAILURE; | ||
55 | } | ||
56 | close(fd); | ||
57 | next: | ||
58 | argv++; | ||
59 | } while (*argv); | ||
60 | |||
61 | return ret; | ||
62 | } | ||