summaryrefslogtreecommitdiff
path: root/sbin/newfs
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-07-20 01:38:41 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-07-20 01:38:41 +0000
commit7a28608cfded6ad958b67771de221d7e4f65d5a4 (patch)
treec9cf52f6b8ea60c0fae8134d5226210f7c1d3ae8 /sbin/newfs
parent86c2401ccbc07e58588ca73b92b27ab89e9e671f (diff)
Make sure the correct errno is reported by warn* or err* and not
the errno of an intervening cleanup operation like close/unlink/etc. Diff from Doug Hogan (doug (at) acyclic.org)
Diffstat (limited to 'sbin/newfs')
-rw-r--r--sbin/newfs/newfs.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 27e37a00dfb..c5dd125fec7 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newfs.c,v 1.96 2014/07/20 00:46:26 guenther Exp $ */
+/* $OpenBSD: newfs.c,v 1.97 2014/07/20 01:38:40 guenther Exp $ */
/* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */
/*
@@ -756,11 +756,12 @@ copy(char *src, char *dst, struct mfs_args *args)
mount_args.fspec = src;
ret = mount(MOUNT_FFS, mountpoint, MNT_RDONLY, &mount_args);
if (ret != 0) {
+ int saved_errno = errno;
if (created && rmdir(mountpoint) != 0)
warn("rmdir %s", mountpoint);
if (unmount(dst, 0) != 0)
warn("unmount %s", dst);
- err(1, "mount %s %s", src, mountpoint);
+ errc(1, saved_errno, "mount %s %s", src, mountpoint);
}
}
ret = do_exec(mountpoint, "/bin/pax", argv);