On 01/24/2015 05:48 PM, Giuseppe Scrivano wrote: > * configure.ac: Check if syncfs(2) is available. > * NEWS: Mention the new feature. > * doc/coreutils.texi (sync invocation): Document the new feature. > * src/sync.c (usage): Describe that arguments are now accepted. > (main): Use syncfs(2) to flush buffers for the file system which > contain the specified arguments. Silently fallback to sync(2) on > errors. > ---
> @@ -65,9 +68,33 @@ main (int argc, char **argv)
> if (getopt_long (argc, argv, "", NULL, NULL) != -1)
> usage (EXIT_FAILURE);
>
> +#if HAVE_SYNCFS
> + /* If arguments are specified, use syncfs on any of them.
> + On any error, silently fallback to sync. */
> if (optind < argc)
> - error (0, 0, _("ignoring all arguments"));
> + {
> + while (optind < argc)
> + {
> + int fd = open (argv[optind], O_RDONLY);
> + if (fd < 0)
> + goto sync;
> +
> + if (syncfs (fd) < 0)
> + {
> + close (fd);
> + goto sync;
> + }
> +
> + if (close (fd) < 0)
> + goto sync;
> +
> + optind++;
> + }
> + return EXIT_SUCCESS;
> + }
> +#endif
>
> +sync:
This label is unused if !HAVE_SYNCFS. I suggest moving it inside the #if.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
