summaryrefslogtreecommitdiff
path: root/sbin/bioctl/bioctl.c
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/bioctl/bioctl.c
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/bioctl/bioctl.c')
-rw-r--r--sbin/bioctl/bioctl.c8
1 files changed, 5 insertions, 3 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;