Home | History | Annotate | Line # | Download | only in chfs
chfs_inode.h revision 1.1.2.1
      1      1.1  ahoka /*	$NetBSD: chfs_inode.h,v 1.1.2.1 2012/03/04 00:46:32 mrg 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.2.1    mrg 	struct genfs_node	gnode;
     46      1.1  ahoka 	kmutex_t inode_lock;	/* lock the fields of chfs_inode */
     47      1.1  ahoka 
     48      1.1  ahoka 	LIST_ENTRY(chfs_inode) hash_entry;	/* Hash chain. */
     49      1.1  ahoka 
     50      1.1  ahoka 	struct ufsmount *ump;			/* ufs mount - TODO we should remove it */
     51      1.1  ahoka 	struct chfs_mount *chmp;	/* chfs mount point - TODO we should remove it */
     52      1.1  ahoka 
     53      1.1  ahoka 	struct vnode *vp;	/* vnode associated with this inode */
     54      1.1  ahoka 	ino_t ino;			/* vnode identifier number */
     55      1.1  ahoka 
     56      1.1  ahoka 	struct vnode *devvp;	/* vnode for block I/O */
     57      1.1  ahoka 	dev_t dev;				/* device associated with the inode */
     58      1.1  ahoka 
     59      1.1  ahoka 	struct chfs_vnode_cache *chvc;	/* vnode cache of this node */
     60      1.1  ahoka 
     61      1.1  ahoka 	struct chfs_dirent *fd;	/* full dirent of this node */
     62      1.1  ahoka //	struct chfs_dirent *dents;	/* directory entries */
     63      1.1  ahoka 	struct chfs_dirent_list dents;
     64      1.1  ahoka 
     65      1.1  ahoka 	struct rb_tree fragtree;	        /* fragtree of inode */
     66      1.1  ahoka 
     67      1.1  ahoka 	uint64_t version;			/* version number */
     68      1.1  ahoka 	//uint64_t highest_version;	/* highest vers. num. (used at data nodes) */
     69      1.1  ahoka 
     70      1.1  ahoka 	uint32_t mode;		/* mode */
     71      1.1  ahoka 	//int16_t nlink;		/* link count */
     72      1.1  ahoka 	uint64_t size;		/* file byte count */
     73      1.1  ahoka 	uint64_t write_size;	/* increasing while write the file out to the flash */
     74      1.1  ahoka 	uint32_t uid;		/* file owner */
     75      1.1  ahoka 	uint32_t gid;		/* file group */
     76      1.1  ahoka 	uint32_t atime;		/* access time */
     77      1.1  ahoka 	uint32_t mtime;		/* modify time */
     78      1.1  ahoka 	uint32_t ctime;		/* creation time */
     79      1.1  ahoka 
     80      1.1  ahoka 	uint32_t iflag;		/* flags, see below */
     81      1.1  ahoka 	uint32_t flags;		/* status flags (chflags) */
     82      1.1  ahoka 
     83      1.1  ahoka 	dev_t rdev;			/* used if type is VCHR or VBLK or VFIFO*/
     84      1.1  ahoka 	char *target;		/* used if type is VLNK */
     85      1.1  ahoka };
     86      1.1  ahoka 
     87      1.1  ahoka /* These flags are kept in chfs_inode->iflag. */
     88      1.1  ahoka #define	IN_ACCESS	0x0001		/* Access time update request. */
     89      1.1  ahoka #define	IN_CHANGE	0x0002		/* Inode change time update request. */
     90      1.1  ahoka #define	IN_UPDATE	0x0004		/* Inode was written to; update mtime. */
     91      1.1  ahoka #define	IN_MODIFY	0x2000		/* Modification time update request. */
     92      1.1  ahoka #define	IN_MODIFIED	0x0008		/* Inode has been modified. */
     93      1.1  ahoka #define	IN_ACCESSED	0x0010		/* Inode has been accessed. */
     94      1.1  ahoka #define	IN_RENAME	0x0020		/* Inode is being renamed. */
     95      1.1  ahoka #define	IN_SHLOCK	0x0040		/* File has shared lock. */
     96      1.1  ahoka #define	IN_EXLOCK	0x0080		/* File has exclusive lock. */
     97      1.1  ahoka #define	IN_CLEANING	0x0100		/* LFS: file is being cleaned */
     98      1.1  ahoka #define	IN_ADIROP	0x0200		/* LFS: dirop in progress */
     99      1.1  ahoka #define	IN_SPACECOUNTED	0x0400		/* Blocks to be freed in free count. */
    100      1.1  ahoka #define	IN_PAGING       0x1000		/* LFS: file is on paging queue */
    101      1.1  ahoka 
    102      1.1  ahoka 
    103      1.1  ahoka #ifdef VTOI
    104      1.1  ahoka # undef VTOI
    105      1.1  ahoka #endif
    106      1.1  ahoka #ifdef ITOV
    107      1.1  ahoka # undef ITOV
    108      1.1  ahoka #endif
    109      1.1  ahoka 
    110      1.1  ahoka #define	VTOI(vp)	((struct chfs_inode *)(vp)->v_data)
    111      1.1  ahoka #define	ITOV(ip)	((ip)->vp)
    112      1.1  ahoka 
    113      1.1  ahoka /* copied from ufs_dinode.h */
    114      1.1  ahoka #define	NDADDR	12			/* Direct addresses in inode. */
    115      1.1  ahoka 
    116      1.1  ahoka #define	ROOTINO	((ino_t)2)
    117      1.1  ahoka 
    118      1.1  ahoka /* File permissions. */
    119      1.1  ahoka #define	IEXEC		0000100		/* Executable. */
    120      1.1  ahoka #define	IWRITE		0000200		/* Writable. */
    121      1.1  ahoka #define	IREAD		0000400		/* Readable. */
    122      1.1  ahoka #define	ISVTX		0001000		/* Sticky bit. */
    123      1.1  ahoka #define	ISGID		0002000		/* Set-gid. */
    124      1.1  ahoka #define	ISUID		0004000		/* Set-uid. */
    125      1.1  ahoka 
    126      1.1  ahoka /* File types. */
    127      1.1  ahoka #define	IFMT		0170000		/* Mask of file type. */
    128      1.1  ahoka #define	IFIFO		0010000		/* Named pipe (fifo). */
    129      1.1  ahoka #define	IFCHR		0020000		/* Character device. */
    130      1.1  ahoka #define	IFDIR		0040000		/* Directory file. */
    131      1.1  ahoka #define	IFBLK		0060000		/* Block device. */
    132      1.1  ahoka #define	IFREG		0100000		/* Regular file. */
    133      1.1  ahoka #define	IFLNK		0120000		/* Symbolic link. */
    134      1.1  ahoka #define	IFSOCK		0140000		/* UNIX domain socket. */
    135      1.1  ahoka #define	IFWHT		0160000		/* Whiteout. */
    136      1.1  ahoka 
    137      1.1  ahoka #endif /* __CHFS_INODE_H__ */
    138