buf.h revision 1.13
11.13Sriastrad/*	$NetBSD: buf.h,v 1.13 2018/09/03 16:29:37 riastradh Exp $	*/
21.1Slukem
31.1Slukem/*
41.2Slukem * Copyright (c) 2001 Wasabi Systems, Inc.
51.1Slukem * All rights reserved.
61.1Slukem *
71.1Slukem * Written by Luke Mewburn for Wasabi Systems, Inc.
81.1Slukem *
91.1Slukem * Redistribution and use in source and binary forms, with or without
101.1Slukem * modification, are permitted provided that the following conditions
111.1Slukem * are met:
121.1Slukem * 1. Redistributions of source code must retain the above copyright
131.1Slukem *    notice, this list of conditions and the following disclaimer.
141.1Slukem * 2. Redistributions in binary form must reproduce the above copyright
151.1Slukem *    notice, this list of conditions and the following disclaimer in the
161.1Slukem *    documentation and/or other materials provided with the distribution.
171.1Slukem * 3. All advertising materials mentioning features or use of this software
181.1Slukem *    must display the following acknowledgement:
191.1Slukem *      This product includes software developed for the NetBSD Project by
201.1Slukem *      Wasabi Systems, Inc.
211.1Slukem * 4. The name of Wasabi Systems, Inc. may not be used to endorse
221.1Slukem *    or promote products derived from this software without specific prior
231.1Slukem *    written permission.
241.1Slukem *
251.1Slukem * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
261.1Slukem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
271.1Slukem * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
281.1Slukem * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
291.1Slukem * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
301.1Slukem * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
311.1Slukem * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
321.1Slukem * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
331.1Slukem * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
341.1Slukem * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
351.1Slukem * POSSIBILITY OF SUCH DAMAGE.
361.1Slukem */
371.1Slukem
381.1Slukem#ifndef _FFS_BUF_H
391.1Slukem#define	_FFS_BUF_H
401.1Slukem
411.1Slukem#include <sys/param.h>
421.1Slukem#include <sys/queue.h>
431.12Schristos#include <sys/stat.h>
441.1Slukem
451.3Schristos#include <stdio.h>
461.3Schristos#include <string.h>
471.3Schristos#include <errno.h>
481.3Schristos#include <time.h>
491.3Schristos#include <stddef.h>
501.3Schristos#include <stdlib.h>
511.3Schristos#include <err.h>
521.3Schristos
531.3Schristosstruct componentname {
541.3Schristos	char *cn_nameptr;
551.3Schristos	size_t cn_namelen;
561.3Schristos};
571.3Schristos
581.9Schristosstruct makefs_fsinfo;
591.3Schristosstruct vnode {
601.9Schristos	struct makefs_fsinfo *fs;
611.3Schristos	void *v_data;
621.3Schristos};
631.3Schristos
641.3Schristos#define vput(a) ((void)(a))
651.3Schristos
661.1Slukemstruct buf {
671.1Slukem	void *		b_data;
681.1Slukem	long		b_bufsize;
691.1Slukem	long		b_bcount;
701.1Slukem	daddr_t		b_blkno;
711.1Slukem	daddr_t		b_lblkno;
721.9Schristos	struct makefs_fsinfo * b_fs;
731.1Slukem
741.1Slukem	TAILQ_ENTRY(buf)	b_tailq;
751.1Slukem};
761.1Slukem
771.4Schristosstruct kauth_cred;
781.1Slukemvoid		bcleanup(void);
791.10Sagcint		bread(struct vnode *, daddr_t, int, int, struct buf **);
801.3Schristosvoid		brelse(struct buf *, int);
811.1Slukemint		bwrite(struct buf *);
821.3Schristosstruct buf *	getblk(struct vnode *, daddr_t, int, int, int);
831.1Slukem
841.1Slukem#define	bdwrite(bp)	bwrite(bp)
851.1Slukem#define	clrbuf(bp)	memset((bp)->b_data, 0, (u_int)(bp)->b_bcount)
861.1Slukem
871.3Schristos#define	B_MODIFY	0
881.3Schristos#define	BC_AGE		0
891.3Schristos
901.3Schristos#define min(a, b) MIN((a), (b))
911.11Schristos
921.13Sriastradstatic inline unsigned int
931.13Sriastraduimin(unsigned int a, unsigned int b)
941.13Sriastrad{
951.13Sriastrad
961.13Sriastrad	return (a < b ? a : b);
971.13Sriastrad}
981.13Sriastrad
991.13Sriastradstatic inline unsigned int
1001.13Sriastraduimax(unsigned int a, unsigned int b)
1011.13Sriastrad{
1021.13Sriastrad
1031.13Sriastrad	return (a > b ? a : b);
1041.13Sriastrad}
1051.13Sriastrad
1061.11Schristosstatic inline void
1071.11Schristosmicrotime(struct timeval *tv)
1081.11Schristos{
1091.11Schristos	extern struct stat stampst;
1101.11Schristos
1111.11Schristos	if (stampst.st_ino) {
1121.11Schristos		tv->tv_sec = stampst.st_mtime;
1131.11Schristos		tv->tv_usec = 0;
1141.11Schristos	} else {
1151.11Schristos	    gettimeofday((tv), NULL);
1161.11Schristos	}
1171.11Schristos}
1181.11Schristos
1191.3Schristos#define KASSERT(a)
1201.3Schristos#define IO_SYNC	1
1211.3Schristos
1221.3Schristosstruct pool {
1231.3Schristos	size_t size;
1241.3Schristos};
1251.3Schristos
1261.3Schristos#define pool_init(p, s, a1, a2, a3, a4, a5, a6)	(p)->size = (s)
1271.7Schristos#define pool_get(p, f)	ecalloc(1, (p)->size)
1281.3Schristos#define pool_put(p, a)	free(a)
1291.3Schristos#define pool_destroy(p)
1301.3Schristos
1311.3Schristos#define MALLOC_DECLARE(a)
1321.3Schristos#define malloc_type_attach(a)
1331.3Schristos#define malloc_type_detach(a)
1341.3Schristos
1351.3Schristos#define mutex_enter(m)
1361.3Schristos#define mutex_exit(m)
1371.3Schristos#define mutex_init(m, t, i)
1381.3Schristos#define mutex_destroy(m)
1391.3Schristos
1401.3Schristos#define desiredvnodes 10000
1411.4Schristos#define NOCRED NULL
1421.4Schristos#define DEV_BSHIFT 9
1431.3Schristos
1441.1Slukem#endif	/* _FFS_BUF_H */
145