1*0a6a1f1dSLionel Sambuc /* $NetBSD: buf.h,v 1.10 2015/03/29 05:52:59 agc Exp $ */ 29f988b79SJean-Baptiste Boric 39f988b79SJean-Baptiste Boric /* 49f988b79SJean-Baptiste Boric * Copyright (c) 2001 Wasabi Systems, Inc. 59f988b79SJean-Baptiste Boric * All rights reserved. 69f988b79SJean-Baptiste Boric * 79f988b79SJean-Baptiste Boric * Written by Luke Mewburn for Wasabi Systems, Inc. 89f988b79SJean-Baptiste Boric * 99f988b79SJean-Baptiste Boric * Redistribution and use in source and binary forms, with or without 109f988b79SJean-Baptiste Boric * modification, are permitted provided that the following conditions 119f988b79SJean-Baptiste Boric * are met: 129f988b79SJean-Baptiste Boric * 1. Redistributions of source code must retain the above copyright 139f988b79SJean-Baptiste Boric * notice, this list of conditions and the following disclaimer. 149f988b79SJean-Baptiste Boric * 2. Redistributions in binary form must reproduce the above copyright 159f988b79SJean-Baptiste Boric * notice, this list of conditions and the following disclaimer in the 169f988b79SJean-Baptiste Boric * documentation and/or other materials provided with the distribution. 179f988b79SJean-Baptiste Boric * 3. All advertising materials mentioning features or use of this software 189f988b79SJean-Baptiste Boric * must display the following acknowledgement: 199f988b79SJean-Baptiste Boric * This product includes software developed for the NetBSD Project by 209f988b79SJean-Baptiste Boric * Wasabi Systems, Inc. 219f988b79SJean-Baptiste Boric * 4. The name of Wasabi Systems, Inc. may not be used to endorse 229f988b79SJean-Baptiste Boric * or promote products derived from this software without specific prior 239f988b79SJean-Baptiste Boric * written permission. 249f988b79SJean-Baptiste Boric * 259f988b79SJean-Baptiste Boric * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 269f988b79SJean-Baptiste Boric * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 279f988b79SJean-Baptiste Boric * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 289f988b79SJean-Baptiste Boric * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 299f988b79SJean-Baptiste Boric * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 309f988b79SJean-Baptiste Boric * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 319f988b79SJean-Baptiste Boric * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 329f988b79SJean-Baptiste Boric * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 339f988b79SJean-Baptiste Boric * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 349f988b79SJean-Baptiste Boric * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 359f988b79SJean-Baptiste Boric * POSSIBILITY OF SUCH DAMAGE. 369f988b79SJean-Baptiste Boric */ 379f988b79SJean-Baptiste Boric 389f988b79SJean-Baptiste Boric #ifndef _FFS_BUF_H 399f988b79SJean-Baptiste Boric #define _FFS_BUF_H 409f988b79SJean-Baptiste Boric 419f988b79SJean-Baptiste Boric #include <sys/param.h> 429f988b79SJean-Baptiste Boric #include <sys/queue.h> 439f988b79SJean-Baptiste Boric 449f988b79SJean-Baptiste Boric #include <stdio.h> 459f988b79SJean-Baptiste Boric #include <string.h> 469f988b79SJean-Baptiste Boric #include <errno.h> 479f988b79SJean-Baptiste Boric #include <time.h> 489f988b79SJean-Baptiste Boric #include <stddef.h> 499f988b79SJean-Baptiste Boric #include <stdlib.h> 509f988b79SJean-Baptiste Boric #include <err.h> 519f988b79SJean-Baptiste Boric 529f988b79SJean-Baptiste Boric struct componentname { 539f988b79SJean-Baptiste Boric char *cn_nameptr; 549f988b79SJean-Baptiste Boric size_t cn_namelen; 559f988b79SJean-Baptiste Boric }; 569f988b79SJean-Baptiste Boric 579f988b79SJean-Baptiste Boric struct makefs_fsinfo; 589f988b79SJean-Baptiste Boric struct vnode { 599f988b79SJean-Baptiste Boric struct makefs_fsinfo *fs; 609f988b79SJean-Baptiste Boric void *v_data; 619f988b79SJean-Baptiste Boric }; 629f988b79SJean-Baptiste Boric 639f988b79SJean-Baptiste Boric #define vput(a) ((void)(a)) 649f988b79SJean-Baptiste Boric 659f988b79SJean-Baptiste Boric struct buf { 669f988b79SJean-Baptiste Boric void * b_data; 679f988b79SJean-Baptiste Boric long b_bufsize; 689f988b79SJean-Baptiste Boric long b_bcount; 699f988b79SJean-Baptiste Boric daddr_t b_blkno; 709f988b79SJean-Baptiste Boric daddr_t b_lblkno; 719f988b79SJean-Baptiste Boric struct makefs_fsinfo * b_fs; 729f988b79SJean-Baptiste Boric 739f988b79SJean-Baptiste Boric TAILQ_ENTRY(buf) b_tailq; 749f988b79SJean-Baptiste Boric }; 759f988b79SJean-Baptiste Boric 769f988b79SJean-Baptiste Boric struct kauth_cred; 779f988b79SJean-Baptiste Boric void bcleanup(void); 78*0a6a1f1dSLionel Sambuc int bread(struct vnode *, daddr_t, int, int, struct buf **); 799f988b79SJean-Baptiste Boric void brelse(struct buf *, int); 809f988b79SJean-Baptiste Boric int bwrite(struct buf *); 819f988b79SJean-Baptiste Boric struct buf * getblk(struct vnode *, daddr_t, int, int, int); 829f988b79SJean-Baptiste Boric 839f988b79SJean-Baptiste Boric #define bdwrite(bp) bwrite(bp) 849f988b79SJean-Baptiste Boric #define clrbuf(bp) memset((bp)->b_data, 0, (u_int)(bp)->b_bcount) 859f988b79SJean-Baptiste Boric 869f988b79SJean-Baptiste Boric #define B_MODIFY 0 879f988b79SJean-Baptiste Boric #define BC_AGE 0 889f988b79SJean-Baptiste Boric 899f988b79SJean-Baptiste Boric #define min(a, b) MIN((a), (b)) 909f988b79SJean-Baptiste Boric #define microtime(tv) gettimeofday((tv), NULL) 919f988b79SJean-Baptiste Boric #define KASSERT(a) 929f988b79SJean-Baptiste Boric #define IO_SYNC 1 939f988b79SJean-Baptiste Boric 949f988b79SJean-Baptiste Boric struct pool { 959f988b79SJean-Baptiste Boric size_t size; 969f988b79SJean-Baptiste Boric }; 979f988b79SJean-Baptiste Boric 989f988b79SJean-Baptiste Boric #define pool_init(p, s, a1, a2, a3, a4, a5, a6) (p)->size = (s) 999f988b79SJean-Baptiste Boric #define pool_get(p, f) ecalloc(1, (p)->size) 1009f988b79SJean-Baptiste Boric #define pool_put(p, a) free(a) 1019f988b79SJean-Baptiste Boric #define pool_destroy(p) 1029f988b79SJean-Baptiste Boric 1039f988b79SJean-Baptiste Boric #define MALLOC_DECLARE(a) 1049f988b79SJean-Baptiste Boric #define malloc_type_attach(a) 1059f988b79SJean-Baptiste Boric #define malloc_type_detach(a) 1069f988b79SJean-Baptiste Boric 1079f988b79SJean-Baptiste Boric #define mutex_enter(m) 1089f988b79SJean-Baptiste Boric #define mutex_exit(m) 1099f988b79SJean-Baptiste Boric #define mutex_init(m, t, i) 1109f988b79SJean-Baptiste Boric #define mutex_destroy(m) 1119f988b79SJean-Baptiste Boric 1129f988b79SJean-Baptiste Boric #define desiredvnodes 10000 1139f988b79SJean-Baptiste Boric #define NOCRED NULL 1149f988b79SJean-Baptiste Boric #define DEV_BSHIFT 9 1159f988b79SJean-Baptiste Boric 1169f988b79SJean-Baptiste Boric #endif /* _FFS_BUF_H */ 117