[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH] util: Detect more I/O errors
From: |
Elliott, Robert (Persistent Memory) |
Subject: |
RE: [PATCH] util: Detect more I/O errors |
Date: |
Thu, 28 Feb 2019 16:32:44 +0000 |
> -----Original Message-----
> From: Grub-devel <address@hidden> On
> Behalf Of Colin Watson
> Sent: Wednesday, February 27, 2019 3:10 AM
> Subject: [PATCH] util: Detect more I/O errors
>
...
> -void
> +int
> grub_util_file_sync (FILE *f)
> {
> - fflush (f);
> + if (fflush (f) != 0)
> + return -1;
> if (!allow_fd_syncs)
> - return;
> - fsync (fileno (f));
> + return 0;
> + return fsync (fileno (f));
> }
Since that's just returning -1 for an error (both for fflush and fsync),
not errno which contains the reason for the error...
> diff --git a/util/editenv.c b/util/editenv.c
> index c6f8d2298..eb2d0c03a 100644
> --- a/util/editenv.c
> +++ b/util/editenv.c
> @@ -55,7 +55,8 @@ grub_util_create_envblk_file (const char *name)
> strerror (errno));
>
>
> - grub_util_file_sync (fp);
> + if (grub_util_file_sync (fp) < 0)
> + grub_util_error (_("cannot sync `%s': %s"), namenew, strerror
> (errno));
callers like this will interpret the -1 as EPERM, which isn't the
true reason.
---
Robert Elliott, HPE Persistent Memory