GNU bug report logs - #19681
[PATCH] sync: use syncfs(2) if any argument is specified

Previous Next

Package: coreutils;

Reported by: Giuseppe Scrivano <gscrivan <at> redhat.com>

Date: Sun, 25 Jan 2015 03:06:02 UTC

Severity: normal

Tags: patch

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #41 received at 19681 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Giuseppe Scrivano <gscrivan <at> redhat.com>, 19681 <at> debbugs.gnu.org
Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is
 specified
Date: Mon, 26 Jan 2015 09:02:50 -0700
[Message part 1 (text/plain, inline)]
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 (application/pgp-signature, attachment)]

This bug report was last modified 6 years and 283 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.