- 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
This commit is contained in:
Jaakko Heinonen 2010-10-10 09:24:19 +00:00
parent d0cc54f3b4
commit 7f79e870d2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=213668

View File

@ -121,8 +121,12 @@ main(int argc, char **argv)
build_iovec(&iov, &iovlen, "update", NULL, 0); build_iovec(&iov, &iovlen, "update", NULL, 0);
build_iovec(&iov, &iovlen, "snapshot", NULL, 0); build_iovec(&iov, &iovlen, "snapshot", NULL, 0);
if (nmount(iov, iovlen, stfsbuf.f_flags) < 0) *errmsg = '\0';
err(1, "Cannot create snapshot %s: %s", snapname, errmsg); 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) if ((fd = open(snapname, O_RDONLY)) < 0)
err(1, "Cannot open %s", snapname); err(1, "Cannot open %s", snapname);
if (fstat(fd, &stbuf) != 0) if (fstat(fd, &stbuf) != 0)