xref: /onnv-gate/usr/src/uts/common/sys/fs/pc_node.h (revision 9694:78fafb281255)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52972Sfrankho  * Common Development and Distribution License (the "License").
62972Sfrankho  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*9694SScott.Rotondo@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
232972Sfrankho  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_FS_PC_NODE_H
270Sstevel@tonic-gate #define	_SYS_FS_PC_NODE_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <vm/page.h>
340Sstevel@tonic-gate #include <sys/buf.h>
350Sstevel@tonic-gate #include <sys/vnode.h>
360Sstevel@tonic-gate 
37*9694SScott.Rotondo@Sun.COM #ifdef _KERNEL
38*9694SScott.Rotondo@Sun.COM #include <sys/vfs_opreg.h>
39*9694SScott.Rotondo@Sun.COM #endif
40*9694SScott.Rotondo@Sun.COM 
410Sstevel@tonic-gate /*
420Sstevel@tonic-gate  * This overlays the fid structure (see vfs.h)
430Sstevel@tonic-gate  *
440Sstevel@tonic-gate  * 10 bytes max.
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate struct pc_fid {
470Sstevel@tonic-gate 	ushort_t	pcfid_len;
480Sstevel@tonic-gate 	uint32_t	pcfid_block;	/* dblock containing directory entry */
490Sstevel@tonic-gate 	uint16_t	pcfid_offset;	/* offset within block of entry */
500Sstevel@tonic-gate 	uint16_t	pcfid_ctime;	/* creation time of entry (~= i_gen) */
510Sstevel@tonic-gate };
520Sstevel@tonic-gate 
530Sstevel@tonic-gate struct pcnode {
540Sstevel@tonic-gate 	struct pcnode	*pc_forw;	/* active list ptrs, must be first */
550Sstevel@tonic-gate 	struct pcnode	*pc_back;
560Sstevel@tonic-gate 	int pc_flags;			/* see below */
570Sstevel@tonic-gate 	struct vnode	*pc_vn;		/* vnode for pcnode */
580Sstevel@tonic-gate 	uint_t pc_size;			/* size of file */
590Sstevel@tonic-gate 	pc_cluster32_t	pc_scluster;	/* starting cluster of file */
600Sstevel@tonic-gate 	daddr_t pc_eblkno;		/* disk blkno for entry */
610Sstevel@tonic-gate 	int pc_eoffset;			/* offset in disk block of entry */
620Sstevel@tonic-gate 	struct pcdir pc_entry;		/* directory entry of file */
630Sstevel@tonic-gate 	pc_cluster32_t	pc_lcluster;	/* last cluster visited */
640Sstevel@tonic-gate 	daddr_t		pc_lindex;	/* index of last cluster visited */
650Sstevel@tonic-gate };
660Sstevel@tonic-gate 
670Sstevel@tonic-gate /*
680Sstevel@tonic-gate  * flags
690Sstevel@tonic-gate  */
700Sstevel@tonic-gate #define	PC_MOD		0x01		/* file data has been modified */
710Sstevel@tonic-gate #define	PC_CHG		0x02		/* node data has been changed */
720Sstevel@tonic-gate #define	PC_INVAL	0x04		/* node is invalid */
730Sstevel@tonic-gate #define	PC_EXTERNAL	0x08		/* vnode ref is held externally */
740Sstevel@tonic-gate #define	PC_ACC		0x10		/* file data has been accessed */
750Sstevel@tonic-gate #define	PC_RELEHOLD	0x80		/* node is being released */
760Sstevel@tonic-gate 
770Sstevel@tonic-gate #define	PCTOV(PCP)	((PCP)->pc_vn)
780Sstevel@tonic-gate #define	VTOPC(VP)	((struct pcnode *)((VP)->v_data))
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /*
810Sstevel@tonic-gate  * Make a unique integer for a file
820Sstevel@tonic-gate  */
830Sstevel@tonic-gate #define	pc_makenodeid(BN, OFF, ATTR, SCLUSTER, ENTPS) \
840Sstevel@tonic-gate 	(ino_t)((ATTR) & PCA_DIR ? \
850Sstevel@tonic-gate 		(uint32_t)(-(SCLUSTER) - 1) : \
860Sstevel@tonic-gate 		((BN) * (ENTPS)) + ((OFF) / sizeof (struct pcdir)))
870Sstevel@tonic-gate 
880Sstevel@tonic-gate #define	NPCHASH 1
890Sstevel@tonic-gate 
900Sstevel@tonic-gate #if NPCHASH == 1
910Sstevel@tonic-gate #define	PCFHASH(FSP, BN, O)	0
920Sstevel@tonic-gate #define	PCDHASH(FSP, SC)	0
930Sstevel@tonic-gate #else
940Sstevel@tonic-gate #define	PCFHASH(FSP, BN, O)	(((unsigned)FSP + BN + O) % NPCHASH)
950Sstevel@tonic-gate #define	PCDHASH(FSP, SC)	(((unsigned)FSP + SC) % NPCHASH)
960Sstevel@tonic-gate #endif
970Sstevel@tonic-gate 
980Sstevel@tonic-gate struct pchead {
990Sstevel@tonic-gate 	struct pcnode *pch_forw;
1000Sstevel@tonic-gate 	struct pcnode *pch_back;
1010Sstevel@tonic-gate };
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate /*
1040Sstevel@tonic-gate  * pcnode file and directory operations vectors
1050Sstevel@tonic-gate  */
1060Sstevel@tonic-gate extern struct vnodeops *pcfs_fvnodeops;
1070Sstevel@tonic-gate extern struct vnodeops *pcfs_dvnodeops;
108*9694SScott.Rotondo@Sun.COM 
109*9694SScott.Rotondo@Sun.COM #ifdef _KERNEL
1100Sstevel@tonic-gate extern const struct fs_operation_def pcfs_fvnodeops_template[];
1110Sstevel@tonic-gate extern const struct fs_operation_def pcfs_dvnodeops_template[];
112*9694SScott.Rotondo@Sun.COM #endif
113*9694SScott.Rotondo@Sun.COM 
1140Sstevel@tonic-gate extern struct pchead pcfhead[];
1150Sstevel@tonic-gate extern struct pchead pcdhead[];
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate /*
1180Sstevel@tonic-gate  * pcnode routines
1190Sstevel@tonic-gate  */
1200Sstevel@tonic-gate extern void pc_init(void);
1210Sstevel@tonic-gate extern struct pcnode *pc_getnode(struct pcfs *, daddr_t, int, struct pcdir *);
1220Sstevel@tonic-gate extern void pc_rele(struct pcnode *);
1235121Sfrankho extern void pc_mark_mod(struct pcfs *, struct pcnode *);
1245121Sfrankho extern void pc_mark_acc(struct pcfs *, struct pcnode *);
1250Sstevel@tonic-gate extern int pc_nodesync(struct pcnode *);
1260Sstevel@tonic-gate extern int pc_nodeupdate(struct pcnode *);
1270Sstevel@tonic-gate extern int pc_bmap(struct pcnode *, daddr_t, daddr_t *, uint_t *);
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate extern int pc_balloc(struct pcnode *, daddr_t, int, daddr_t *);
1300Sstevel@tonic-gate extern int pc_bfree(struct pcnode *, pc_cluster32_t);
1310Sstevel@tonic-gate extern int pc_verify(struct pcfs *);
1320Sstevel@tonic-gate extern void pc_diskchanged(struct pcfs *);
1330Sstevel@tonic-gate extern void pc_mark_irrecov(struct pcfs *);
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate extern int pc_dirlook(struct pcnode *, char *, struct pcnode **);
1360Sstevel@tonic-gate extern int pc_direnter(struct pcnode *, char *, struct vattr *,
1370Sstevel@tonic-gate 	struct pcnode **);
1385331Samw extern int pc_dirremove(struct pcnode *, char *, struct vnode *, enum vtype,
1395331Samw 		caller_context_t *);
1405331Samw extern int pc_rename(struct pcnode *, struct pcnode *, char *, char *,
1415331Samw 		caller_context_t *);
1420Sstevel@tonic-gate extern int pc_blkatoff(struct pcnode *, offset_t, struct buf **,
1430Sstevel@tonic-gate 	struct pcdir **);
1440Sstevel@tonic-gate extern int pc_truncate(struct pcnode *, uint_t);
1452972Sfrankho extern int pc_fileclsize(struct pcfs *, pc_cluster32_t, pc_cluster32_t *);
1460Sstevel@tonic-gate extern int pcfs_putapage(struct vnode *, page_t *, u_offset_t *, size_t *, int,
1470Sstevel@tonic-gate 	struct cred *);
1480Sstevel@tonic-gate extern void pc_badfs(struct pcfs *);
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate #ifdef	__cplusplus
1510Sstevel@tonic-gate }
1520Sstevel@tonic-gate #endif
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate #endif	/* _SYS_FS_PC_NODE_H */
155