]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
libxfs: when creating a file in a directory, set the project id based on the parent
authorDarrick J. Wong <djwong@kernel.org>
Wed, 3 Jul 2024 21:21:33 +0000 (14:21 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 31 Jul 2024 01:46:41 +0000 (18:46 -0700)
When we're creating a file as a child of an existing directory, use
xfs_get_initial_prid to have the child inherit the project id of the
directory if the directory has PROJINHERIT set, just like the kernel
does.  This fixes mkfs project id propagation with -d projinherit=X when
protofiles are in use.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/inode.c
libxfs/libxfs_api_defs.h

index 132cf990dc35126e65914df8492c3846932db66f..d022b41b6e04af6f96d24b0d4050ebdf2fd25269 100644 (file)
@@ -121,6 +121,9 @@ libxfs_icreate(
                        inode->i_mode |= S_ISGID;
        }
 
+       if (pip)
+               ip->i_projid = libxfs_get_initial_prid(pip);
+
        ip->i_disk_size = 0;
        ip->i_df.if_nextents = 0;
        ASSERT(ip->i_nblocks == 0);
index 26948849b9641a5c1a5c280708c17d251b9f378c..87f2ccf93fe21cb09706abc6e3f688890a30f8c5 100644 (file)
 #define xfs_free_perag                 libxfs_free_perag
 #define xfs_fs_geometry                        libxfs_fs_geometry
 #define xfs_get_projid                 libxfs_get_projid
+#define xfs_get_initial_prid           libxfs_get_initial_prid
 #define xfs_highbit32                  libxfs_highbit32
 #define xfs_highbit64                  libxfs_highbit64
 #define xfs_ialloc_calc_rootino                libxfs_ialloc_calc_rootino