summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2005-01-07 21:57:11 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2005-01-07 21:57:11 +0000
commitd0efb854d58230fd14fa4651d7527cf34fdcf6f3 (patch)
tree5ab02b47560b641bc5395692a459b365c2ffc304 /sbin
parente4f4f347978b36c2a869622f384afba9e29fccac (diff)
Use fstatfs(), not statfs() to determine free space so if /var/crash
is a link we follow it. OK deraadt@ jcs@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/savecore/savecore.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 379f8aa69a0..d1bf1766ae8 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: savecore.c,v 1.41 2004/09/15 18:52:29 deraadt Exp $ */
+/* $OpenBSD: savecore.c,v 1.42 2005/01/07 21:57:10 millert Exp $ */
/* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */
/*-
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)savecore.c 8.3 (Berkeley) 1/2/94";
#else
-static char rcsid[] = "$OpenBSD: savecore.c,v 1.41 2004/09/15 18:52:29 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: savecore.c,v 1.42 2005/01/07 21:57:10 millert Exp $";
#endif
#endif /* not lint */
@@ -602,6 +602,7 @@ check_space(void)
struct stat st;
struct statfs fsbuf;
char buf[100], path[MAXPATHLEN];
+ int fd;
tkernel = kernel ? kernel : _PATH_UNIX;
if (stat(tkernel, &st) < 0) {
@@ -609,10 +610,11 @@ check_space(void)
exit(1);
}
kernelsize = st.st_blocks * S_BLKSIZE;
- if (statfs(dirn, &fsbuf) < 0) {
+ if ((fd = open(dirn, O_RDONLY, 0)) < 0 || fstatfs(fd, &fsbuf) < 0) {
syslog(LOG_ERR, "%s: %m", dirn);
exit(1);
}
+ close(fd);
spacefree = ((off_t)fsbuf.f_bavail * fsbuf.f_bsize) / 1024;
(void)snprintf(path, sizeof(path), "%s/minfree", dirn);