]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/xfs_inode.h
8141d972553ebdec8adc70c0b4ef79371e839fbc
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
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.
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.
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
19 #ifndef __XFS_INODE_H__
20 #define __XFS_INODE_H__
22 /* These match kernel side includes */
23 #include "xfs_inode_buf.h"
24 #include "xfs_inode_fork.h"
28 struct xfs_inode_log_item
;
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
39 uint32_t i_generation
;
41 struct timespec i_atime
;
42 struct timespec i_mtime
;
43 struct timespec i_ctime
;
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 */
53 struct xfs_ifork i_df
; /* data fork */
54 struct xfs_trans
*i_transp
; /* ptr to owning transaction */
55 struct xfs_inode_log_item
*i_itemp
; /* logging information */
56 unsigned int i_delayed_blks
; /* count of delay alloc blks */
57 struct xfs_icdinode i_d
; /* most of ondisk inode */
58 xfs_fsize_t i_size
; /* in-memory size */
59 const struct xfs_dir_ops
*d_ops
; /* directory ops vector */
63 static inline struct inode
*VFS_I(struct xfs_inode
*ip
)
69 * wrappers around the mode checks to simplify code
71 static inline bool XFS_ISREG(struct xfs_inode
*ip
)
73 return S_ISREG(VFS_I(ip
)->i_mode
);
76 static inline bool XFS_ISDIR(struct xfs_inode
*ip
)
78 return S_ISDIR(VFS_I(ip
)->i_mode
);
82 * For regular files we only update the on-disk filesize when actually
83 * writing data back to disk. Until then only the copy in the VFS inode
86 static inline xfs_fsize_t
XFS_ISIZE(struct xfs_inode
*ip
)
90 return ip
->i_d
.di_size
;
92 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
94 /* inode link counts */
95 static inline void set_nlink(struct inode
*inode
, uint32_t nlink
)
97 inode
->i_nlink
= nlink
;
99 static inline void inc_nlink(struct inode
*inode
)
105 * Project quota id helpers (previously projid was 16bit only and using two
106 * 16bit values to hold new 32bit projid was chosen to retain compatibility with
107 * "old" filesystems).
109 * Copied here from xfs_inode.h because it has to be defined after the struct
113 xfs_get_projid(struct xfs_icdinode
*id
)
115 return (prid_t
)id
->di_projid_hi
<< 16 | id
->di_projid_lo
;
119 xfs_set_projid(struct xfs_icdinode
*id
, prid_t projid
)
121 id
->di_projid_hi
= (__uint16_t
) (projid
>> 16);
122 id
->di_projid_lo
= (__uint16_t
) (projid
& 0xffff);
125 typedef struct cred
{
130 extern int libxfs_inode_alloc (struct xfs_trans
**, struct xfs_inode
*,
131 mode_t
, nlink_t
, xfs_dev_t
, struct cred
*,
132 struct fsxattr
*, struct xfs_inode
**);
133 extern void libxfs_trans_inode_alloc_buf (struct xfs_trans
*,
136 extern void libxfs_trans_ichgtime(struct xfs_trans
*,
137 struct xfs_inode
*, int);
138 extern int libxfs_iflush_int (struct xfs_inode
*, struct xfs_buf
*);
140 /* Inode Cache Interfaces */
141 extern int libxfs_iget(struct xfs_mount
*, struct xfs_trans
*, xfs_ino_t
,
142 uint
, struct xfs_inode
**, xfs_daddr_t
);
143 extern void libxfs_iput(struct xfs_inode
*);
145 #define IRELE(ip) libxfs_iput(ip)
147 #endif /* __XFS_INODE_H__ */