pc_node.h revision 2972:10096047b1c0
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26#ifndef _SYS_FS_PC_NODE_H 27#define _SYS_FS_PC_NODE_H 28 29#pragma ident "%Z%%M% %I% %E% SMI" 30 31#ifdef __cplusplus 32extern "C" { 33#endif 34 35#include <vm/page.h> 36#include <sys/buf.h> 37#include <sys/vnode.h> 38 39/* 40 * This overlays the fid structure (see vfs.h) 41 * 42 * 10 bytes max. 43 */ 44struct pc_fid { 45 ushort_t pcfid_len; 46 uint32_t pcfid_block; /* dblock containing directory entry */ 47 uint16_t pcfid_offset; /* offset within block of entry */ 48 uint16_t pcfid_ctime; /* creation time of entry (~= i_gen) */ 49}; 50 51struct pcnode { 52 struct pcnode *pc_forw; /* active list ptrs, must be first */ 53 struct pcnode *pc_back; 54 int pc_flags; /* see below */ 55 struct vnode *pc_vn; /* vnode for pcnode */ 56 uint_t pc_size; /* size of file */ 57 pc_cluster32_t pc_scluster; /* starting cluster of file */ 58 daddr_t pc_eblkno; /* disk blkno for entry */ 59 int pc_eoffset; /* offset in disk block of entry */ 60 struct pcdir pc_entry; /* directory entry of file */ 61 pc_cluster32_t pc_lcluster; /* last cluster visited */ 62 daddr_t pc_lindex; /* index of last cluster visited */ 63}; 64 65/* 66 * flags 67 */ 68#define PC_MOD 0x01 /* file data has been modified */ 69#define PC_CHG 0x02 /* node data has been changed */ 70#define PC_INVAL 0x04 /* node is invalid */ 71#define PC_EXTERNAL 0x08 /* vnode ref is held externally */ 72#define PC_ACC 0x10 /* file data has been accessed */ 73#define PC_RELEHOLD 0x80 /* node is being released */ 74 75#define PCTOV(PCP) ((PCP)->pc_vn) 76#define VTOPC(VP) ((struct pcnode *)((VP)->v_data)) 77 78/* 79 * Make a unique integer for a file 80 */ 81#define pc_makenodeid(BN, OFF, ATTR, SCLUSTER, ENTPS) \ 82 (ino_t)((ATTR) & PCA_DIR ? \ 83 (uint32_t)(-(SCLUSTER) - 1) : \ 84 ((BN) * (ENTPS)) + ((OFF) / sizeof (struct pcdir))) 85 86#define NPCHASH 1 87 88#if NPCHASH == 1 89#define PCFHASH(FSP, BN, O) 0 90#define PCDHASH(FSP, SC) 0 91#else 92#define PCFHASH(FSP, BN, O) (((unsigned)FSP + BN + O) % NPCHASH) 93#define PCDHASH(FSP, SC) (((unsigned)FSP + SC) % NPCHASH) 94#endif 95 96struct pchead { 97 struct pcnode *pch_forw; 98 struct pcnode *pch_back; 99}; 100 101/* 102 * pcnode file and directory operations vectors 103 */ 104extern struct vnodeops *pcfs_fvnodeops; 105extern struct vnodeops *pcfs_dvnodeops; 106extern const struct fs_operation_def pcfs_fvnodeops_template[]; 107extern const struct fs_operation_def pcfs_dvnodeops_template[]; 108extern struct pchead pcfhead[]; 109extern struct pchead pcdhead[]; 110 111/* 112 * pcnode routines 113 */ 114extern void pc_init(void); 115extern struct pcnode *pc_getnode(struct pcfs *, daddr_t, int, struct pcdir *); 116extern void pc_rele(struct pcnode *); 117extern void pc_mark_mod(struct pcnode *); 118extern void pc_mark_acc(struct pcnode *); 119extern int pc_nodesync(struct pcnode *); 120extern int pc_nodeupdate(struct pcnode *); 121extern int pc_bmap(struct pcnode *, daddr_t, daddr_t *, uint_t *); 122 123extern int pc_balloc(struct pcnode *, daddr_t, int, daddr_t *); 124extern int pc_bfree(struct pcnode *, pc_cluster32_t); 125extern int pc_verify(struct pcfs *); 126extern void pc_diskchanged(struct pcfs *); 127extern void pc_mark_irrecov(struct pcfs *); 128 129extern int pc_dirlook(struct pcnode *, char *, struct pcnode **); 130extern int pc_direnter(struct pcnode *, char *, struct vattr *, 131 struct pcnode **); 132extern int pc_dirremove(struct pcnode *, char *, struct vnode *, enum vtype); 133extern int pc_rename(struct pcnode *, struct pcnode *, char *, char *); 134extern int pc_blkatoff(struct pcnode *, offset_t, struct buf **, 135 struct pcdir **); 136extern int pc_truncate(struct pcnode *, uint_t); 137extern int pc_fileclsize(struct pcfs *, pc_cluster32_t, pc_cluster32_t *); 138extern int pcfs_putapage(struct vnode *, page_t *, u_offset_t *, size_t *, int, 139 struct cred *); 140extern void pc_badfs(struct pcfs *); 141 142#ifdef __cplusplus 143} 144#endif 145 146#endif /* _SYS_FS_PC_NODE_H */ 147