util: Detect more I/O errors
Many of GRUB's utilities don't check anywhere near all the possible write errors. For example, if grub-install runs out of space when copying a file, it won't notice. There were missing checks for the return values of write, fflush, fsync, and close (or the equivalents on other OSes), all of which must be checked. I tried to be consistent with the existing logging practices of the various hostdisk implementations, but they weren't entirely consistent to start with so I used my judgement. The result at least looks reasonable on GNU/Linux when I provoke a write error: Installing for x86_64-efi platform. grub-install: error: cannot copy `/usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed' to `/boot/efi/EFI/debian/grubx64.efi': No space left on device. There are more missing checks in other utilities, but this should fix the most critical ones. Fixes Debian bug #922741. Signed-off-by: Colin Watson <cjwatson@ubuntu.com> Reviewed-by: Steve McIntyre <93sam@debian.org> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
222cb8f6df
commit
62daa27056
10 changed files with 90 additions and 45 deletions
|
@ -47,11 +47,11 @@ grub_util_fd_t
|
|||
EXPORT_FUNC(grub_util_fd_open) (const char *os_dev, int flags);
|
||||
const char *
|
||||
EXPORT_FUNC(grub_util_fd_strerror) (void);
|
||||
void
|
||||
int
|
||||
grub_util_fd_sync (grub_util_fd_t fd);
|
||||
void
|
||||
grub_util_disable_fd_syncs (void);
|
||||
void
|
||||
int
|
||||
EXPORT_FUNC(grub_util_fd_close) (grub_util_fd_t fd);
|
||||
|
||||
grub_uint64_t
|
||||
|
|
|
@ -73,6 +73,6 @@ FILE *
|
|||
grub_util_fopen (const char *path, const char *mode);
|
||||
#endif
|
||||
|
||||
void grub_util_file_sync (FILE *f);
|
||||
int grub_util_file_sync (FILE *f);
|
||||
|
||||
#endif /* GRUB_EMU_MISC_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue