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