17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 59bd42341Sfrankho * Common Development and Distribution License (the "License"). 69bd42341Sfrankho * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*d67944fbSScott Rotondo * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 239bd42341Sfrankho * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_FS_PC_NODE_H 277c478bd9Sstevel@tonic-gate #define _SYS_FS_PC_NODE_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <vm/page.h> 347c478bd9Sstevel@tonic-gate #include <sys/buf.h> 357c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 367c478bd9Sstevel@tonic-gate 37*d67944fbSScott Rotondo #ifdef _KERNEL 38*d67944fbSScott Rotondo #include <sys/vfs_opreg.h> 39*d67944fbSScott Rotondo #endif 40*d67944fbSScott Rotondo 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * This overlays the fid structure (see vfs.h) 437c478bd9Sstevel@tonic-gate * 447c478bd9Sstevel@tonic-gate * 10 bytes max. 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate struct pc_fid { 477c478bd9Sstevel@tonic-gate ushort_t pcfid_len; 487c478bd9Sstevel@tonic-gate uint32_t pcfid_block; /* dblock containing directory entry */ 497c478bd9Sstevel@tonic-gate uint16_t pcfid_offset; /* offset within block of entry */ 507c478bd9Sstevel@tonic-gate uint16_t pcfid_ctime; /* creation time of entry (~= i_gen) */ 517c478bd9Sstevel@tonic-gate }; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate struct pcnode { 547c478bd9Sstevel@tonic-gate struct pcnode *pc_forw; /* active list ptrs, must be first */ 557c478bd9Sstevel@tonic-gate struct pcnode *pc_back; 567c478bd9Sstevel@tonic-gate int pc_flags; /* see below */ 577c478bd9Sstevel@tonic-gate struct vnode *pc_vn; /* vnode for pcnode */ 587c478bd9Sstevel@tonic-gate uint_t pc_size; /* size of file */ 597c478bd9Sstevel@tonic-gate pc_cluster32_t pc_scluster; /* starting cluster of file */ 607c478bd9Sstevel@tonic-gate daddr_t pc_eblkno; /* disk blkno for entry */ 617c478bd9Sstevel@tonic-gate int pc_eoffset; /* offset in disk block of entry */ 627c478bd9Sstevel@tonic-gate struct pcdir pc_entry; /* directory entry of file */ 637c478bd9Sstevel@tonic-gate pc_cluster32_t pc_lcluster; /* last cluster visited */ 647c478bd9Sstevel@tonic-gate daddr_t pc_lindex; /* index of last cluster visited */ 657c478bd9Sstevel@tonic-gate }; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * flags 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate #define PC_MOD 0x01 /* file data has been modified */ 717c478bd9Sstevel@tonic-gate #define PC_CHG 0x02 /* node data has been changed */ 727c478bd9Sstevel@tonic-gate #define PC_INVAL 0x04 /* node is invalid */ 737c478bd9Sstevel@tonic-gate #define PC_EXTERNAL 0x08 /* vnode ref is held externally */ 747c478bd9Sstevel@tonic-gate #define PC_ACC 0x10 /* file data has been accessed */ 757c478bd9Sstevel@tonic-gate #define PC_RELEHOLD 0x80 /* node is being released */ 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #define PCTOV(PCP) ((PCP)->pc_vn) 787c478bd9Sstevel@tonic-gate #define VTOPC(VP) ((struct pcnode *)((VP)->v_data)) 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* 817c478bd9Sstevel@tonic-gate * Make a unique integer for a file 827c478bd9Sstevel@tonic-gate */ 837c478bd9Sstevel@tonic-gate #define pc_makenodeid(BN, OFF, ATTR, SCLUSTER, ENTPS) \ 847c478bd9Sstevel@tonic-gate (ino_t)((ATTR) & PCA_DIR ? \ 857c478bd9Sstevel@tonic-gate (uint32_t)(-(SCLUSTER) - 1) : \ 867c478bd9Sstevel@tonic-gate ((BN) * (ENTPS)) + ((OFF) / sizeof (struct pcdir))) 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate #define NPCHASH 1 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate #if NPCHASH == 1 917c478bd9Sstevel@tonic-gate #define PCFHASH(FSP, BN, O) 0 927c478bd9Sstevel@tonic-gate #define PCDHASH(FSP, SC) 0 937c478bd9Sstevel@tonic-gate #else 947c478bd9Sstevel@tonic-gate #define PCFHASH(FSP, BN, O) (((unsigned)FSP + BN + O) % NPCHASH) 957c478bd9Sstevel@tonic-gate #define PCDHASH(FSP, SC) (((unsigned)FSP + SC) % NPCHASH) 967c478bd9Sstevel@tonic-gate #endif 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate struct pchead { 997c478bd9Sstevel@tonic-gate struct pcnode *pch_forw; 1007c478bd9Sstevel@tonic-gate struct pcnode *pch_back; 1017c478bd9Sstevel@tonic-gate }; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * pcnode file and directory operations vectors 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate extern struct vnodeops *pcfs_fvnodeops; 1077c478bd9Sstevel@tonic-gate extern struct vnodeops *pcfs_dvnodeops; 108*d67944fbSScott Rotondo 109*d67944fbSScott Rotondo #ifdef _KERNEL 1107c478bd9Sstevel@tonic-gate extern const struct fs_operation_def pcfs_fvnodeops_template[]; 1117c478bd9Sstevel@tonic-gate extern const struct fs_operation_def pcfs_dvnodeops_template[]; 112*d67944fbSScott Rotondo #endif 113*d67944fbSScott Rotondo 1147c478bd9Sstevel@tonic-gate extern struct pchead pcfhead[]; 1157c478bd9Sstevel@tonic-gate extern struct pchead pcdhead[]; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * pcnode routines 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate extern void pc_init(void); 1217c478bd9Sstevel@tonic-gate extern struct pcnode *pc_getnode(struct pcfs *, daddr_t, int, struct pcdir *); 1227c478bd9Sstevel@tonic-gate extern void pc_rele(struct pcnode *); 123f127cb91Sfrankho extern void pc_mark_mod(struct pcfs *, struct pcnode *); 124f127cb91Sfrankho extern void pc_mark_acc(struct pcfs *, struct pcnode *); 1257c478bd9Sstevel@tonic-gate extern int pc_nodesync(struct pcnode *); 1267c478bd9Sstevel@tonic-gate extern int pc_nodeupdate(struct pcnode *); 1277c478bd9Sstevel@tonic-gate extern int pc_bmap(struct pcnode *, daddr_t, daddr_t *, uint_t *); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate extern int pc_balloc(struct pcnode *, daddr_t, int, daddr_t *); 1307c478bd9Sstevel@tonic-gate extern int pc_bfree(struct pcnode *, pc_cluster32_t); 1317c478bd9Sstevel@tonic-gate extern int pc_verify(struct pcfs *); 1327c478bd9Sstevel@tonic-gate extern void pc_diskchanged(struct pcfs *); 1337c478bd9Sstevel@tonic-gate extern void pc_mark_irrecov(struct pcfs *); 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate extern int pc_dirlook(struct pcnode *, char *, struct pcnode **); 1367c478bd9Sstevel@tonic-gate extern int pc_direnter(struct pcnode *, char *, struct vattr *, 1377c478bd9Sstevel@tonic-gate struct pcnode **); 138da6c28aaSamw extern int pc_dirremove(struct pcnode *, char *, struct vnode *, enum vtype, 139da6c28aaSamw caller_context_t *); 140da6c28aaSamw extern int pc_rename(struct pcnode *, struct pcnode *, char *, char *, 141da6c28aaSamw caller_context_t *); 1427c478bd9Sstevel@tonic-gate extern int pc_blkatoff(struct pcnode *, offset_t, struct buf **, 1437c478bd9Sstevel@tonic-gate struct pcdir **); 1447c478bd9Sstevel@tonic-gate extern int pc_truncate(struct pcnode *, uint_t); 1459bd42341Sfrankho extern int pc_fileclsize(struct pcfs *, pc_cluster32_t, pc_cluster32_t *); 1467c478bd9Sstevel@tonic-gate extern int pcfs_putapage(struct vnode *, page_t *, u_offset_t *, size_t *, int, 1477c478bd9Sstevel@tonic-gate struct cred *); 1487c478bd9Sstevel@tonic-gate extern void pc_badfs(struct pcfs *); 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1517c478bd9Sstevel@tonic-gate } 1527c478bd9Sstevel@tonic-gate #endif 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate #endif /* _SYS_FS_PC_NODE_H */ 155