Home | History | Annotate | Line # | Download | only in chfs
      1  1.10   hannken /*	$NetBSD: chfs_inode.h,v 1.10 2015/01/11 17:29:57 hannken 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.6     ttoth /* 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.6     ttoth 	kmutex_t inode_lock;		/* lock the fields of chfs_inode */
     79   1.1     ahoka 
     80   1.6     ttoth 	struct ufsmount *ump;		/* ufs mount - TODO we should remove it */
     81   1.1     ahoka 	struct chfs_mount *chmp;	/* chfs mount point - TODO we should remove it */
     82   1.1     ahoka 
     83   1.1     ahoka 	struct vnode *vp;	/* vnode associated with this inode */
     84   1.1     ahoka 	ino_t ino;			/* vnode identifier number */
     85   1.1     ahoka 
     86   1.1     ahoka 	struct vnode *devvp;	/* vnode for block I/O */
     87   1.1     ahoka 	dev_t dev;				/* device associated with the inode */
     88   1.1     ahoka 
     89   1.1     ahoka 	struct chfs_vnode_cache *chvc;	/* vnode cache of this node */
     90   1.1     ahoka 
     91   1.6     ttoth 	struct chfs_dirent *fd;			/* full dirent of this node */
     92   1.1     ahoka 	struct chfs_dirent_list dents;
     93   1.1     ahoka 
     94   1.6     ttoth 	struct rb_tree fragtree;		/* fragtree of inode */
     95   1.1     ahoka 
     96   1.6     ttoth 	uint64_t version;		/* version number */
     97   1.1     ahoka 
     98   1.6     ttoth 	uint32_t mode;			/* mode */
     99   1.6     ttoth 	enum chtype ch_type;	/* chfs file type */
    100   1.6     ttoth 	uint64_t size;			/* file byte count */
    101   1.1     ahoka 	uint64_t write_size;	/* increasing while write the file out to the flash */
    102   1.6     ttoth 	uint32_t uid;			/* file owner */
    103   1.6     ttoth 	uint32_t gid;			/* file group */
    104   1.6     ttoth 	uint32_t atime;			/* access time */
    105   1.6     ttoth 	uint32_t mtime;			/* modify time */
    106   1.6     ttoth 	uint32_t ctime;			/* creation time */
    107   1.1     ahoka 
    108   1.6     ttoth 	uint32_t iflag;			/* flags, see below */
    109   1.6     ttoth 	uint32_t flags;			/* status flags (chflags) */
    110   1.1     ahoka 
    111   1.6     ttoth 	dev_t rdev;				/* used if type is VCHR or VBLK or VFIFO*/
    112   1.6     ttoth 	char *target;			/* used if type is VLNK */
    113   1.1     ahoka };
    114   1.1     ahoka 
    115   1.1     ahoka /* These flags are kept in chfs_inode->iflag. */
    116   1.1     ahoka #define	IN_ACCESS	0x0001		/* Access time update request. */
    117   1.1     ahoka #define	IN_CHANGE	0x0002		/* Inode change time update request. */
    118   1.1     ahoka #define	IN_UPDATE	0x0004		/* Inode was written to; update mtime. */
    119   1.1     ahoka #define	IN_MODIFY	0x2000		/* Modification time update request. */
    120   1.1     ahoka #define	IN_MODIFIED	0x0008		/* Inode has been modified. */
    121   1.1     ahoka #define	IN_ACCESSED	0x0010		/* Inode has been accessed. */
    122   1.9  dholland /*	   unused	0x0020 */	/* was IN_RENAME */
    123   1.1     ahoka #define	IN_SHLOCK	0x0040		/* File has shared lock. */
    124   1.1     ahoka #define	IN_EXLOCK	0x0080		/* File has exclusive lock. */
    125   1.9  dholland /*	   unused	0x0100 */	/* was LFS-only IN_CLEANING */
    126   1.9  dholland /*	   unused	0x0200 */	/* was LFS-only IN_ADIROP */
    127   1.1     ahoka #define	IN_SPACECOUNTED	0x0400		/* Blocks to be freed in free count. */
    128   1.9  dholland /*	   unused       0x1000 */	/* was LFS-only IN_PAGING */
    129   1.1     ahoka 
    130   1.1     ahoka 
    131   1.1     ahoka #ifdef VTOI
    132   1.1     ahoka # undef VTOI
    133   1.1     ahoka #endif
    134   1.1     ahoka #ifdef ITOV
    135   1.1     ahoka # undef ITOV
    136   1.1     ahoka #endif
    137   1.1     ahoka 
    138   1.6     ttoth /* struct vnode to struct chfs_inode */
    139   1.1     ahoka #define	VTOI(vp)	((struct chfs_inode *)(vp)->v_data)
    140   1.6     ttoth /* struct chfs_inode to struct vnode */
    141   1.1     ahoka #define	ITOV(ip)	((ip)->vp)
    142   1.1     ahoka 
    143   1.7  dholland /* XXX copied from ufs_dinode.h and should not be duplicated here */
    144   1.7  dholland #define	UFS_NDADDR	12		/* Direct addresses in inode. */
    145   1.1     ahoka 
    146   1.7  dholland /* XXX this should not be duplicated here */
    147   1.7  dholland #define	UFS_ROOTINO	((ino_t)2)
    148   1.1     ahoka 
    149   1.1     ahoka /* File permissions. */
    150   1.1     ahoka #define	IEXEC		0000100		/* Executable. */
    151   1.1     ahoka #define	IWRITE		0000200		/* Writable. */
    152   1.1     ahoka #define	IREAD		0000400		/* Readable. */
    153   1.1     ahoka #define	ISVTX		0001000		/* Sticky bit. */
    154   1.1     ahoka #define	ISGID		0002000		/* Set-gid. */
    155   1.1     ahoka #define	ISUID		0004000		/* Set-uid. */
    156   1.1     ahoka 
    157   1.1     ahoka /* File types. */
    158   1.1     ahoka #define	IFMT		0170000		/* Mask of file type. */
    159   1.1     ahoka #define	IFIFO		0010000		/* Named pipe (fifo). */
    160   1.1     ahoka #define	IFCHR		0020000		/* Character device. */
    161   1.1     ahoka #define	IFDIR		0040000		/* Directory file. */
    162   1.1     ahoka #define	IFBLK		0060000		/* Block device. */
    163   1.1     ahoka #define	IFREG		0100000		/* Regular file. */
    164   1.1     ahoka #define	IFLNK		0120000		/* Symbolic link. */
    165   1.1     ahoka #define	IFSOCK		0140000		/* UNIX domain socket. */
    166   1.1     ahoka #define	IFWHT		0160000		/* Whiteout. */
    167   1.1     ahoka 
    168   1.4     ttoth #endif /* _KERNEL */
    169   1.1     ahoka #endif /* __CHFS_INODE_H__ */
    170