svn commit: r213668 - head/sbin/mksnap_ffs
Jaakko Heinonen
jh at FreeBSD.org
Sun Oct 10 09:24:19 UTC 2010
Author: jh
Date: Sun Oct 10 09:24:19 2010
New Revision: 213668
URL: http://svn.freebsd.org/changeset/base/213668
Log:
- Print the nmount(2) provided error message only when it is set.
- Ensure that the error message is NUL-terminated before printing it.
PR: bin/147482
MFC after: 2 weeks
Modified:
head/sbin/mksnap_ffs/mksnap_ffs.c
Modified: head/sbin/mksnap_ffs/mksnap_ffs.c
==============================================================================
--- head/sbin/mksnap_ffs/mksnap_ffs.c Sun Oct 10 08:41:08 2010 (r213667)
+++ head/sbin/mksnap_ffs/mksnap_ffs.c Sun Oct 10 09:24:19 2010 (r213668)
@@ -121,8 +121,12 @@ main(int argc, char **argv)
build_iovec(&iov, &iovlen, "update", NULL, 0);
build_iovec(&iov, &iovlen, "snapshot", NULL, 0);
- if (nmount(iov, iovlen, stfsbuf.f_flags) < 0)
- err(1, "Cannot create snapshot %s: %s", snapname, errmsg);
+ *errmsg = '\0';
+ if (nmount(iov, iovlen, stfsbuf.f_flags) < 0) {
+ errmsg[sizeof(errmsg) - 1] = '\0';
+ err(1, "Cannot create snapshot %s%s%s", snapname,
+ *errmsg != '\0' ? ": " : "", errmsg);
+ }
if ((fd = open(snapname, O_RDONLY)) < 0)
err(1, "Cannot open %s", snapname);
if (fstat(fd, &stbuf) != 0)
More information about the svn-src-head
mailing list