summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs/inode.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-01-16 06:39:28 +0000
committerderaadt <deraadt@openbsd.org>2015-01-16 06:39:28 +0000
commitb9fc9a728fce9c4289b7e9a992665e28d5629a54 (patch)
tree72b2433e418dfa1aef5fcf8305617b97979a25d8 /sbin/fsck_ffs/inode.c
parentimprove checksum parsing slightly. now handles filenames with spaces. (diff)
downloadwireguard-openbsd-b9fc9a728fce9c4289b7e9a992665e28d5629a54.tar.xz
wireguard-openbsd-b9fc9a728fce9c4289b7e9a992665e28d5629a54.zip
Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
Diffstat (limited to 'sbin/fsck_ffs/inode.c')
-rw-r--r--sbin/fsck_ffs/inode.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index c38c05a2d40..13a8be66561 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inode.c,v 1.44 2014/10/08 16:28:38 deraadt Exp $ */
+/* $OpenBSD: inode.c,v 1.45 2015/01/16 06:39:57 deraadt Exp $ */
/* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXFRAG setbit btodb */
#include <sys/time.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
@@ -42,11 +42,15 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "fsck.h"
#include "fsutil.h"
#include "extern.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
static ino_t startinum;
static int iblock(struct inodesc *, long, off_t);
@@ -59,7 +63,7 @@ ckinode(union dinode *dp, struct inodesc *idesc)
off_t sizepb, remsize;
mode_t mode;
int i;
- char pathbuf[MAXPATHLEN + 1];
+ char pathbuf[PATH_MAX + 1];
if (idesc->id_fix != IGNORE)
idesc->id_fix = DONTKNOW;
@@ -151,7 +155,7 @@ iblock(struct inodesc *idesc, long ilevel, off_t isize)
int i, n, (*func)(struct inodesc *), nif;
off_t sizepb;
char buf[BUFSIZ];
- char pathbuf[MAXPATHLEN + 1];
+ char pathbuf[PATH_MAX + 1];
union dinode *dp;
if (idesc->id_type == ADDR) {
@@ -598,8 +602,8 @@ allocino(ino_t request, int type)
/* If necessary, extend the inoinfo array. grow exponentially */
if ((ino % sblock.fs_ipg) >= (uint64_t)inostathead[cg].il_numalloced) {
unsigned long newalloced, i;
- newalloced = MIN(sblock.fs_ipg,
- MAX(2 * inostathead[cg].il_numalloced, 10));
+ newalloced = MINIMUM(sblock.fs_ipg,
+ MAXIMUM(2 * inostathead[cg].il_numalloced, 10));
info = calloc(newalloced, sizeof(struct inostat));
if (info == NULL) {
pwarn("cannot alloc %zu bytes to extend inoinfo\n",