mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-15 15:06:42 +00:00
Improve error handling: bail out if one of the files scheduled
to go to the FS image we are making cannot be read (e.g. EPERM). Current behaviour when we issue waring but still proceeed and return success is definitely not correct: masking out error condition as well as making a slighly inconsistent FS where attempt to access the file in question ends up in EBADF. See linked DR for details. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D18584
This commit is contained in:
parent
f214ea82c3
commit
781e78182d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=344555
@ -932,8 +932,7 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
|
||||
if (isfile) {
|
||||
fbuf = emalloc(ffs_opts->bsize);
|
||||
if ((ffd = open((char *)buf, O_RDONLY, 0444)) == -1) {
|
||||
warn("Can't open `%s' for reading", (char *)buf);
|
||||
goto leave_ffs_write_file;
|
||||
err(EXIT_FAILURE, "Can't open `%s' for reading", (char *)buf);
|
||||
}
|
||||
} else {
|
||||
p = buf;
|
||||
@ -987,8 +986,6 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
|
||||
|
||||
write_inode_and_leave:
|
||||
ffs_write_inode(&in.i_din, in.i_number, fsopts);
|
||||
|
||||
leave_ffs_write_file:
|
||||
if (fbuf)
|
||||
free(fbuf);
|
||||
if (ffd != -1)
|
||||
|
Loading…
Reference in New Issue
Block a user