-/* $OpenBSD: ffs.c,v 1.33 2021/09/01 15:19:00 deraadt Exp $ */
+/* $OpenBSD: ffs.c,v 1.34 2021/10/06 00:40:39 deraadt Exp $ */
/* $NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $ */
/*
* @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95
*/
+#include <sys/param.h> /* roundup DEV_BSIZE */
#include <sys/types.h>
#include <sys/disklabel.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
+#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
if (fsopts->sectorsize == -1)
fsopts->sectorsize = DFL_SECSIZE;
if (ffs_opts->fsize == -1)
- ffs_opts->fsize = MAX(DFL_FRAGSIZE, fsopts->sectorsize);
+ ffs_opts->fsize = MAXIMUM(DFL_FRAGSIZE, fsopts->sectorsize);
if (ffs_opts->bsize == -1)
- ffs_opts->bsize = MIN(DFL_BLKSIZE, 8 * ffs_opts->fsize);
+ ffs_opts->bsize = MINIMUM(DFL_BLKSIZE, 8 * ffs_opts->fsize);
/* fsopts->density is set below */
/* XXX ondisk32 */
if (ffs_opts->maxbpg == -1)
if (bufrem > 0)
buf = ecalloc(1, bufsize);
while (bufrem > 0) {
- i = write(fsopts->fd, buf, MIN(bufsize, bufrem));
+ i = write(fsopts->fd, buf, MINIMUM(bufsize, bufrem));
if (i == -1) {
warn("zeroing image, %lld bytes to go",
(long long)bufrem);
dirbuf_t dirbuf;
union dinode din;
void *membuf;
- char path[MAXPATHLEN + 1];
+ char path[PATH_MAX + 1];
ffs_opt_t *ffs_opts = fsopts->fs_specific;
assert(dir != NULL);
chunk = 0;
for (bufleft = DIP(din, size); bufleft > 0; bufleft -= chunk) {
- chunk = MIN(bufleft, ffs_opts->bsize);
+ chunk = MINIMUM(bufleft, ffs_opts->bsize);
if (!isfile)
;
else if ((nread = read(ffd, fbuf, chunk)) == -1)
-/* $OpenBSD: buf.c,v 1.6 2016/12/17 16:26:46 krw Exp $ */
+/* $OpenBSD: buf.c,v 1.7 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: buf.c,v 1.24 2016/06/24 19:24:11 christos Exp $ */
/*
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <assert.h>
-/* $OpenBSD: buf.h,v 1.4 2016/10/17 01:16:22 tedu Exp $ */
+/* $OpenBSD: buf.h,v 1.5 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: buf.h,v 1.10 2015/03/29 05:52:59 agc Exp $ */
/*
#ifndef _FFS_BUF_H
#define _FFS_BUF_H
-#include <sys/param.h>
#include <sys/queue.h>
#include <stdio.h>
#define B_MODIFY 0
#define BC_AGE 0
-#define min(a, b) MIN((a), (b))
#define microtime(tv) gettimeofday((tv), NULL)
#define KASSERT(a)
#define IO_SYNC 1
-/* $OpenBSD: ffs_alloc.c,v 1.13 2016/12/17 16:26:46 krw Exp $ */
+/* $OpenBSD: ffs_alloc.c,v 1.14 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: ffs_alloc.c,v 1.29 2016/06/24 19:24:11 christos Exp $ */
/* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */
* @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95
*/
-#include <sys/param.h>
-
-#include <errno.h>
+#include <sys/param.h> /* DEV_BSIZE setbit clrbit NBBY howmany */
+#include <sys/types.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
#include "ffs/ufs_inode.h"
#include "ffs/ffs_extern.h"
+#include <errno.h>
static int scanc(u_int, const u_char *, const u_char *, int);
-/* $OpenBSD: ffs_subr.c,v 1.4 2016/10/22 19:43:50 natano Exp $ */
+/* $OpenBSD: ffs_subr.c,v 1.5 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: ffs_subr.c,v 1.49 2016/05/07 11:59:08 maxv Exp $ */
/*
* @(#)ffs_subr.c 8.5 (Berkeley) 3/21/95
*/
-#include <sys/param.h>
-
+#include <sys/param.h> /* setbit clrbit NBBY */
+#include <sys/types.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
+#include <limits.h>
#include <err.h>
#include "ffs/ffs_extern.h"
-/* $OpenBSD: ffs_tables.c,v 1.2 2016/10/22 16:51:52 natano Exp $ */
+/* $OpenBSD: ffs_tables.c,v 1.3 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: ffs_tables.c,v 1.2 1994/06/29 06:46:35 cgd Exp $ */
/*
* @(#)ffs_tables.c 8.1 (Berkeley) 6/11/93
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <ufs/ffs/fs.h>
+#include <stdlib.h>
+
/*
* Bit patterns for identifying fragments in the block map
* used as ((map & around) == inside)
-/* $OpenBSD: mkfs.c,v 1.13 2016/11/11 09:54:07 natano Exp $ */
+/* $OpenBSD: mkfs.c,v 1.14 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: mkfs.c,v 1.34 2016/06/24 19:24:11 christos Exp $ */
/*
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* roundup howmany setbit */
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
minfree = ffs_opts->minfree;
opt = ffs_opts->optimization;
density = ffs_opts->density;
- maxcontig = MAX(1, MIN(MAXBSIZE, FFS_MAXBSIZE) / bsize);
+ maxcontig = MAXIMUM(1, MINIMUM(MAXBSIZE, FFS_MAXBSIZE) / bsize);
maxbpg = ffs_opts->maxbpg;
avgfilesize = ffs_opts->avgfilesize;
avgfpdir = ffs_opts->avgfpdir;
}
if (sblock.fs_maxcontig > 1)
- sblock.fs_contigsumsize = MIN(sblock.fs_maxcontig,FS_MAXCONTIG);
+ sblock.fs_contigsumsize = MINIMUM(sblock.fs_maxcontig,FS_MAXCONTIG);
sblock.fs_bmask = ~(sblock.fs_bsize - 1);
sblock.fs_fmask = ~(sblock.fs_fsize - 1);
*/
origdensity = density;
for (;;) {
- fragsperinode = MAX(numfrags(&sblock, density), 1);
+ fragsperinode = MAXIMUM(numfrags(&sblock, density), 1);
minfpg = fragsperinode * INOPB(&sblock);
if (minfpg > sblock.fs_size)
minfpg = sblock.fs_size;
-/* $OpenBSD: ufs_bmap.c,v 1.6 2016/12/17 16:26:46 krw Exp $ */
+/* $OpenBSD: ufs_bmap.c,v 1.7 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: ufs_bmap.c,v 1.18 2013/06/19 17:51:27 dholland Exp $ */
/* From: NetBSD: ufs_bmap.c,v 1.14 2001/11/08 05:00:51 chs Exp */
* @(#)ufs_bmap.c 8.8 (Berkeley) 8/11/95
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <assert.h>
-/* $OpenBSD: makefs.h,v 1.12 2016/12/17 16:12:15 krw Exp $ */
+/* $OpenBSD: makefs.h,v 1.13 2021/10/06 00:40:39 deraadt Exp $ */
/* $NetBSD: makefs.h,v 1.36 2015/11/25 00:48:49 christos Exp $ */
/*
#define DEFAULT_FSTYPE "ffs"
#endif
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
/* xmalloc.c */
void *emalloc(size_t);
-/* $OpenBSD: msdos.c,v 1.12 2021/09/01 15:19:00 deraadt Exp $ */
+/* $OpenBSD: msdos.c,v 1.13 2021/10/06 00:40:39 deraadt Exp $ */
/* $NetBSD: msdos.c,v 1.16 2016/01/30 09:59:27 mlelstv Exp $ */
/*-
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/types.h>
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include <string.h>
#include "ffs/buf.h"
* XXX: pick up other options from the msdos specific ones?
* Is minsize right here?
*/
- msdos_opt->create_size = MAX(msdos_opt->create_size,
+ msdos_opt->create_size = MAXIMUM(msdos_opt->create_size,
fsopts->minsize);
msdos_opt->offset = fsopts->offset;
if (msdos_opt->bytes_per_sector == 0) {
fsnode *parent, fsinfo_t *fsopts)
{
fsnode *cur;
- char pbuf[MAXPATHLEN];
+ char pbuf[PATH_MAX];
assert(dir != NULL);
assert(root != NULL);
-/* $OpenBSD: mkfs_msdos.c,v 1.5 2017/11/02 11:06:54 jca Exp $ */
+/* $OpenBSD: mkfs_msdos.c,v 1.6 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: mkfs_msdos.c,v 1.10 2016/04/03 11:00:13 mlelstv Exp $ */
/*
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* powerof2 */
+#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
+#include <limits.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
int
mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
{
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
struct stat sb;
struct timeval tv;
struct bpb bpb;
x = bpb.bkbs + 1;
}
if (!bpb.res)
- bpb.res = o.fat_type == 32 ? MAX(x, MAX(16384 / bpb.bps, 4)) : x;
+ bpb.res = o.fat_type == 32 ? MAXIMUM(x, MAXIMUM(16384 / bpb.bps, 4)) : x;
else if (bpb.res < x) {
warnx("too few reserved sectors (need %d have %d)", x, bpb.res);
return -1;
x1 += x * bpb.nft;
x = (u_int64_t)(bpb.bsec - x1) * bpb.bps * NPB /
(bpb.spc * bpb.bps * NPB + o.fat_type / BPN * bpb.nft);
- x2 = howmany((RESFTE + MIN(x, maxcls(o.fat_type))) * (o.fat_type / BPN),
+ x2 = howmany((RESFTE + MINIMUM(x, maxcls(o.fat_type))) * (o.fat_type / BPN),
bpb.bps * NPB);
if (!bpb.bspf) {
bpb.bspf = x2;
-/* $OpenBSD: msdosfs_conv.c,v 1.1 2016/10/18 17:05:30 natano Exp $ */
+/* $OpenBSD: msdosfs_conv.c,v 1.2 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: msdosfs_conv.c,v 1.24 1997/10/17 11:23:54 ws Exp $ */
/*-
/*
* System include files.
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <sys/dirent.h>
#include <sys/lock.h>
-/* $OpenBSD: msdosfs_denode.c,v 1.6 2016/10/22 22:20:24 natano Exp $ */
+/* $OpenBSD: msdosfs_denode.c,v 1.7 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: msdosfs_denode.c,v 1.7 2015/03/29 05:52:59 agc Exp $ */
/*-
* October 1992
*/
-#include <sys/param.h>
#include "ffs/buf.h"
-/* $OpenBSD: msdosfs_fat.c,v 1.5 2018/04/26 12:42:51 guenther Exp $ */
+/* $OpenBSD: msdosfs_fat.c,v 1.6 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $ */
/*-
* October 1992
*/
+#include <sys/types.h>
+#include <sys/time.h>
+
/*
* kernel include files.
*/
-#include <sys/param.h>
#include "ffs/buf.h"
#include "msdos/direntry.h"
#include "msdos/denode.h"
#include "msdos/fat.h"
+#include "makefs.h"
/*
* Fat cache stats.
u_long bn, size;
bn = ofs / pmp->pm_fatblocksize * pmp->pm_fatblocksec;
- size = min(pmp->pm_fatblocksec, pmp->pm_FATsecs - bn)
+ size = MINIMUM(pmp->pm_fatblocksec, pmp->pm_FATsecs - bn)
* pmp->pm_BytesPerSec;
bn += pmp->pm_fatblk + pmp->pm_curfat * pmp->pm_FATsecs;
if (cnp)
*cnp = MSDOSFSROOT;
if (sp)
- *sp = min(pmp->pm_bpcluster,
+ *sp = MINIMUM(pmp->pm_bpcluster,
dep->de_FileSize - de_cn2off(pmp, findcn));
DPRINTF(("%s(root, bn=%lu, cn=%u)\n", __func__,
pmp->pm_rootdirblk + de_cn2bn(pmp, findcn),
-/* $OpenBSD: msdosfs_lookup.c,v 1.3 2017/08/31 12:03:02 otto Exp $ */
+/* $OpenBSD: msdosfs_lookup.c,v 1.4 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: msdosfs_lookup.c,v 1.35 2016/01/30 09:59:27 mlelstv Exp $ */
/*-
* October 1992
*/
-#include <sys/param.h>
#include "ffs/buf.h"
-/* $OpenBSD: msdosfs_vfsops.c,v 1.12 2019/09/04 14:40:22 cheloha Exp $ */
+/* $OpenBSD: msdosfs_vfsops.c,v 1.13 2021/10/06 00:40:41 deraadt Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
* October 1992
*/
-#include <sys/param.h>
+
+#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include "ffs/buf.h"
-/* $OpenBSD: msdosfs_vnops.c,v 1.8 2016/12/17 16:43:30 krw Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.9 2021/10/06 00:40:41 deraadt Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.17 2016/01/30 09:59:27 mlelstv Exp $ */
/*-
* October 1992
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
DPRINTF(("bread %d\n", error));
goto out;
}
- cpsize = MIN((nsize - offs), blsize - on);
+ cpsize = MINIMUM((nsize - offs), blsize - on);
memcpy((char *)bp->b_data + on, dat + offs, cpsize);
bwrite(bp);
offs += cpsize;