18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. 48c2ecf20Sopenharmony_ci * All Rights Reserved. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef __XFS_INODE_BUF_H__ 78c2ecf20Sopenharmony_ci#define __XFS_INODE_BUF_H__ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct xfs_inode; 108c2ecf20Sopenharmony_cistruct xfs_dinode; 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* 138c2ecf20Sopenharmony_ci * In memory representation of the XFS inode. This is held in the in-core struct 148c2ecf20Sopenharmony_ci * xfs_inode and represents the current on disk values but the structure is not 158c2ecf20Sopenharmony_ci * in on-disk format. That is, this structure is always translated to on-disk 168c2ecf20Sopenharmony_ci * format specific structures at the appropriate time. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_cistruct xfs_icdinode { 198c2ecf20Sopenharmony_ci uint16_t di_flushiter; /* incremented on flush */ 208c2ecf20Sopenharmony_ci prid_t di_projid; /* owner's project id */ 218c2ecf20Sopenharmony_ci xfs_fsize_t di_size; /* number of bytes in file */ 228c2ecf20Sopenharmony_ci xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */ 238c2ecf20Sopenharmony_ci xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ 248c2ecf20Sopenharmony_ci uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ 258c2ecf20Sopenharmony_ci uint32_t di_dmevmask; /* DMIG event mask */ 268c2ecf20Sopenharmony_ci uint16_t di_dmstate; /* DMIG state info */ 278c2ecf20Sopenharmony_ci uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci uint64_t di_flags2; /* more random flags */ 308c2ecf20Sopenharmony_ci uint32_t di_cowextsize; /* basic cow extent size for file */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci struct timespec64 di_crtime; /* time created */ 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic inline bool xfs_icdinode_has_bigtime(const struct xfs_icdinode *icd) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci return icd->di_flags2 & XFS_DIFLAG2_BIGTIME; 388c2ecf20Sopenharmony_ci} 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* 418c2ecf20Sopenharmony_ci * Inode location information. Stored in the inode and passed to 428c2ecf20Sopenharmony_ci * xfs_imap_to_bp() to get a buffer and dinode for a given inode. 438c2ecf20Sopenharmony_ci */ 448c2ecf20Sopenharmony_cistruct xfs_imap { 458c2ecf20Sopenharmony_ci xfs_daddr_t im_blkno; /* starting BB of inode chunk */ 468c2ecf20Sopenharmony_ci unsigned short im_len; /* length in BBs of inode chunk */ 478c2ecf20Sopenharmony_ci unsigned short im_boffset; /* inode offset in block in bytes */ 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciint xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *, 518c2ecf20Sopenharmony_ci struct xfs_imap *, struct xfs_dinode **, 528c2ecf20Sopenharmony_ci struct xfs_buf **, uint); 538c2ecf20Sopenharmony_civoid xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *); 548c2ecf20Sopenharmony_civoid xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to, 558c2ecf20Sopenharmony_ci xfs_lsn_t lsn); 568c2ecf20Sopenharmony_ciint xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from); 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cixfs_failaddr_t xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino, 598c2ecf20Sopenharmony_ci struct xfs_dinode *dip); 608c2ecf20Sopenharmony_cixfs_failaddr_t xfs_inode_validate_extsize(struct xfs_mount *mp, 618c2ecf20Sopenharmony_ci uint32_t extsize, uint16_t mode, uint16_t flags); 628c2ecf20Sopenharmony_cixfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp, 638c2ecf20Sopenharmony_ci uint32_t cowextsize, uint16_t mode, uint16_t flags, 648c2ecf20Sopenharmony_ci uint64_t flags2); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistatic inline uint64_t xfs_inode_encode_bigtime(struct timespec64 tv) 678c2ecf20Sopenharmony_ci{ 688c2ecf20Sopenharmony_ci return xfs_unix_to_bigtime(tv.tv_sec) * NSEC_PER_SEC + tv.tv_nsec; 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_cistruct timespec64 xfs_inode_from_disk_ts(struct xfs_dinode *dip, 728c2ecf20Sopenharmony_ci const xfs_timestamp_t ts); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#endif /* __XFS_INODE_BUF_H__ */ 75