aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/fsync.c
diff options
context:
space:
mode:
authorSameer Pradhan <sameer.p.pradhan@gmail.com>2015-07-24 19:51:40 -0500
committerRob Landley <rob@landley.net>2015-07-24 19:51:40 -0500
commit441d1cedfb8dbe2c720bee791b5240829a5e54f9 (patch)
treec65a4ab84842c50ba7f474f70ee8d37b1cab03f2 /toys/pending/fsync.c
parente1937bd599077e744bd4381731ea5683c01eef09 (diff)
downloadtoybox-441d1cedfb8dbe2c720bee791b5240829a5e54f9.tar.gz
Attached are new toys.
tftp - Client for tftp daemon. hostid -Print the numeric identifier for the current host. fsync -Synchronize a file's in-core state with storage device.
Diffstat (limited to 'toys/pending/fsync.c')
-rw-r--r--toys/pending/fsync.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/toys/pending/fsync.c b/toys/pending/fsync.c
new file mode 100644
index 00000000..bf673df1
--- /dev/null
+++ b/toys/pending/fsync.c
@@ -0,0 +1,32 @@
+/* fsync.c - Synchronize a file's in-core state with storage device.
+ *
+ * Copyright 2015 Ranjan Kumar <ranjankumar.bth@gmail.comi>
+ *
+ * No Standard.
+
+USE_FSYNC(NEWTOY(fsync, "<1d", TOYFLAG_BIN))
+
+config FSYNC
+ bool "fsync"
+ default n
+ help
+ usage: fsync [d] [FILE...]
+
+ Synchronize a file's in-core state with storage device.
+
+ -d Avoid syncing metadata.
+*/
+#define FOR_fsync
+#include "toys.h"
+
+static void do_fsync(int fd, char *name)
+{
+ if (((toys.optflags & FLAG_d) ? fdatasync(fd) : fsync(fd)))
+ perror_msg("can't sync '%s'", name);
+}
+
+void fsync_main(void)
+{
+ loopfiles_rw(toys.optargs, O_RDONLY|O_NOATIME|O_NOCTTY|O_CLOEXEC,
+ 0, 0, do_fsync);
+}