btrfs-progs/mkfs
Qu Wenruo 0af60b1faf btrfs-progs: mkfs: add the missing xattr for the rootdir inode
[BUG]
When using "mkfs.btrfs" with "--rootdir" option, the top level inode
(rootdir) will not get the same xattr from the source dir:

  mkdir -p source_dir/
  touch source_dir/file
  setfattr -n user.rootdir_xattr source_dir/
  setfattr -n user.regular_xattr source_dir/file
  mkfs.btrfs -f --rootdir source_dir $dev
  mount $dev $mnt
  getfattr $mnt
  # Nothing <<<
  getfattr $mnt/file
  # file: $mnt/file
  user.regular_xattr <<<

[CAUSE]
In function traverse_directory(), we only call add_xattr_item() for all
the child inodes, not really for the rootdir inode itself, leading to
the missing xattr items.

Not only xattr, in fact we also miss the uid/gid/timestamps/mode for the
rootdir inode.

[FIX]
Extract a dedicated function, copy_rootdir_inode(), to handle every
needed attributes for the rootdir inode, including:

- xattr
- uid
- gid
- mode
- timestamps

Issue: #688
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-21 15:51:07 +02:00
..
common.c btrfs-progs: clean up includes, using include-what-you-use 2023-10-03 01:11:57 +02:00
common.h btrfs-progs: clean up includes, using include-what-you-use 2023-10-03 01:11:57 +02:00
main.c btrfs-progs: mkfs: do not enlarge the target block device 2023-10-21 15:51:07 +02:00
Makefile btrfs-progs: build: add stub makefile to image and mkfs 2019-07-04 15:36:01 +02:00
rootdir.c btrfs-progs: mkfs: add the missing xattr for the rootdir inode 2023-10-21 15:51:07 +02:00
rootdir.h btrfs-progs: mkfs: more verbose output for --rootdir 2023-05-26 22:17:33 +02:00