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