]>
Commit | Line | Data |
---|---|---|
b626fb59 DC |
1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. | |
3 | * All Rights Reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU General Public License as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it would be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | ||
19 | #ifndef __XFS_INODE_H__ | |
20 | #define __XFS_INODE_H__ | |
21 | ||
22 | /* These match kernel side includes */ | |
6b803e5a CH |
23 | #include "xfs_inode_buf.h" |
24 | #include "xfs_inode_fork.h" | |
b626fb59 DC |
25 | |
26 | struct xfs_trans; | |
27 | struct xfs_mount; | |
28 | struct xfs_inode_log_item; | |
29 | struct xfs_dir_ops; | |
30 | ||
31 | /* | |
1bc6cbe3 DC |
32 | * Inode interface. This fakes up a "VFS inode" to make the xfs_inode appear |
33 | * similar to the kernel which now is used tohold certain parts of the on-disk | |
34 | * metadata. | |
b626fb59 | 35 | */ |
1bc6cbe3 | 36 | struct inode { |
e37bf53c | 37 | mode_t i_mode; |
bcbe04c1 | 38 | uint32_t i_nlink; |
6652c253 | 39 | uint32_t i_generation; |
9abcc5cd | 40 | uint64_t i_version; |
1bc6cbe3 DC |
41 | struct timespec i_atime; |
42 | struct timespec i_mtime; | |
43 | struct timespec i_ctime; | |
44 | }; | |
45 | ||
b626fb59 DC |
46 | typedef struct xfs_inode { |
47 | struct cache_node i_node; | |
48 | struct xfs_mount *i_mount; /* fs mount struct ptr */ | |
49 | xfs_ino_t i_ino; /* inode number (agno/agino) */ | |
50 | struct xfs_imap i_imap; /* location for xfs_imap() */ | |
51 | struct xfs_buftarg i_dev; /* dev for this inode */ | |
52 | struct xfs_ifork *i_afp; /* attribute fork pointer */ | |
cb8a004a | 53 | struct xfs_ifork *i_cowfp; /* copy on write extents */ |
b626fb59 DC |
54 | struct xfs_ifork i_df; /* data fork */ |
55 | struct xfs_trans *i_transp; /* ptr to owning transaction */ | |
56 | struct xfs_inode_log_item *i_itemp; /* logging information */ | |
57 | unsigned int i_delayed_blks; /* count of delay alloc blks */ | |
58 | struct xfs_icdinode i_d; /* most of ondisk inode */ | |
cb8a004a DW |
59 | |
60 | xfs_extnum_t i_cnextents; /* # of extents in cow fork */ | |
61 | unsigned int i_cformat; /* format of cow fork */ | |
62 | ||
b626fb59 DC |
63 | xfs_fsize_t i_size; /* in-memory size */ |
64 | const struct xfs_dir_ops *d_ops; /* directory ops vector */ | |
1bc6cbe3 | 65 | struct inode i_vnode; |
b626fb59 DC |
66 | } xfs_inode_t; |
67 | ||
1bc6cbe3 DC |
68 | static inline struct inode *VFS_I(struct xfs_inode *ip) |
69 | { | |
70 | return &ip->i_vnode; | |
71 | } | |
72 | ||
e37bf53c DC |
73 | /* |
74 | * wrappers around the mode checks to simplify code | |
75 | */ | |
76 | static inline bool XFS_ISREG(struct xfs_inode *ip) | |
77 | { | |
78 | return S_ISREG(VFS_I(ip)->i_mode); | |
79 | } | |
80 | ||
81 | static inline bool XFS_ISDIR(struct xfs_inode *ip) | |
82 | { | |
83 | return S_ISDIR(VFS_I(ip)->i_mode); | |
84 | } | |
85 | ||
b626fb59 DC |
86 | /* |
87 | * For regular files we only update the on-disk filesize when actually | |
88 | * writing data back to disk. Until then only the copy in the VFS inode | |
89 | * is uptodate. | |
90 | */ | |
91 | static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip) | |
92 | { | |
e37bf53c | 93 | if (XFS_ISREG(ip)) |
b626fb59 DC |
94 | return ip->i_size; |
95 | return ip->i_d.di_size; | |
96 | } | |
97 | #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) | |
98 | ||
bcbe04c1 DC |
99 | /* inode link counts */ |
100 | static inline void set_nlink(struct inode *inode, uint32_t nlink) | |
101 | { | |
102 | inode->i_nlink = nlink; | |
103 | } | |
104 | static inline void inc_nlink(struct inode *inode) | |
105 | { | |
106 | inode->i_nlink++; | |
107 | } | |
108 | ||
b626fb59 DC |
109 | /* |
110 | * Project quota id helpers (previously projid was 16bit only and using two | |
111 | * 16bit values to hold new 32bit projid was chosen to retain compatibility with | |
112 | * "old" filesystems). | |
113 | * | |
114 | * Copied here from xfs_inode.h because it has to be defined after the struct | |
115 | * xfs_inode... | |
116 | */ | |
117 | static inline prid_t | |
118 | xfs_get_projid(struct xfs_icdinode *id) | |
119 | { | |
120 | return (prid_t)id->di_projid_hi << 16 | id->di_projid_lo; | |
121 | } | |
122 | ||
123 | static inline void | |
124 | xfs_set_projid(struct xfs_icdinode *id, prid_t projid) | |
125 | { | |
126 | id->di_projid_hi = (__uint16_t) (projid >> 16); | |
127 | id->di_projid_lo = (__uint16_t) (projid & 0xffff); | |
128 | } | |
129 | ||
cfe32f0d DW |
130 | static inline bool xfs_is_reflink_inode(struct xfs_inode *ip) |
131 | { | |
132 | return ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK; | |
133 | } | |
134 | ||
b626fb59 DC |
135 | typedef struct cred { |
136 | uid_t cr_uid; | |
137 | gid_t cr_gid; | |
138 | } cred_t; | |
139 | ||
140 | extern int libxfs_inode_alloc (struct xfs_trans **, struct xfs_inode *, | |
141 | mode_t, nlink_t, xfs_dev_t, struct cred *, | |
142 | struct fsxattr *, struct xfs_inode **); | |
143 | extern void libxfs_trans_inode_alloc_buf (struct xfs_trans *, | |
144 | struct xfs_buf *); | |
145 | ||
146 | extern void libxfs_trans_ichgtime(struct xfs_trans *, | |
147 | struct xfs_inode *, int); | |
148 | extern int libxfs_iflush_int (struct xfs_inode *, struct xfs_buf *); | |
149 | ||
150 | /* Inode Cache Interfaces */ | |
151 | extern int libxfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, | |
81f8132a | 152 | uint, struct xfs_inode **); |
b626fb59 DC |
153 | extern void libxfs_iput(struct xfs_inode *); |
154 | ||
155 | #define IRELE(ip) libxfs_iput(ip) | |
156 | ||
157 | #endif /* __XFS_INODE_H__ */ |