diff options
author | Erwan Velu <erwanaliasr1@gmail.com> | 2015-09-03 15:12:26 +0200 |
---|---|---|
committer | Erwan Velu <erwanaliasr1@gmail.com> | 2015-09-08 20:30:47 +0200 |
commit | 054f9453859b3d3e610721fca4ffdea8b6a8b85f (patch) | |
tree | c6adfffdd53159919722b6c8fa2bf0a1405679b2 | |
parent | bc0578ce672088a679eeaf4a48e72524e2323fad (diff) | |
download | syslinux-054f9453859b3d3e610721fca4ffdea8b6a8b85f.tar.gz |
libinstaller: Explicit failure if path isn't writable
As per bug #4, we should report a clear failure if the target path is
not writable.
The current code was catching the fact the file was not writable
but it didn't wrote an explicit message and even more confusing, was
trying to process the file descriptor leading to a creepy "Bad file
descriptor" error message.
This patch does return EACCES to avoid process the file description.
It also print an explicit message saying a particular file isn't
writable which generates a fatal error.
A typical output looks like :
[root@host]: extlinux --once=plop /boot
/boot is device /dev/sda
Cannot open file '/boot/ldlinux.sys' in read/write mode !
Fatal error, exiting.
-rw-r--r-- | libinstaller/advio.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libinstaller/advio.c b/libinstaller/advio.c index 56f607d0..66e477ed 100644 --- a/libinstaller/advio.c +++ b/libinstaller/advio.c @@ -130,7 +130,8 @@ int write_adv(const char *path, const char *cfg) close(fd); fd = open(file, O_RDWR | O_SYNC); if (fd < 0) { - err = -1; + fprintf(stderr, "Cannot open file '%s' in read/write mode !\nFatal error, exiting.\n", file); + return -EACCES; } else if (fstat(fd, &xst) || xst.st_ino != st.st_ino || xst.st_dev != st.st_dev || xst.st_size != st.st_size) { fprintf(stderr, "%s: race condition on write\n", file); |