Dave Chinner | 1fd7115 | 2013-08-12 20:49:35 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000-2003,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 | #ifndef __XFS_INODE_BUF_H__ |
| 19 | #define __XFS_INODE_BUF_H__ |
| 20 | |
| 21 | struct xfs_inode; |
| 22 | struct xfs_dinode; |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 23 | |
| 24 | /* |
Dave Chinner | 93f958f | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 25 | * In memory representation of the XFS inode. This is held in the in-core struct |
| 26 | * xfs_inode and represents the current on disk values but the structure is not |
| 27 | * in on-disk format. That is, this structure is always translated to on-disk |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 28 | * format specific structures at the appropriate time. |
| 29 | */ |
| 30 | struct xfs_icdinode { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 31 | int8_t di_version; /* inode version */ |
| 32 | int8_t di_format; /* format of di_c data */ |
| 33 | uint16_t di_flushiter; /* incremented on flush */ |
| 34 | uint32_t di_uid; /* owner's user id */ |
| 35 | uint32_t di_gid; /* owner's group id */ |
| 36 | uint16_t di_projid_lo; /* lower part of owner's project id */ |
| 37 | uint16_t di_projid_hi; /* higher part of owner's project id */ |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 38 | xfs_fsize_t di_size; /* number of bytes in file */ |
| 39 | xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */ |
| 40 | xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ |
| 41 | xfs_extnum_t di_nextents; /* number of extents in data fork */ |
| 42 | xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 43 | uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ |
| 44 | int8_t di_aformat; /* format of attr fork's data */ |
| 45 | uint32_t di_dmevmask; /* DMIG event mask */ |
| 46 | uint16_t di_dmstate; /* DMIG state info */ |
| 47 | uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 48 | |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 49 | uint64_t di_flags2; /* more random flags */ |
| 50 | uint32_t di_cowextsize; /* basic cow extent size for file */ |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 51 | |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 52 | xfs_ictimestamp_t di_crtime; /* time created */ |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 53 | }; |
Dave Chinner | 1fd7115 | 2013-08-12 20:49:35 +1000 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | * Inode location information. Stored in the inode and passed to |
| 57 | * xfs_imap_to_bp() to get a buffer and dinode for a given inode. |
| 58 | */ |
| 59 | struct xfs_imap { |
| 60 | xfs_daddr_t im_blkno; /* starting BB of inode chunk */ |
Darrick J. Wong | 755c7bf | 2016-11-08 11:55:48 +1100 | [diff] [blame] | 61 | unsigned short im_len; /* length in BBs of inode chunk */ |
| 62 | unsigned short im_boffset; /* inode offset in block in bytes */ |
Dave Chinner | 1fd7115 | 2013-08-12 20:49:35 +1000 | [diff] [blame] | 63 | }; |
| 64 | |
Dave Chinner | 638f4416 | 2013-08-30 10:23:45 +1000 | [diff] [blame] | 65 | int xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *, |
| 66 | struct xfs_imap *, struct xfs_dinode **, |
| 67 | struct xfs_buf **, uint, uint); |
| 68 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, |
| 69 | struct xfs_inode *, uint); |
| 70 | void xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *); |
Dave Chinner | 93f958f | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 71 | void xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to, |
| 72 | xfs_lsn_t lsn); |
Dave Chinner | 3987848 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 73 | void xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from); |
| 74 | void xfs_log_dinode_to_disk(struct xfs_log_dinode *from, |
| 75 | struct xfs_dinode *to); |
Dave Chinner | 1fd7115 | 2013-08-12 20:49:35 +1000 | [diff] [blame] | 76 | |
Roger Willcocks | 8cdcc81 | 2016-10-20 15:48:38 +1100 | [diff] [blame] | 77 | bool xfs_dinode_good_version(struct xfs_mount *mp, __u8 version); |
| 78 | |
Dave Chinner | 1fd7115 | 2013-08-12 20:49:35 +1000 | [diff] [blame] | 79 | #if defined(DEBUG) |
Dave Chinner | 638f4416 | 2013-08-30 10:23:45 +1000 | [diff] [blame] | 80 | void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *); |
Dave Chinner | 1fd7115 | 2013-08-12 20:49:35 +1000 | [diff] [blame] | 81 | #else |
| 82 | #define xfs_inobp_check(mp, bp) |
| 83 | #endif /* DEBUG */ |
| 84 | |
Darrick J. Wong | a6a781a | 2018-01-08 10:51:03 -0800 | [diff] [blame] | 85 | xfs_failaddr_t xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino, |
| 86 | struct xfs_dinode *dip); |
Darrick J. Wong | 8bb82bc | 2018-03-23 10:06:55 -0700 | [diff] [blame] | 87 | xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_mount *mp, |
| 88 | uint32_t extsize, uint16_t mode, uint16_t flags); |
| 89 | xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp, |
| 90 | uint32_t cowextsize, uint16_t mode, uint16_t flags, |
| 91 | uint64_t flags2); |
Darrick J. Wong | 2678809 | 2017-06-16 11:00:07 -0700 | [diff] [blame] | 92 | |
Dave Chinner | 1fd7115 | 2013-08-12 20:49:35 +1000 | [diff] [blame] | 93 | #endif /* __XFS_INODE_BUF_H__ */ |