Home | History | Annotate | Line # | Download | only in chfs
chfs_inode.h revision 1.1
      1  1.1  ahoka /*	$NetBSD: chfs_inode.h,v 1.1 2011/11/24 15:51:31 ahoka Exp $	*/
      2  1.1  ahoka 
      3  1.1  ahoka /*-
      4  1.1  ahoka  * Copyright (c) 2010 Department of Software Engineering,
      5  1.1  ahoka  *		      University of Szeged, Hungary
      6  1.1  ahoka  * Copyright (C) 2010 Tamas Toth <ttoth (at) inf.u-szeged.hu>
      7  1.1  ahoka  * Copyright (C) 2010 Adam Hoka <ahoka (at) NetBSD.org>
      8  1.1  ahoka  * All rights reserved.
      9  1.1  ahoka  *
     10  1.1  ahoka  * This code is derived from software contributed to The NetBSD Foundation
     11  1.1  ahoka  * by the Department of Software Engineering, University of Szeged, Hungary
     12  1.1  ahoka  *
     13  1.1  ahoka  * Redistribution and use in source and binary forms, with or without
     14  1.1  ahoka  * modification, are permitted provided that the following conditions
     15  1.1  ahoka  * are met:
     16  1.1  ahoka  * 1. Redistributions of source code must retain the above copyright
     17  1.1  ahoka  *    notice, this list of conditions and the following disclaimer.
     18  1.1  ahoka  * 2. Redistributions in binary form must reproduce the above copyright
     19  1.1  ahoka  *    notice, this list of conditions and the following disclaimer in the
     20  1.1  ahoka  *    documentation and/or other materials provided with the distribution.
     21  1.1  ahoka  *
     22  1.1  ahoka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  1.1  ahoka  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  1.1  ahoka  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  1.1  ahoka  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  1.1  ahoka  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     27  1.1  ahoka  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     28  1.1  ahoka  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     29  1.1  ahoka  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     30  1.1  ahoka  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.1  ahoka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  1.1  ahoka  * SUCH DAMAGE.
     33  1.1  ahoka  */
     34  1.1  ahoka 
     35  1.1  ahoka #ifndef __CHFS_INODE_H__
     36  1.1  ahoka #define __CHFS_INODE_H__
     37  1.1  ahoka 
     38  1.1  ahoka #include <sys/vnode.h>
     39  1.1  ahoka #include <sys/stat.h>
     40  1.1  ahoka #include <ufs/ufs/ufsmount.h>
     41  1.1  ahoka #include <miscfs/genfs/genfs_node.h>
     42  1.1  ahoka 
     43  1.1  ahoka struct chfs_inode
     44  1.1  ahoka {
     45  1.1  ahoka 	kmutex_t inode_lock;	/* lock the fields of chfs_inode */
     46  1.1  ahoka 
     47  1.1  ahoka 	LIST_ENTRY(chfs_inode) hash_entry;	/* Hash chain. */
     48  1.1  ahoka 
     49  1.1  ahoka 	struct ufsmount *ump;			/* ufs mount - TODO we should remove it */
     50  1.1  ahoka 	struct chfs_mount *chmp;	/* chfs mount point - TODO we should remove it */
     51  1.1  ahoka 
     52  1.1  ahoka 	struct vnode *vp;	/* vnode associated with this inode */
     53  1.1  ahoka 	ino_t ino;			/* vnode identifier number */
     54  1.1  ahoka 
     55  1.1  ahoka 	struct vnode *devvp;	/* vnode for block I/O */
     56  1.1  ahoka 	dev_t dev;				/* device associated with the inode */
     57  1.1  ahoka 
     58  1.1  ahoka 	struct chfs_vnode_cache *chvc;	/* vnode cache of this node */
     59  1.1  ahoka 
     60  1.1  ahoka 	struct chfs_dirent *fd;	/* full dirent of this node */
     61  1.1  ahoka //	struct chfs_dirent *dents;	/* directory entries */
     62  1.1  ahoka 	struct chfs_dirent_list dents;
     63  1.1  ahoka 
     64  1.1  ahoka 	struct rb_tree fragtree;	        /* fragtree of inode */
     65  1.1  ahoka 
     66  1.1  ahoka 	uint64_t version;			/* version number */
     67  1.1  ahoka 	//uint64_t highest_version;	/* highest vers. num. (used at data nodes) */
     68  1.1  ahoka 
     69  1.1  ahoka 	uint32_t mode;		/* mode */
     70  1.1  ahoka 	//int16_t nlink;		/* link count */
     71  1.1  ahoka 	uint64_t size;		/* file byte count */
     72  1.1  ahoka 	uint64_t write_size;	/* increasing while write the file out to the flash */
     73  1.1  ahoka 	uint32_t uid;		/* file owner */
     74  1.1  ahoka 	uint32_t gid;		/* file group */
     75  1.1  ahoka 	uint32_t atime;		/* access time */
     76  1.1  ahoka 	uint32_t mtime;		/* modify time */
     77  1.1  ahoka 	uint32_t ctime;		/* creation time */
     78  1.1  ahoka 
     79  1.1  ahoka 	uint32_t iflag;		/* flags, see below */
     80  1.1  ahoka 	uint32_t flags;		/* status flags (chflags) */
     81  1.1  ahoka 
     82  1.1  ahoka 	dev_t rdev;			/* used if type is VCHR or VBLK or VFIFO*/
     83  1.1  ahoka 	char *target;		/* used if type is VLNK */
     84  1.1  ahoka };
     85  1.1  ahoka 
     86  1.1  ahoka /* These flags are kept in chfs_inode->iflag. */
     87  1.1  ahoka #define	IN_ACCESS	0x0001		/* Access time update request. */
     88  1.1  ahoka #define	IN_CHANGE	0x0002		/* Inode change time update request. */
     89  1.1  ahoka #define	IN_UPDATE	0x0004		/* Inode was written to; update mtime. */
     90  1.1  ahoka #define	IN_MODIFY	0x2000		/* Modification time update request. */
     91  1.1  ahoka #define	IN_MODIFIED	0x0008		/* Inode has been modified. */
     92  1.1  ahoka #define	IN_ACCESSED	0x0010		/* Inode has been accessed. */
     93  1.1  ahoka #define	IN_RENAME	0x0020		/* Inode is being renamed. */
     94  1.1  ahoka #define	IN_SHLOCK	0x0040		/* File has shared lock. */
     95  1.1  ahoka #define	IN_EXLOCK	0x0080		/* File has exclusive lock. */
     96  1.1  ahoka #define	IN_CLEANING	0x0100		/* LFS: file is being cleaned */
     97  1.1  ahoka #define	IN_ADIROP	0x0200		/* LFS: dirop in progress */
     98  1.1  ahoka #define	IN_SPACECOUNTED	0x0400		/* Blocks to be freed in free count. */
     99  1.1  ahoka #define	IN_PAGING       0x1000		/* LFS: file is on paging queue */
    100  1.1  ahoka 
    101  1.1  ahoka 
    102  1.1  ahoka #ifdef VTOI
    103  1.1  ahoka # undef VTOI
    104  1.1  ahoka #endif
    105  1.1  ahoka #ifdef ITOV
    106  1.1  ahoka # undef ITOV
    107  1.1  ahoka #endif
    108  1.1  ahoka 
    109  1.1  ahoka #define	VTOI(vp)	((struct chfs_inode *)(vp)->v_data)
    110  1.1  ahoka #define	ITOV(ip)	((ip)->vp)
    111  1.1  ahoka 
    112  1.1  ahoka /* copied from ufs_dinode.h */
    113  1.1  ahoka #define	NDADDR	12			/* Direct addresses in inode. */
    114  1.1  ahoka 
    115  1.1  ahoka #define	ROOTINO	((ino_t)2)
    116  1.1  ahoka 
    117  1.1  ahoka /* File permissions. */
    118  1.1  ahoka #define	IEXEC		0000100		/* Executable. */
    119  1.1  ahoka #define	IWRITE		0000200		/* Writable. */
    120  1.1  ahoka #define	IREAD		0000400		/* Readable. */
    121  1.1  ahoka #define	ISVTX		0001000		/* Sticky bit. */
    122  1.1  ahoka #define	ISGID		0002000		/* Set-gid. */
    123  1.1  ahoka #define	ISUID		0004000		/* Set-uid. */
    124  1.1  ahoka 
    125  1.1  ahoka /* File types. */
    126  1.1  ahoka #define	IFMT		0170000		/* Mask of file type. */
    127  1.1  ahoka #define	IFIFO		0010000		/* Named pipe (fifo). */
    128  1.1  ahoka #define	IFCHR		0020000		/* Character device. */
    129  1.1  ahoka #define	IFDIR		0040000		/* Directory file. */
    130  1.1  ahoka #define	IFBLK		0060000		/* Block device. */
    131  1.1  ahoka #define	IFREG		0100000		/* Regular file. */
    132  1.1  ahoka #define	IFLNK		0120000		/* Symbolic link. */
    133  1.1  ahoka #define	IFSOCK		0140000		/* UNIX domain socket. */
    134  1.1  ahoka #define	IFWHT		0160000		/* Whiteout. */
    135  1.1  ahoka 
    136  1.1  ahoka #endif /* __CHFS_INODE_H__ */
    137