summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/bioctl/bioctl.c8
-rw-r--r--sbin/disklabel/disklabel.c4
-rw-r--r--sbin/newfs/newfs.c5
-rw-r--r--sbin/restore/dirs.c11
4 files changed, 18 insertions, 10 deletions
diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c
index cfd5b243cb2..97de831a6c8 100644
--- a/sbin/bioctl/bioctl.c
+++ b/sbin/bioctl/bioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bioctl.c,v 1.120 2014/04/22 20:42:01 tedu Exp $ */
+/* $OpenBSD: bioctl.c,v 1.121 2014/07/20 01:38:40 guenther Exp $ */
/*
* Copyright (c) 2004, 2005 Marco Peereboom
@@ -926,8 +926,9 @@ bio_createraid(u_int16_t level, char *dev_list, char *key_disk)
if (fd == -1)
err(1, "could not open %s", key_disk);
if (fstat(fd, &sb) == -1) {
+ int saved_errno = errno;
close(fd);
- err(1, "could not stat %s", key_disk);
+ errc(1, saved_errno, "could not stat %s", key_disk);
}
close(fd);
create.bc_key_disk = sb.st_rdev;
@@ -1026,8 +1027,9 @@ bio_parse_devlist(char *lst, dev_t *dt)
if (fd == -1)
err(1, "could not open %s", dev);
if (fstat(fd, &sb) == -1) {
+ int saved_errno = errno;
close(fd);
- err(1, "could not stat %s", dev);
+ errc(1, saved_errno, "could not stat %s", dev);
}
close(fd);
dt[no_dev] = sb.st_rdev;
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index e3daa538332..6955b45db66 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.195 2014/05/05 16:33:34 krw Exp $ */
+/* $OpenBSD: disklabel.c,v 1.196 2014/07/20 01:38:40 guenther Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -816,9 +816,9 @@ edit(struct disklabel *lp, int f)
u_int64_t total_sectors, starting_sector, ending_sector;
if ((fd = mkstemp(tmpfil)) == -1 || (fp = fdopen(fd, "w")) == NULL) {
+ warn("%s", tmpfil);
if (fd != -1)
close(fd);
- warn("%s", tmpfil);
return (1);
}
display(fp, lp, 0, 1);
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);
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index 1ac0d939fd8..46966278fc3 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dirs.c,v 1.35 2013/04/25 06:43:20 otto Exp $ */
+/* $OpenBSD: dirs.c,v 1.36 2014/07/20 01:38:40 guenther Exp $ */
/* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $ */
/*
@@ -45,6 +45,7 @@
#include <protocols/dumprestore.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <stdio.h>
@@ -148,9 +149,11 @@ extractdirs(int genmode)
} else
fd = open(dirfile, O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1 || (df = fdopen(fd, "w")) == NULL) {
+ int saved_errno = errno;
if (fd != -1)
close(fd);
- err(1, "cannot create directory temporary %s", dirfile);
+ errc(1, saved_errno,
+ "cannot create directory temporary %s", dirfile);
}
if (genmode != 0) {
(void)snprintf(modefile, sizeof(modefile), "%s/rstmode%lld",
@@ -161,9 +164,11 @@ extractdirs(int genmode)
} else
fd = open(modefile, O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1 || (mf = fdopen(fd, "w")) == NULL) {
+ int saved_errno = errno;
if (fd != -1)
close(fd);
- err(1, "cannot create modefile %s", modefile);
+ errc(1, saved_errno,
+ "cannot create modefile %s", modefile);
}
}
nulldir.d_ino = 0;