mbox series

[v3,0/2] btrfs-progs: make sure "mkfs --rootdir" copies all the attributes for the rootdir

Message ID cover.1697057301.git.wqu@suse.com (mailing list archive)
Headers show
Series btrfs-progs: make sure "mkfs --rootdir" copies all the attributes for the rootdir | expand

Message

Qu Wenruo Oct. 11, 2023, 8:49 p.m. UTC
[CHANGELOG]
v3:
- Use 'stat()' instead pf 'lstate()' for the rootdir
  This would follow a softlink for the rootdir.

v2:
- Add more attributes to be copied for rootdir, including:
  * mode
  * uid
  * gid
  * timestamps

- Update the test case
  * Use two loopback devices
    One to store the source directory, so that we're ensured to have
    xattr support.
  * Add checks for all the uid/gid/mode attributes

We got a bug report that "mkfs.btrfs --rootdir" copies all the xattr but
the xattr of the source directory.

It turns out that we only do the regular xattr/gid/uid/mode/timestamps
copy for all the child inodes, not the source directory itself.

Fix it and create a test case for it.

Qu Wenruo (2):
  btrfs-progs: mkfs/rootdir: copy missing attributes for the rootdir
    inode
  btrfs-progs: tests/mkfs: make sure rootdir inode got its attributes
    copied

 mkfs/rootdir.c                             | 88 ++++++++++++++++------
 tests/mkfs-tests/027-rootdir-inode/test.sh | 60 +++++++++++++++
 2 files changed, 127 insertions(+), 21 deletions(-)
 create mode 100755 tests/mkfs-tests/027-rootdir-inode/test.sh

--
2.42.0

Comments

David Sterba Oct. 13, 2023, 4:21 p.m. UTC | #1
On Thu, Oct 12, 2023 at 07:19:24AM +1030, Qu Wenruo wrote:
> [CHANGELOG]
> v3:
> - Use 'stat()' instead pf 'lstate()' for the rootdir
>   This would follow a softlink for the rootdir.
> 
> v2:
> - Add more attributes to be copied for rootdir, including:
>   * mode
>   * uid
>   * gid
>   * timestamps
> 
> - Update the test case
>   * Use two loopback devices
>     One to store the source directory, so that we're ensured to have
>     xattr support.
>   * Add checks for all the uid/gid/mode attributes
> 
> We got a bug report that "mkfs.btrfs --rootdir" copies all the xattr but
> the xattr of the source directory.
> 
> It turns out that we only do the regular xattr/gid/uid/mode/timestamps
> copy for all the child inodes, not the source directory itself.
> 
> Fix it and create a test case for it.
> 
> Qu Wenruo (2):
>   btrfs-progs: mkfs/rootdir: copy missing attributes for the rootdir
>     inode
>   btrfs-progs: tests/mkfs: make sure rootdir inode got its attributes
>     copied

Added to devel with some fixups, thanks.