[PATCH] dd fsync support
Denys Vlasenko
vda.linux at googlemail.com
Wed Apr 2 14:21:37 PDT 2008
On Wednesday 02 April 2008 22:03, James Simmons wrote:
> Support to physically write output file data before finishing.
>
> Index: dd.c
> ===================================================================
> --- dd.c (revision 21619)
> +++ dd.c (working copy)
> @@ -87,6 +87,7 @@
> FLAG_NOTRUNC = 1 << 2,
> FLAG_TWOBUFS = 1 << 3,
> FLAG_COUNT = 1 << 4,
> + FLAG_FSYNC = 1 << 5,
> };
> static const char keywords[] ALIGN1 =
> "bs=\0""count=\0""seek=\0""skip=\0""if=\0""of=\0"
> @@ -108,6 +109,7 @@
> OP_conv_notrunc,
> OP_conv_sync,
> OP_conv_noerror,
> + OP_conv_fsync,
> #endif
> };
> int exitcode = EXIT_FAILURE;
> @@ -185,6 +187,8 @@
> flags |= FLAG_SYNC;
> if (what == OP_conv_noerror)
> flags |= FLAG_NOERROR;
> + if (what == OP_conv_fsync)
> + flags |= FLAG_FSYNC;
> if (!key) /* no ',' left, so this was the last specifier */
> break;
> arg = key + 1; /* skip this keyword and ',' */
> @@ -304,6 +308,11 @@
> }
> } else if (write_and_stats(ibuf, n, obs, outfile))
> goto out_status;
> +
> + if (flags & FLAG_FSYNC) {
> + if (fsync(ofd) < 0)
> + goto die_outfile;
> + }
> }
>
> if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
Seems like the string "fsync\0" is not added by this patch...
I fixed it up. Applied to current svn. Thanks.
--
vda
More information about the busybox
mailing list