.. | .. |
---|
1 | | -// SPDX-License-Identifier: GPL-2.0 |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
---|
2 | 2 | /* |
---|
3 | 3 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
---|
4 | 4 | * Copyright (c) 2013 Red Hat, Inc. |
---|
.. | .. |
---|
15 | 15 | */ |
---|
16 | 16 | #define XFS_DA_NODE_MAGIC 0xfebe /* magic number: non-leaf blocks */ |
---|
17 | 17 | #define XFS_ATTR_LEAF_MAGIC 0xfbee /* magic number: attribute leaf blks */ |
---|
18 | | -#define XFS_DIR2_LEAF1_MAGIC 0xd2f1 /* magic number: v2 dirlf single blks */ |
---|
19 | | -#define XFS_DIR2_LEAFN_MAGIC 0xd2ff /* magic number: v2 dirlf multi blks */ |
---|
| 18 | +#define XFS_DIR2_LEAF1_MAGIC 0xd2f1 /* magic number: v2 dirlf single blks */ |
---|
| 19 | +#define XFS_DIR2_LEAFN_MAGIC 0xd2ff /* magic number: v2 dirlf multi blks */ |
---|
20 | 20 | |
---|
21 | 21 | typedef struct xfs_da_blkinfo { |
---|
22 | 22 | __be32 forw; /* previous block in list */ |
---|
.. | .. |
---|
35 | 35 | */ |
---|
36 | 36 | #define XFS_DA3_NODE_MAGIC 0x3ebe /* magic number: non-leaf blocks */ |
---|
37 | 37 | #define XFS_ATTR3_LEAF_MAGIC 0x3bee /* magic number: attribute leaf blks */ |
---|
38 | | -#define XFS_DIR3_LEAF1_MAGIC 0x3df1 /* magic number: v2 dirlf single blks */ |
---|
39 | | -#define XFS_DIR3_LEAFN_MAGIC 0x3dff /* magic number: v2 dirlf multi blks */ |
---|
| 38 | +#define XFS_DIR3_LEAF1_MAGIC 0x3df1 /* magic number: v3 dirlf single blks */ |
---|
| 39 | +#define XFS_DIR3_LEAFN_MAGIC 0x3dff /* magic number: v3 dirlf multi blks */ |
---|
40 | 40 | |
---|
41 | 41 | struct xfs_da3_blkinfo { |
---|
42 | 42 | /* |
---|
.. | .. |
---|
61 | 61 | * Since we have duplicate keys, use a binary search but always follow |
---|
62 | 62 | * all match in the block, not just the first match found. |
---|
63 | 63 | */ |
---|
64 | | -#define XFS_DA_NODE_MAXDEPTH 5 /* max depth of Btree */ |
---|
| 64 | +#define XFS_DA_NODE_MAXDEPTH 5 /* max depth of Btree */ |
---|
65 | 65 | |
---|
66 | 66 | typedef struct xfs_da_node_hdr { |
---|
67 | 67 | struct xfs_da_blkinfo info; /* block type, links, etc. */ |
---|
.. | .. |
---|
91 | 91 | struct xfs_da3_intnode { |
---|
92 | 92 | struct xfs_da3_node_hdr hdr; |
---|
93 | 93 | struct xfs_da_node_entry __btree[]; |
---|
94 | | -}; |
---|
95 | | - |
---|
96 | | -/* |
---|
97 | | - * In-core version of the node header to abstract the differences in the v2 and |
---|
98 | | - * v3 disk format of the headers. Callers need to convert to/from disk format as |
---|
99 | | - * appropriate. |
---|
100 | | - */ |
---|
101 | | -struct xfs_da3_icnode_hdr { |
---|
102 | | - uint32_t forw; |
---|
103 | | - uint32_t back; |
---|
104 | | - uint16_t magic; |
---|
105 | | - uint16_t count; |
---|
106 | | - uint16_t level; |
---|
107 | 94 | }; |
---|
108 | 95 | |
---|
109 | 96 | /* |
---|
.. | .. |
---|
230 | 217 | * A 64-bit or 32-bit inode number follows here, at a variable offset |
---|
231 | 218 | * after the name. |
---|
232 | 219 | */ |
---|
233 | | -} xfs_dir2_sf_entry_t; |
---|
| 220 | +} __packed xfs_dir2_sf_entry_t; |
---|
234 | 221 | |
---|
235 | 222 | static inline int xfs_dir2_sf_hdr_size(int i8count) |
---|
236 | 223 | { |
---|
.. | .. |
---|
434 | 421 | __be32 pad; /* 64 bit alignment */ |
---|
435 | 422 | }; |
---|
436 | 423 | |
---|
437 | | -struct xfs_dir3_icleaf_hdr { |
---|
438 | | - uint32_t forw; |
---|
439 | | - uint32_t back; |
---|
440 | | - uint16_t magic; |
---|
441 | | - uint16_t count; |
---|
442 | | - uint16_t stale; |
---|
443 | | -}; |
---|
444 | | - |
---|
445 | 424 | /* |
---|
446 | 425 | * Leaf block entry. |
---|
447 | 426 | */ |
---|
.. | .. |
---|
482 | 461 | } |
---|
483 | 462 | |
---|
484 | 463 | /* |
---|
485 | | - * Free space block defintions for the node format. |
---|
| 464 | + * Free space block definitions for the node format. |
---|
486 | 465 | */ |
---|
487 | 466 | |
---|
488 | 467 | /* |
---|
.. | .. |
---|
519 | 498 | }; |
---|
520 | 499 | |
---|
521 | 500 | #define XFS_DIR3_FREE_CRC_OFF offsetof(struct xfs_dir3_free, hdr.hdr.crc) |
---|
522 | | - |
---|
523 | | -/* |
---|
524 | | - * In core version of the free block header, abstracted away from on-disk format |
---|
525 | | - * differences. Use this in the code, and convert to/from the disk version using |
---|
526 | | - * xfs_dir3_free_hdr_from_disk/xfs_dir3_free_hdr_to_disk. |
---|
527 | | - */ |
---|
528 | | -struct xfs_dir3_icfree_hdr { |
---|
529 | | - uint32_t magic; |
---|
530 | | - uint32_t firstdb; |
---|
531 | | - uint32_t nvalid; |
---|
532 | | - uint32_t nused; |
---|
533 | | - |
---|
534 | | -}; |
---|
535 | 501 | |
---|
536 | 502 | /* |
---|
537 | 503 | * Single block format. |
---|
.. | .. |
---|
613 | 579 | /* |
---|
614 | 580 | * Entries are packed toward the top as tight as possible. |
---|
615 | 581 | */ |
---|
616 | | -typedef struct xfs_attr_shortform { |
---|
| 582 | +struct xfs_attr_shortform { |
---|
617 | 583 | struct xfs_attr_sf_hdr { /* constant-structure header block */ |
---|
618 | 584 | __be16 totsize; /* total bytes in shortform list */ |
---|
619 | 585 | __u8 count; /* count of active entries */ |
---|
.. | .. |
---|
623 | 589 | uint8_t namelen; /* actual length of name (no NULL) */ |
---|
624 | 590 | uint8_t valuelen; /* actual length of value (no NULL) */ |
---|
625 | 591 | uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */ |
---|
626 | | - uint8_t nameval[1]; /* name & value bytes concatenated */ |
---|
| 592 | + uint8_t nameval[]; /* name & value bytes concatenated */ |
---|
627 | 593 | } list[1]; /* variable sized array */ |
---|
628 | | -} xfs_attr_shortform_t; |
---|
| 594 | +}; |
---|
629 | 595 | |
---|
630 | 596 | typedef struct xfs_attr_leaf_map { /* RLE map of free bytes */ |
---|
631 | 597 | __be16 base; /* base of free region */ |
---|
.. | .. |
---|
710 | 676 | }; |
---|
711 | 677 | |
---|
712 | 678 | /* |
---|
713 | | - * incore, neutral version of the attribute leaf header |
---|
714 | | - */ |
---|
715 | | -struct xfs_attr3_icleaf_hdr { |
---|
716 | | - uint32_t forw; |
---|
717 | | - uint32_t back; |
---|
718 | | - uint16_t magic; |
---|
719 | | - uint16_t count; |
---|
720 | | - uint16_t usedbytes; |
---|
721 | | - /* |
---|
722 | | - * firstused is 32-bit here instead of 16-bit like the on-disk variant |
---|
723 | | - * to support maximum fsb size of 64k without overflow issues throughout |
---|
724 | | - * the attr code. Instead, the overflow condition is handled on |
---|
725 | | - * conversion to/from disk. |
---|
726 | | - */ |
---|
727 | | - uint32_t firstused; |
---|
728 | | - __u8 holes; |
---|
729 | | - struct { |
---|
730 | | - uint16_t base; |
---|
731 | | - uint16_t size; |
---|
732 | | - } freemap[XFS_ATTR_LEAF_MAPSIZE]; |
---|
733 | | -}; |
---|
734 | | - |
---|
735 | | -/* |
---|
736 | 679 | * Special value to represent fs block size in the leaf header firstused field. |
---|
737 | 680 | * Only used when block size overflows the 2-bytes available on disk. |
---|
738 | 681 | */ |
---|
.. | .. |
---|
740 | 683 | |
---|
741 | 684 | /* |
---|
742 | 685 | * Flags used in the leaf_entry[i].flags field. |
---|
743 | | - * NOTE: the INCOMPLETE bit must not collide with the flags bits specified |
---|
744 | | - * on the system call, they are "or"ed together for various operations. |
---|
745 | 686 | */ |
---|
746 | 687 | #define XFS_ATTR_LOCAL_BIT 0 /* attr is stored locally */ |
---|
747 | 688 | #define XFS_ATTR_ROOT_BIT 1 /* limit access to trusted attrs */ |
---|
.. | .. |
---|
751 | 692 | #define XFS_ATTR_ROOT (1 << XFS_ATTR_ROOT_BIT) |
---|
752 | 693 | #define XFS_ATTR_SECURE (1 << XFS_ATTR_SECURE_BIT) |
---|
753 | 694 | #define XFS_ATTR_INCOMPLETE (1 << XFS_ATTR_INCOMPLETE_BIT) |
---|
754 | | - |
---|
755 | | -/* |
---|
756 | | - * Conversion macros for converting namespace bits from argument flags |
---|
757 | | - * to ondisk flags. |
---|
758 | | - */ |
---|
759 | | -#define XFS_ATTR_NSP_ARGS_MASK (ATTR_ROOT | ATTR_SECURE) |
---|
760 | 695 | #define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE) |
---|
761 | | -#define XFS_ATTR_NSP_ONDISK(flags) ((flags) & XFS_ATTR_NSP_ONDISK_MASK) |
---|
762 | | -#define XFS_ATTR_NSP_ARGS(flags) ((flags) & XFS_ATTR_NSP_ARGS_MASK) |
---|
763 | | -#define XFS_ATTR_NSP_ARGS_TO_ONDISK(x) (((x) & ATTR_ROOT ? XFS_ATTR_ROOT : 0) |\ |
---|
764 | | - ((x) & ATTR_SECURE ? XFS_ATTR_SECURE : 0)) |
---|
765 | | -#define XFS_ATTR_NSP_ONDISK_TO_ARGS(x) (((x) & XFS_ATTR_ROOT ? ATTR_ROOT : 0) |\ |
---|
766 | | - ((x) & XFS_ATTR_SECURE ? ATTR_SECURE : 0)) |
---|
767 | 696 | |
---|
768 | 697 | /* |
---|
769 | 698 | * Alignment for namelist and valuelist entries (since they are mixed |
---|
.. | .. |
---|
817 | 746 | */ |
---|
818 | 747 | static inline int xfs_attr_leaf_entsize_remote(int nlen) |
---|
819 | 748 | { |
---|
820 | | - return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \ |
---|
821 | | - XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1); |
---|
| 749 | + return round_up(sizeof(struct xfs_attr_leaf_name_remote) - 1 + |
---|
| 750 | + nlen, XFS_ATTR_LEAF_NAME_ALIGN); |
---|
822 | 751 | } |
---|
823 | 752 | |
---|
824 | 753 | static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen) |
---|
825 | 754 | { |
---|
826 | | - return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) + |
---|
827 | | - XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1); |
---|
| 755 | + return round_up(sizeof(struct xfs_attr_leaf_name_local) - 1 + |
---|
| 756 | + nlen + vlen, XFS_ATTR_LEAF_NAME_ALIGN); |
---|
828 | 757 | } |
---|
829 | 758 | |
---|
830 | 759 | static inline int xfs_attr_leaf_entsize_local_max(int bsize) |
---|
.. | .. |
---|
869 | 798 | return 1 << (sbp->sb_blocklog + sbp->sb_dirblklog); |
---|
870 | 799 | } |
---|
871 | 800 | |
---|
| 801 | +xfs_failaddr_t xfs_da3_blkinfo_verify(struct xfs_buf *bp, |
---|
| 802 | + struct xfs_da3_blkinfo *hdr3); |
---|
| 803 | + |
---|
872 | 804 | #endif /* __XFS_DA_FORMAT_H__ */ |
---|