1 Index: busybox/coreutils/fsync.c
2 ===================================================================
3 --- busybox/coreutils/fsync.c (revision 0)
4 +++ busybox/coreutils/fsync.c (revision 0)
6 +/* vi: set sw=4 ts=4: */
8 + * Mini fsync implementation for busybox
10 + * Copyright (C) 2008 Nokia Corporation. All rights reserved.
12 + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
17 +/* This is a NOFORK applet. Be very careful! */
19 +int fsync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
20 +int fsync_main(int argc, char **argv)
22 + int status = EXIT_SUCCESS;
27 + flags = getopt32(argv, "d"); /* fdatasync */
34 + for (path = *argv++; path; path = *argv++) {
35 + fd = open(path, O_NOATIME | O_NOCTTY | O_RDONLY);
38 + bb_simple_perror_msg(path);
39 + status = EXIT_FAILURE;
43 + if ((flags ? fdatasync(fd) : fsync(fd)) == -1) {
44 + bb_simple_perror_msg(path);
52 Index: busybox/coreutils/Kbuild
53 ===================================================================
54 --- busybox/coreutils/Kbuild (revision 23238)
55 +++ busybox/coreutils/Kbuild (working copy)
57 lib-$(CONFIG_EXPAND) += expand.o
58 lib-$(CONFIG_FALSE) += false.o
59 lib-$(CONFIG_FOLD) += fold.o
60 +lib-$(CONFIG_FSYNC) += fsync.o
61 lib-$(CONFIG_HEAD) += head.o
62 lib-$(CONFIG_HOSTID) += hostid.o
63 lib-$(CONFIG_ID) += id.o
64 Index: busybox/coreutils/Config.in
65 ===================================================================
66 --- busybox/coreutils/Config.in (revision 23238)
67 +++ busybox/coreutils/Config.in (working copy)
70 Wrap text to fit a specific width.
76 + fsync is used to flush file-related cached blocks to disk.
81 Index: busybox/include/usage.h
82 ===================================================================
83 --- busybox/include/usage.h (revision 23238)
84 +++ busybox/include/usage.h (working copy)
85 @@ -3905,6 +3905,13 @@
86 #define sync_full_usage "\n\n" \
87 "Write all buffered filesystem blocks to disk"
89 +#define fsync_trivial_usage \
90 + "[OPTION]... FILE..."
91 +#define fsync_full_usage \
92 + "Write files' buffered blocks to disk\n" \
94 + "\n -d Avoid syncing metadata (like access time)"
96 #define sysctl_trivial_usage \
97 "[OPTIONS]... [VALUE]..."
98 #define sysctl_full_usage "\n\n" \
99 Index: busybox/include/applets.h
100 ===================================================================
101 --- busybox/include/applets.h (revision 23238)
102 +++ busybox/include/applets.h (working copy)
104 //USE_E2FSCK(APPLET_ODDNAME(fsck.ext2, e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER, fsck_ext2))
105 //USE_E2FSCK(APPLET_ODDNAME(fsck.ext3, e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER, fsck_ext3))
106 USE_FSCK_MINIX(APPLET_ODDNAME(fsck.minix, fsck_minix, _BB_DIR_SBIN, _BB_SUID_NEVER, fsck_minix))
107 +USE_FSYNC(APPLET_NOFORK(fsync, fsync, _BB_DIR_BIN, _BB_SUID_NEVER, fsync))
108 USE_FTPGET(APPLET_ODDNAME(ftpget, ftpgetput, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ftpget))
109 USE_FTPPUT(APPLET_ODDNAME(ftpput, ftpgetput, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ftpput))
110 USE_FUSER(APPLET(fuser, _BB_DIR_USR_BIN, _BB_SUID_NEVER))