Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Feb 2019 23:45:36 +0000 (UTC)
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344555 - head/usr.sbin/makefs
Message-ID:  <201902252345.x1PNjadM091018@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sobomax
Date: Mon Feb 25 23:45:36 2019
New Revision: 344555
URL: https://svnweb.freebsd.org/changeset/base/344555

Log:
  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

Modified:
  head/usr.sbin/makefs/ffs.c

Modified: head/usr.sbin/makefs/ffs.c
==============================================================================
--- head/usr.sbin/makefs/ffs.c	Mon Feb 25 22:11:44 2019	(r344554)
+++ head/usr.sbin/makefs/ffs.c	Mon Feb 25 23:45:36 2019	(r344555)
@@ -932,8 +932,7 @@ ffs_write_file(union dinode *din, uint32_t ino, void *
 	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 *
   
  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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902252345.x1PNjadM091018>