mirror of
https://github.com/kdave/btrfs-progs
synced 2025-03-01 08:20:45 +00:00
Add back pointers from the inode to the directory that referenced it
This commit is contained in:
parent
66d0930cf6
commit
fba66bd865
12
ctree.h
12
ctree.h
@ -192,6 +192,11 @@ struct btrfs_extent_ref {
|
||||
__le64 offset;
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
struct btrfs_inode_ref {
|
||||
__le16 name_len;
|
||||
/* name goes here */
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
struct btrfs_inode_timespec {
|
||||
__le64 sec;
|
||||
__le32 nsec;
|
||||
@ -352,7 +357,8 @@ struct btrfs_root {
|
||||
* the FS
|
||||
*/
|
||||
#define BTRFS_INODE_ITEM_KEY 1
|
||||
#define BTRFS_XATTR_ITEM_KEY 2
|
||||
#define BTRFS_INODE_REF_KEY 2
|
||||
#define BTRFS_XATTR_ITEM_KEY 8
|
||||
|
||||
/* reserve 3-15 close to the inode for later flexibility */
|
||||
|
||||
@ -556,6 +562,10 @@ static inline void btrfs_set_timespec_nsec(struct btrfs_inode_timespec *ts,
|
||||
|
||||
BTRFS_SETGET_STACK_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32);
|
||||
|
||||
BTRFS_SETGET_STACK_FUNCS(inode_ref_name_len, struct btrfs_inode_ref,
|
||||
name_len, 16);
|
||||
|
||||
|
||||
BTRFS_SETGET_STACK_FUNCS(ref_root, struct btrfs_extent_ref, root, 64);
|
||||
BTRFS_SETGET_STACK_FUNCS(ref_generation, struct btrfs_extent_ref,
|
||||
generation, 64);
|
||||
|
23
print-tree.c
23
print-tree.c
@ -45,6 +45,24 @@ static int print_dir_item(struct btrfs_item *item,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_inode_ref_item(struct btrfs_item *item,
|
||||
struct btrfs_inode_ref *ref)
|
||||
{
|
||||
u32 total;
|
||||
u32 cur = 0;
|
||||
u32 len;
|
||||
total = btrfs_item_size(item);
|
||||
while(cur < total) {
|
||||
len = btrfs_inode_ref_name_len(ref);
|
||||
printf("\t\tinode ref name: %.*s\n", len, (char *)(ref + 1));
|
||||
len += sizeof(*ref);
|
||||
ref = (struct btrfs_inode_ref *)((char *)ref + len);
|
||||
cur += len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
|
||||
{
|
||||
int i;
|
||||
@ -58,6 +76,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
|
||||
struct btrfs_csum_item *ci;
|
||||
struct btrfs_block_group_item *bi;
|
||||
struct btrfs_extent_ref *ref;
|
||||
struct btrfs_inode_ref *iref;
|
||||
u32 type;
|
||||
|
||||
printf("leaf %llu ptrs %d free space %d generation %llu owner %llu\n",
|
||||
@ -86,6 +105,10 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
|
||||
btrfs_inode_mode(ii),
|
||||
btrfs_inode_nlink(ii));
|
||||
break;
|
||||
case BTRFS_INODE_REF_KEY:
|
||||
iref = btrfs_item_ptr(l, i, struct btrfs_inode_ref);
|
||||
print_inode_ref_item(l->items + i, iref);
|
||||
break;
|
||||
case BTRFS_DIR_ITEM_KEY:
|
||||
di = btrfs_item_ptr(l, i, struct btrfs_dir_item);
|
||||
print_dir_item(l->items + i, di);
|
||||
|
Loading…
Reference in New Issue
Block a user