Home | History | Annotate | Line # | Download | only in chfs
chfs_inode.h revision 1.5.2.2
      1  1.5.2.2       tls /*	$NetBSD: chfs_inode.h,v 1.5.2.2 2013/02/25 00:30:13 tls 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.4     ttoth #ifdef _KERNEL
     39      1.1     ahoka #include <sys/vnode.h>
     40      1.1     ahoka #include <sys/stat.h>
     41      1.1     ahoka #include <ufs/ufs/ufsmount.h>
     42      1.1     ahoka #include <miscfs/genfs/genfs_node.h>
     43      1.4     ttoth #endif /* _KERNEL */
     44      1.1     ahoka 
     45      1.3     ttoth #define CHFS_ROOTINO 2
     46      1.3     ttoth 
     47      1.3     ttoth /* chfs file types */
     48      1.3     ttoth enum chtype {
     49      1.3     ttoth 	CHT_BLANK,	/* empty type */
     50      1.3     ttoth 	CHT_REG,	/* regular file */
     51      1.3     ttoth 	CHT_DIR,	/* directory */
     52      1.3     ttoth 	CHT_BLK,	/* block device */
     53      1.3     ttoth 	CHT_CHR,	/* character device */
     54      1.3     ttoth 	CHT_LNK,	/* link */
     55      1.3     ttoth 	CHT_SOCK,	/* socket */
     56      1.3     ttoth 	CHT_FIFO,	/* fifo */
     57      1.3     ttoth 	CHT_BAD		/* bad type */
     58      1.3     ttoth };
     59      1.3     ttoth 
     60      1.3     ttoth /* these macros are needed because the compatibility */
     61      1.5     joerg #define CHTTOVT(ch_type)	(enum vtype)(ch_type)
     62      1.5     joerg #define VTTOCHT(v_type)		(enum chtype)(v_type)
     63      1.3     ttoth 
     64  1.5.2.1       tls /* vtype replaced with chtype, these are only for backward compatibility */
     65      1.4     ttoth static const enum chtype iftocht_tab[16] = {
     66      1.4     ttoth 	CHT_BLANK, CHT_FIFO, CHT_CHR, CHT_BLANK,
     67      1.4     ttoth 	CHT_DIR, CHT_BLANK, CHT_BLK, CHT_BLANK,
     68      1.4     ttoth 	CHT_REG, CHT_BLANK, CHT_LNK, CHT_BLANK,
     69      1.4     ttoth 	CHT_SOCK, CHT_BLANK, CHT_BLANK, CHT_BAD,
     70      1.4     ttoth };
     71      1.3     ttoth 
     72      1.3     ttoth #define	IFTOCHT(mode)	(iftocht_tab[((mode) & S_IFMT) >> 12])
     73      1.3     ttoth 
     74      1.4     ttoth #ifdef _KERNEL
     75      1.1     ahoka struct chfs_inode
     76      1.1     ahoka {
     77      1.2  christos 	struct genfs_node	gnode;
     78  1.5.2.1       tls 	kmutex_t inode_lock;		/* lock the fields of chfs_inode */
     79      1.1     ahoka 
     80  1.5.2.1       tls 	LIST_ENTRY(chfs_inode) hash_entry;	/* hash chain */
     81      1.1     ahoka 
     82  1.5.2.1       tls 	struct ufsmount *ump;		/* ufs mount - TODO we should remove it */
     83      1.1     ahoka 	struct chfs_mount *chmp;	/* chfs mount point - TODO we should remove it */
     84      1.1     ahoka 
     85      1.1     ahoka 	struct vnode *vp;	/* vnode associated with this inode */
     86      1.1     ahoka 	ino_t ino;			/* vnode identifier number */
     87      1.1     ahoka 
     88      1.1     ahoka 	struct vnode *devvp;	/* vnode for block I/O */
     89      1.1     ahoka 	dev_t dev;				/* device associated with the inode */
     90      1.1     ahoka 
     91      1.1     ahoka 	struct chfs_vnode_cache *chvc;	/* vnode cache of this node */
     92      1.1     ahoka 
     93  1.5.2.1       tls 	struct chfs_dirent *fd;			/* full dirent of this node */
     94      1.1     ahoka 	struct chfs_dirent_list dents;
     95      1.1     ahoka 
     96  1.5.2.1       tls 	struct rb_tree fragtree;		/* fragtree of inode */
     97      1.1     ahoka 
     98  1.5.2.1       tls 	uint64_t version;		/* version number */
     99      1.1     ahoka 
    100  1.5.2.1       tls 	uint32_t mode;			/* mode */
    101  1.5.2.1       tls 	enum chtype ch_type;	/* chfs file type */
    102  1.5.2.1       tls 	uint64_t size;			/* file byte count */
    103      1.1     ahoka 	uint64_t write_size;	/* increasing while write the file out to the flash */
    104  1.5.2.1       tls 	uint32_t uid;			/* file owner */
    105  1.5.2.1       tls 	uint32_t gid;			/* file group */
    106  1.5.2.1       tls 	uint32_t atime;			/* access time */
    107  1.5.2.1       tls 	uint32_t mtime;			/* modify time */
    108  1.5.2.1       tls 	uint32_t ctime;			/* creation time */
    109      1.1     ahoka 
    110  1.5.2.1       tls 	uint32_t iflag;			/* flags, see below */
    111  1.5.2.1       tls 	uint32_t flags;			/* status flags (chflags) */
    112      1.1     ahoka 
    113  1.5.2.1       tls 	dev_t rdev;				/* used if type is VCHR or VBLK or VFIFO*/
    114  1.5.2.1       tls 	char *target;			/* used if type is VLNK */
    115      1.1     ahoka };
    116      1.1     ahoka 
    117      1.1     ahoka /* These flags are kept in chfs_inode->iflag. */
    118      1.1     ahoka #define	IN_ACCESS	0x0001		/* Access time update request. */
    119      1.1     ahoka #define	IN_CHANGE	0x0002		/* Inode change time update request. */
    120      1.1     ahoka #define	IN_UPDATE	0x0004		/* Inode was written to; update mtime. */
    121      1.1     ahoka #define	IN_MODIFY	0x2000		/* Modification time update request. */
    122      1.1     ahoka #define	IN_MODIFIED	0x0008		/* Inode has been modified. */
    123      1.1     ahoka #define	IN_ACCESSED	0x0010		/* Inode has been accessed. */
    124      1.1     ahoka #define	IN_RENAME	0x0020		/* Inode is being renamed. */
    125      1.1     ahoka #define	IN_SHLOCK	0x0040		/* File has shared lock. */
    126      1.1     ahoka #define	IN_EXLOCK	0x0080		/* File has exclusive lock. */
    127      1.1     ahoka #define	IN_CLEANING	0x0100		/* LFS: file is being cleaned */
    128      1.1     ahoka #define	IN_ADIROP	0x0200		/* LFS: dirop in progress */
    129      1.1     ahoka #define	IN_SPACECOUNTED	0x0400		/* Blocks to be freed in free count. */
    130      1.1     ahoka #define	IN_PAGING       0x1000		/* LFS: file is on paging queue */
    131      1.1     ahoka 
    132      1.1     ahoka 
    133      1.1     ahoka #ifdef VTOI
    134      1.1     ahoka # undef VTOI
    135      1.1     ahoka #endif
    136      1.1     ahoka #ifdef ITOV
    137      1.1     ahoka # undef ITOV
    138      1.1     ahoka #endif
    139      1.1     ahoka 
    140  1.5.2.1       tls /* struct vnode to struct chfs_inode */
    141      1.1     ahoka #define	VTOI(vp)	((struct chfs_inode *)(vp)->v_data)
    142  1.5.2.1       tls /* struct chfs_inode to struct vnode */
    143      1.1     ahoka #define	ITOV(ip)	((ip)->vp)
    144      1.1     ahoka 
    145  1.5.2.2       tls /* XXX copied from ufs_dinode.h and should not be duplicated here */
    146  1.5.2.2       tls #define	UFS_NDADDR	12		/* Direct addresses in inode. */
    147      1.1     ahoka 
    148  1.5.2.2       tls /* XXX this should not be duplicated here */
    149  1.5.2.2       tls #define	UFS_ROOTINO	((ino_t)2)
    150      1.1     ahoka 
    151      1.1     ahoka /* File permissions. */
    152      1.1     ahoka #define	IEXEC		0000100		/* Executable. */
    153      1.1     ahoka #define	IWRITE		0000200		/* Writable. */
    154      1.1     ahoka #define	IREAD		0000400		/* Readable. */
    155      1.1     ahoka #define	ISVTX		0001000		/* Sticky bit. */
    156      1.1     ahoka #define	ISGID		0002000		/* Set-gid. */
    157      1.1     ahoka #define	ISUID		0004000		/* Set-uid. */
    158      1.1     ahoka 
    159      1.1     ahoka /* File types. */
    160      1.1     ahoka #define	IFMT		0170000		/* Mask of file type. */
    161      1.1     ahoka #define	IFIFO		0010000		/* Named pipe (fifo). */
    162      1.1     ahoka #define	IFCHR		0020000		/* Character device. */
    163      1.1     ahoka #define	IFDIR		0040000		/* Directory file. */
    164      1.1     ahoka #define	IFBLK		0060000		/* Block device. */
    165      1.1     ahoka #define	IFREG		0100000		/* Regular file. */
    166      1.1     ahoka #define	IFLNK		0120000		/* Symbolic link. */
    167      1.1     ahoka #define	IFSOCK		0140000		/* UNIX domain socket. */
    168      1.1     ahoka #define	IFWHT		0160000		/* Whiteout. */
    169      1.1     ahoka 
    170      1.4     ttoth #endif /* _KERNEL */
    171      1.1     ahoka #endif /* __CHFS_INODE_H__ */
    172