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