]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/xfs_inode.h
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
7 #ifndef __XFS_INODE_H__
8 #define __XFS_INODE_H__
10 /* These match kernel side includes */
11 #include "xfs_inode_buf.h"
12 #include "xfs_inode_fork.h"
16 struct xfs_inode_log_item
;
19 * These are not actually used, they are only for userspace build
20 * compatibility in code that looks at i_state
22 #define I_DIRTY_TIME 0
23 #define I_DIRTY_TIME_EXPIRED 0
25 #define IS_I_VERSION(inode) (0)
26 #define inode_maybe_inc_iversion(inode,flags) (0)
29 * Inode interface. This fakes up a "VFS inode" to make the xfs_inode appear
30 * similar to the kernel which now is used tohold certain parts of the on-disk
38 xfs_dev_t i_rdev
; /* This actually holds xfs_dev_t */
40 unsigned long i_state
; /* Not actually used in userspace */
41 uint32_t i_generation
;
43 struct timespec64 i_atime
;
44 struct timespec64 i_mtime
;
45 struct timespec64 i_ctime
;
48 static inline uint32_t i_uid_read(struct inode
*inode
)
52 static inline uint32_t i_gid_read(struct inode
*inode
)
56 static inline void i_uid_write(struct inode
*inode
, uint32_t uid
)
60 static inline void i_gid_write(struct inode
*inode
, uint32_t gid
)
65 static inline void ihold(struct inode
*inode
)
70 typedef struct xfs_inode
{
71 struct cache_node i_node
;
72 struct xfs_mount
*i_mount
; /* fs mount struct ptr */
73 xfs_ino_t i_ino
; /* inode number (agno/agino) */
74 struct xfs_imap i_imap
; /* location for xfs_imap() */
75 struct xfs_buftarg i_dev
; /* dev for this inode */
76 struct xfs_ifork
*i_afp
; /* attribute fork pointer */
77 struct xfs_ifork
*i_cowfp
; /* copy on write extents */
78 struct xfs_ifork i_df
; /* data fork */
79 struct xfs_inode_log_item
*i_itemp
; /* logging information */
80 unsigned int i_delayed_blks
; /* count of delay alloc blks */
81 struct xfs_icdinode i_d
; /* most of ondisk inode */
83 xfs_extnum_t i_cnextents
; /* # of extents in cow fork */
84 unsigned int i_cformat
; /* format of cow fork */
86 xfs_fsize_t i_size
; /* in-memory size */
90 /* Convert from vfs inode to xfs inode */
91 static inline struct xfs_inode
*XFS_I(struct inode
*inode
)
93 return container_of(inode
, struct xfs_inode
, i_vnode
);
96 /* convert from xfs inode to vfs inode */
97 static inline struct inode
*VFS_I(struct xfs_inode
*ip
)
102 /* We only have i_size in the xfs inode in userspace */
103 static inline loff_t
i_size_read(struct inode
*inode
)
105 return XFS_I(inode
)->i_size
;
109 * wrappers around the mode checks to simplify code
111 static inline bool XFS_ISREG(struct xfs_inode
*ip
)
113 return S_ISREG(VFS_I(ip
)->i_mode
);
116 static inline bool XFS_ISDIR(struct xfs_inode
*ip
)
118 return S_ISDIR(VFS_I(ip
)->i_mode
);
122 * For regular files we only update the on-disk filesize when actually
123 * writing data back to disk. Until then only the copy in the VFS inode
126 static inline xfs_fsize_t
XFS_ISIZE(struct xfs_inode
*ip
)
130 return ip
->i_d
.di_size
;
132 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
134 /* inode link counts */
135 static inline void set_nlink(struct inode
*inode
, uint32_t nlink
)
137 inode
->i_nlink
= nlink
;
139 static inline void inc_nlink(struct inode
*inode
)
144 static inline bool xfs_is_reflink_inode(struct xfs_inode
*ip
)
146 return ip
->i_d
.di_flags2
& XFS_DIFLAG2_REFLINK
;
149 static inline bool xfs_inode_has_bigtime(struct xfs_inode
*ip
)
151 return ip
->i_d
.di_flags2
& XFS_DIFLAG2_BIGTIME
;
154 typedef struct cred
{
159 extern int libxfs_dir_ialloc (struct xfs_trans
**, struct xfs_inode
*,
160 mode_t
, nlink_t
, xfs_dev_t
, struct cred
*,
161 struct fsxattr
*, struct xfs_inode
**);
162 extern void libxfs_trans_inode_alloc_buf (struct xfs_trans
*,
165 extern void libxfs_trans_ichgtime(struct xfs_trans
*,
166 struct xfs_inode
*, int);
167 extern int libxfs_iflush_int (struct xfs_inode
*, struct xfs_buf
*);
169 extern struct timespec64
current_time(struct inode
*inode
);
171 /* Inode Cache Interfaces */
172 extern int libxfs_iget(struct xfs_mount
*, struct xfs_trans
*, xfs_ino_t
,
173 uint
, struct xfs_inode
**);
174 extern void libxfs_irele(struct xfs_inode
*ip
);
176 #endif /* __XFS_INODE_H__ */