* [PATCH 1/6] mkfs: don't redefine DIRT for protofiles
2026-06-30 1:02 [PATCHSET 2/4] mkfs.xfs: codex-inspired bug fixes Darrick J. Wong
@ 2026-06-30 1:02 ` Darrick J. Wong
2026-06-30 5:31 ` Christoph Hellwig
2026-06-30 1:03 ` [PATCH 2/6] mkfs: fix PATH_MAX check Darrick J. Wong
` (4 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2026-06-30 1:02 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
Codex noticed that the mkfs Makefile redefines DIRT to point only to the
xfs_protofile script. This overrides the more expansive definition in
buildrules; we should use LDIRT instead.
Cc: <linux-xfs@vger.kernel.org> # v6.13.0
Fixes: 6aace700b7b82d ("mkfs: add a utility to generate protofiles")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
mkfs/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkfs/Makefile b/mkfs/Makefile
index fb1473324cde7c..16793bdb1e03e3 100644
--- a/mkfs/Makefile
+++ b/mkfs/Makefile
@@ -25,7 +25,7 @@ LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBRT) $(LIBBLKID) \
$(LIBUUID) $(LIBINIH) $(LIBURCU) $(LIBPTHREAD)
LTDEPENDENCIES += $(LIBXFS) $(LIBXCMD) $(LIBFROG)
LLDFLAGS = -static-libtool-libs
-DIRT = $(XFS_PROTOFILE)
+LDIRT = $(XFS_PROTOFILE)
default: depend $(LTCOMMAND) $(CFGFILES) $(XFS_PROTOFILE)
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 2/6] mkfs: fix PATH_MAX check
2026-06-30 1:02 [PATCHSET 2/4] mkfs.xfs: codex-inspired bug fixes Darrick J. Wong
2026-06-30 1:02 ` [PATCH 1/6] mkfs: don't redefine DIRT for protofiles Darrick J. Wong
@ 2026-06-30 1:03 ` Darrick J. Wong
2026-06-30 5:31 ` Christoph Hellwig
2026-06-30 1:03 ` [PATCH 3/6] mkfs: fix symlink target length check in create_nondir_inode Darrick J. Wong
` (3 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2026-06-30 1:03 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
Per the snprintf manpage, the correct means to check snprintf for an
insufficiently large buffer is to check if its return value is >= @size,
not > @size. Codex found this.
Cc: <linux-xfs@vger.kernel.org> # v6.17.0
Fixes: 8a4ea72724930c ("proto: add ability to populate a filesystem from a directory")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
mkfs/proto.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkfs/proto.c b/mkfs/proto.c
index a460aebd95ae1e..e167cba1d8d3ec 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -1674,7 +1674,7 @@ handle_direntry(
/* Ensure we're within the limits of PATH_MAX. */
size_t avail = PATH_MAX - path_len;
size_t wrote = snprintf(path_buf + path_len, avail, "/%s", entry->d_name);
- if (wrote > avail)
+ if (wrote >= avail)
fail(path_buf, ENAMETOOLONG);
/*
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 3/6] mkfs: fix symlink target length check in create_nondir_inode
2026-06-30 1:02 [PATCHSET 2/4] mkfs.xfs: codex-inspired bug fixes Darrick J. Wong
2026-06-30 1:02 ` [PATCH 1/6] mkfs: don't redefine DIRT for protofiles Darrick J. Wong
2026-06-30 1:03 ` [PATCH 2/6] mkfs: fix PATH_MAX check Darrick J. Wong
@ 2026-06-30 1:03 ` Darrick J. Wong
2026-06-30 5:34 ` Christoph Hellwig
2026-06-30 1:03 ` [PATCH 4/6] mkfs: fix hardlink detection in directory import code Darrick J. Wong
` (2 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2026-06-30 1:03 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
Codex complains about the way this function tries to detect symlink
targets that are so long that the new filesystem cannot handle them.
Specifically, it complains about the confusion between
XFS_SYMLINK_MAXLEN and PATH_MAX.
To be clear, XFS cannot handle targets longer than XFS_SYMLINK_MAXLEN
bytes. PATH_MAX is irrelevant here. The manpage for readlink(3) says
that it returns the number of bytes copied into the buffer and does not
say that it null-terminates the buffer. Therefore, the only way to
detect the overflow condition is to declare a buffer larger than
XFS_SYMLINK_MAXLEN and see if readink returns a value greater than
XFS_SYMLINK_MAXLEN.
Cc: <linux-xfs@vger.kernel.org> # v6.17.0
Fixes: 8a4ea72724930c ("proto: add ability to populate a filesystem from a directory")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
mkfs/proto.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mkfs/proto.c b/mkfs/proto.c
index e167cba1d8d3ec..e258424ae4140a 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -1542,7 +1542,7 @@ create_nondir_inode(
char *src_fname)
{
- char link_target[XFS_SYMLINK_MAXLEN];
+ char link_target[XFS_SYMLINK_MAXLEN + 1];
int error;
ssize_t link_len = 0;
struct xfs_inode *ip;
@@ -1563,10 +1563,10 @@ create_nondir_inode(
* We need to read out our link target and act accordingly.
*/
if (xname.type == XFS_DIR3_FT_SYMLINK) {
- link_len = readlink(src_fname, link_target, XFS_SYMLINK_MAXLEN);
+ link_len = readlink(src_fname, link_target, sizeof(link_target));
if (link_len < 0)
fail(_("could not resolve symlink"), errno);
- if (link_len >= PATH_MAX)
+ if (link_len > XFS_SYMLINK_MAXLEN)
fail(_("symlink target too long"), ENAMETOOLONG);
tp = getres(mp, XFS_B_TO_FSB(mp, link_len));
} else {
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 3/6] mkfs: fix symlink target length check in create_nondir_inode
2026-06-30 1:03 ` [PATCH 3/6] mkfs: fix symlink target length check in create_nondir_inode Darrick J. Wong
@ 2026-06-30 5:34 ` Christoph Hellwig
0 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2026-06-30 5:34 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: aalbersh, linux-xfs, hch
On Mon, Jun 29, 2026 at 06:03:26PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Codex complains about the way this function tries to detect symlink
> targets that are so long that the new filesystem cannot handle them.
> Specifically, it complains about the confusion between
> XFS_SYMLINK_MAXLEN and PATH_MAX.
>
> To be clear, XFS cannot handle targets longer than XFS_SYMLINK_MAXLEN
> bytes. PATH_MAX is irrelevant here. The manpage for readlink(3) says
> that it returns the number of bytes copied into the buffer and does not
> say that it null-terminates the buffer. Therefore, the only way to
> detect the overflow condition is to declare a buffer larger than
> XFS_SYMLINK_MAXLEN and see if readink returns a value greater than
> XFS_SYMLINK_MAXLEN.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 4/6] mkfs: fix hardlink detection in directory import code
2026-06-30 1:02 [PATCHSET 2/4] mkfs.xfs: codex-inspired bug fixes Darrick J. Wong
` (2 preceding siblings ...)
2026-06-30 1:03 ` [PATCH 3/6] mkfs: fix symlink target length check in create_nondir_inode Darrick J. Wong
@ 2026-06-30 1:03 ` Darrick J. Wong
2026-06-30 5:38 ` Christoph Hellwig
2026-06-30 1:03 ` [PATCH 5/6] mkfs: PQUOTA shouldn't conflict with GQNOENFORCE Darrick J. Wong
2026-06-30 1:04 ` [PATCH 6/6] xfs_protofile: make nondirectory arguments actually work Darrick J. Wong
5 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2026-06-30 1:03 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
There's a serious problem in the hardlink detection code in the new mkfs
protofile functionality that copies a directory tree into the new
filesystem. It's been long established that hardlinks can only be
detected by comparing st_ino *and* st_dev, but the new code doesn't do
that. Fix the detector, and stop passing struct stat objects by
value(!) since they are quite large.
Cc: <linux-xfs@vger.kernel.org> # v6.17.0
Fixes: 8a4ea72724930c ("proto: add ability to populate a filesystem from a directory")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
mkfs/proto.c | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/mkfs/proto.c b/mkfs/proto.c
index e258424ae4140a..32add2b5e8dc94 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -1285,7 +1285,7 @@ writefsxattrs(
static void
writetimestamps(
struct xfs_inode *ip,
- struct stat *statbuf)
+ const struct stat *statbuf)
{
struct timespec64 ts;
@@ -1314,6 +1314,7 @@ writetimestamps(
}
struct hardlink {
+ dev_t src_dev;
ino_t src_ino;
xfs_ino_t dst_ino;
};
@@ -1362,10 +1363,11 @@ cleanup_hardlink_tracker(void)
static xfs_ino_t
get_hardlink_dst_inode(
- xfs_ino_t i_ino)
+ const struct stat *filestat)
{
for (size_t i = 0; i < hardlink_tracker.count; i++) {
- if (hardlink_tracker.entries[i].src_ino == i_ino)
+ if (hardlink_tracker.entries[i].src_dev == filestat->st_dev &&
+ hardlink_tracker.entries[i].src_ino == filestat->st_ino)
return hardlink_tracker.entries[i].dst_ino;
}
return 0;
@@ -1373,8 +1375,8 @@ get_hardlink_dst_inode(
static void
track_hardlink_inode(
- ino_t src_ino,
- xfs_ino_t dst_ino)
+ const struct stat *filestat,
+ xfs_ino_t dst_ino)
{
if (hardlink_tracker.count >= hardlink_tracker.size) {
/*
@@ -1399,7 +1401,8 @@ track_hardlink_inode(
hardlink_tracker.entries = resized_array;
hardlink_tracker.size = new_size;
}
- hardlink_tracker.entries[hardlink_tracker.count].src_ino = src_ino;
+ hardlink_tracker.entries[hardlink_tracker.count].src_dev = filestat->st_dev;
+ hardlink_tracker.entries[hardlink_tracker.count].src_ino = filestat->st_ino;
hardlink_tracker.entries[hardlink_tracker.count].dst_ino = dst_ino;
hardlink_tracker.count++;
}
@@ -1415,7 +1418,7 @@ handle_hardlink(
struct xfs_mount *mp,
struct xfs_inode *pip,
struct xfs_name xname,
- struct stat file_stat)
+ const struct stat *file_stat)
{
int error;
xfs_ino_t dst_ino;
@@ -1429,7 +1432,7 @@ handle_hardlink(
* inode as a regular file type, and later save the source inode in our
* buffer for future consumption.
*/
- dst_ino = get_hardlink_dst_inode(file_stat.st_ino);
+ dst_ino = get_hardlink_dst_inode(file_stat);
if (dst_ino == 0)
return false;
@@ -1536,7 +1539,7 @@ create_nondir_inode(
struct cred creds,
struct xfs_name xname,
int flags,
- struct stat file_stat,
+ const struct stat *file_stat,
xfs_dev_t rdev,
int fd,
char *src_fname)
@@ -1553,7 +1556,7 @@ create_nondir_inode(
* If handle_hardlink() returns true it means the hardlink has been
* correctly found and set, so we don't need to do anything else.
*/
- if (file_stat.st_nlink > 1 && handle_hardlink(mp, pip, xname, file_stat)) {
+ if (file_stat->st_nlink > 1 && handle_hardlink(mp, pip, xname, file_stat)) {
close(fd);
return;
}
@@ -1591,7 +1594,7 @@ create_nondir_inode(
/*
* Copy over timestamps.
*/
- writetimestamps(ip, &file_stat);
+ writetimestamps(ip, file_stat);
libxfs_trans_log_inode(tp, ip, flags);
@@ -1622,8 +1625,8 @@ create_nondir_inode(
* If we're here it means this is the first time we're encountering an
* hardlink, so we need to store it.
*/
- if (file_stat.st_nlink > 1)
- track_hardlink_inode(file_stat.st_ino, ip->i_ino);
+ if (file_stat->st_nlink > 1)
+ track_hardlink_inode(file_stat, ip->i_ino);
libxfs_irele(ip);
}
@@ -1777,8 +1780,8 @@ handle_direntry(
break;
}
- create_nondir_inode(mp, pip, fsxp, mode, creds, xname, flags, file_stat,
- rdev, fd, fname);
+ create_nondir_inode(mp, pip, fsxp, mode, creds, xname, flags,
+ &file_stat, rdev, fd, fname);
out:
close(pathfd);
/* Reset path_buf to original */
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 4/6] mkfs: fix hardlink detection in directory import code
2026-06-30 1:03 ` [PATCH 4/6] mkfs: fix hardlink detection in directory import code Darrick J. Wong
@ 2026-06-30 5:38 ` Christoph Hellwig
2026-06-30 16:28 ` Darrick J. Wong
0 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2026-06-30 5:38 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: aalbersh, linux-xfs, hch
On Mon, Jun 29, 2026 at 06:03:41PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> There's a serious problem in the hardlink detection code in the new mkfs
> protofile functionality that copies a directory tree into the new
> filesystem. It's been long established that hardlinks can only be
> detected by comparing st_ino *and* st_dev, but the new code doesn't do
> that.
Yes.
> Fix the detector, and stop passing struct stat objects by
> value(!) since they are quite large.
Without looking at the code I suspect the compiler silently passes
them by references as long as the functions are static, but it's
still good to fix this up.
> static void
> writetimestamps(
> struct xfs_inode *ip,
> - struct stat *statbuf)
> + const struct stat *statbuf)
It also seems to constify a few things :)
> - hardlink_tracker.entries[hardlink_tracker.count].src_ino = src_ino;
> + hardlink_tracker.entries[hardlink_tracker.count].src_dev = filestat->st_dev;
> + hardlink_tracker.entries[hardlink_tracker.count].src_ino = filestat->st_ino;
> hardlink_tracker.entries[hardlink_tracker.count].dst_ino = dst_ino;
A bunch of overly long lines. This would probably benefit from
a local variable for the tracker entry.
Otherwise looks good, although I would have split it into a few patches.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 4/6] mkfs: fix hardlink detection in directory import code
2026-06-30 5:38 ` Christoph Hellwig
@ 2026-06-30 16:28 ` Darrick J. Wong
0 siblings, 0 replies; 15+ messages in thread
From: Darrick J. Wong @ 2026-06-30 16:28 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: aalbersh, linux-xfs
On Tue, Jun 30, 2026 at 07:38:52AM +0200, Christoph Hellwig wrote:
> On Mon, Jun 29, 2026 at 06:03:41PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > There's a serious problem in the hardlink detection code in the new mkfs
> > protofile functionality that copies a directory tree into the new
> > filesystem. It's been long established that hardlinks can only be
> > detected by comparing st_ino *and* st_dev, but the new code doesn't do
> > that.
>
> Yes.
>
> > Fix the detector, and stop passing struct stat objects by
> > value(!) since they are quite large.
>
> Without looking at the code I suspect the compiler silently passes
> them by references as long as the functions are static, but it's
> still good to fix this up.
>
> > static void
> > writetimestamps(
> > struct xfs_inode *ip,
> > - struct stat *statbuf)
> > + const struct stat *statbuf)
>
> It also seems to constify a few things :)
Yeah, I'll modify the commit message to state that we pass around const
statbuf pointers because none of the protofile code needs to modify them
once we've sampled the open fd.
> > - hardlink_tracker.entries[hardlink_tracker.count].src_ino = src_ino;
> > + hardlink_tracker.entries[hardlink_tracker.count].src_dev = filestat->st_dev;
> > + hardlink_tracker.entries[hardlink_tracker.count].src_ino = filestat->st_ino;
> > hardlink_tracker.entries[hardlink_tracker.count].dst_ino = dst_ino;
>
> A bunch of overly long lines. This would probably benefit from
> a local variable for the tracker entry.
and add a convenience variable here to reduce the long lines.
> Otherwise looks good, although I would have split it into a few patches.
<nod> I'll go fix the statbuf pointers separately then.
--D
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 5/6] mkfs: PQUOTA shouldn't conflict with GQNOENFORCE
2026-06-30 1:02 [PATCHSET 2/4] mkfs.xfs: codex-inspired bug fixes Darrick J. Wong
` (3 preceding siblings ...)
2026-06-30 1:03 ` [PATCH 4/6] mkfs: fix hardlink detection in directory import code Darrick J. Wong
@ 2026-06-30 1:03 ` Darrick J. Wong
2026-06-30 5:41 ` Christoph Hellwig
2026-06-30 1:04 ` [PATCH 6/6] xfs_protofile: make nondirectory arguments actually work Darrick J. Wong
5 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2026-06-30 1:03 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
Codex points out that project quota isn't incompatible with
non-enforcing group quota in the kernel, so those shouldn't be
incompatible in mkfs either.
Cc: <linux-xfs@vger.kernel.org> # v6.13.0
Fixes: 525f826429a868 ("mkfs: add quota flags when setting up filesystem")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
mkfs/xfs_mkfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 3da11c664255b1..a4864c37a8821b 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -976,7 +976,7 @@ static struct opt_params mopts = {
.defaultval = 1,
},
{ .index = M_PQUOTA,
- .conflicts = { { &mopts, M_GQNOENFORCE },
+ .conflicts = { { &mopts, M_PQNOENFORCE },
{ NULL, LAST_CONFLICT } },
.minval = 0,
.maxval = 1,
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 5/6] mkfs: PQUOTA shouldn't conflict with GQNOENFORCE
2026-06-30 1:03 ` [PATCH 5/6] mkfs: PQUOTA shouldn't conflict with GQNOENFORCE Darrick J. Wong
@ 2026-06-30 5:41 ` Christoph Hellwig
2026-06-30 16:27 ` Darrick J. Wong
0 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2026-06-30 5:41 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: aalbersh, linux-xfs, hch
On Mon, Jun 29, 2026 at 06:03:57PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Codex points out that project quota isn't incompatible with
> non-enforcing group quota in the kernel, so those shouldn't be
> incompatible in mkfs either.
For file systems with XFS_SB_VERSION_QUOTABIT there is no incompatibility
at all, enforcing or not.
>
> Cc: <linux-xfs@vger.kernel.org> # v6.13.0
> Fixes: 525f826429a868 ("mkfs: add quota flags when setting up filesystem")
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> ---
> mkfs/xfs_mkfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 3da11c664255b1..a4864c37a8821b 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -976,7 +976,7 @@ static struct opt_params mopts = {
> .defaultval = 1,
> },
> { .index = M_PQUOTA,
> - .conflicts = { { &mopts, M_GQNOENFORCE },
> + .conflicts = { { &mopts, M_PQNOENFORCE },
> { NULL, LAST_CONFLICT } },
But I think this is just fat-fingering anyway, as it wants to
conflict the pquota vs pquota no enforce options. So I think
the commit log could use some rewording for clarify, but the
change looks good.
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 5/6] mkfs: PQUOTA shouldn't conflict with GQNOENFORCE
2026-06-30 5:41 ` Christoph Hellwig
@ 2026-06-30 16:27 ` Darrick J. Wong
0 siblings, 0 replies; 15+ messages in thread
From: Darrick J. Wong @ 2026-06-30 16:27 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: aalbersh, linux-xfs
On Tue, Jun 30, 2026 at 07:41:22AM +0200, Christoph Hellwig wrote:
> On Mon, Jun 29, 2026 at 06:03:57PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > Codex points out that project quota isn't incompatible with
> > non-enforcing group quota in the kernel, so those shouldn't be
> > incompatible in mkfs either.
>
> For file systems with XFS_SB_VERSION_QUOTABIT there is no incompatibility
> at all, enforcing or not.
>
> >
> > Cc: <linux-xfs@vger.kernel.org> # v6.13.0
> > Fixes: 525f826429a868 ("mkfs: add quota flags when setting up filesystem")
> > Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> > ---
> > mkfs/xfs_mkfs.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >
> > diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> > index 3da11c664255b1..a4864c37a8821b 100644
> > --- a/mkfs/xfs_mkfs.c
> > +++ b/mkfs/xfs_mkfs.c
> > @@ -976,7 +976,7 @@ static struct opt_params mopts = {
> > .defaultval = 1,
> > },
> > { .index = M_PQUOTA,
> > - .conflicts = { { &mopts, M_GQNOENFORCE },
> > + .conflicts = { { &mopts, M_PQNOENFORCE },
> > { NULL, LAST_CONFLICT } },
>
> But I think this is just fat-fingering anyway, as it wants to
> conflict the pquota vs pquota no enforce options. So I think
> the commit log could use some rewording for clarify, but the
> change looks good.
Ok, how about:
"Codex points out that project quota isn't incompatible with
non-enforcing group quota in the kernel, so those shouldn't be
incompatible in mkfs either.
"Furthermore, project and group quotas are never incompatible on
QUOTABIT and V5 filesystems, so this is clearly a fat-finger error."
--D
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 6/6] xfs_protofile: make nondirectory arguments actually work
2026-06-30 1:02 [PATCHSET 2/4] mkfs.xfs: codex-inspired bug fixes Darrick J. Wong
` (4 preceding siblings ...)
2026-06-30 1:03 ` [PATCH 5/6] mkfs: PQUOTA shouldn't conflict with GQNOENFORCE Darrick J. Wong
@ 2026-06-30 1:04 ` Darrick J. Wong
2026-06-30 5:45 ` Christoph Hellwig
5 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2026-06-30 1:04 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
Codex points out that xfs_protofile fails if you pass it paths to
non-directories. It's supposed to just copy them into the root
directory, but we don't actually do that.
Cc: <linux-xfs@vger.kernel.org> # v6.13.0
Fixes: 6aace700b7b82d ("mkfs: add a utility to generate protofiles")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
mkfs/xfs_protofile.py.in | 40 +++++++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/mkfs/xfs_protofile.py.in b/mkfs/xfs_protofile.py.in
index 40d06ddb44aa30..00010fa7b3b041 100644
--- a/mkfs/xfs_protofile.py.in
+++ b/mkfs/xfs_protofile.py.in
@@ -66,46 +66,56 @@ def max_fname_len(s1):
'''Return the length of the longest string in s1.'''
ret = 0
for s in s1:
+ ss = os.path.basename(s)
if len(s) > ret:
ret = len(s)
return ret
+def list_maybe_dir(path, depth):
+ try:
+ for fname in os.listdir(path):
+ yield os.path.join(path, fname)
+ except NotADirectoryError as e:
+ if depth == 1:
+ yield path
+ return
+ raise e
+
def walk_tree(path, depth):
'''Walk the directory tree rooted by path.'''
dirs = []
files = []
- for fname in os.listdir(path):
- fullpath = os.path.join(path, fname)
+ for fullpath in list_maybe_dir(path, depth):
sb = os.lstat(fullpath)
if stat.S_ISDIR(sb.st_mode):
- dirs.append(fname)
+ dirs.append(fullpath)
continue
elif stat.S_ISSOCK(sb.st_mode):
continue
else:
- files.append(fname)
+ files.append(fullpath)
- for fname in files:
- if ' ' in fname:
+ for fullpath in files:
+ if ' ' in os.path.basename(fullpath):
msg = _("Spaces not allowed in file names.")
- raise ValueError(f'{fname}: {msg}')
- for fname in dirs:
- if ' ' in fname:
+ raise ValueError(f'{fullpath}: {msg}')
+ for fullpath in dirs:
+ if ' ' in os.path.basename(fullpath):
msg = _("Spaces not allowed in subdirectory names.")
- raise Exception(f'{fname}: {msg}')
+ raise Exception(f'{fullpath}: {msg}')
fname_width = max_fname_len(files)
- for fname in files:
- fullpath = os.path.join(path, fname)
+ for fullpath in files:
+ fname = os.path.basename(fullpath)
sb = os.lstat(fullpath)
extra = stat_to_extra(sb, fullpath)
print('%*s%-*s %s%s' % (depth, ' ', fname_width, fname, \
stat_to_str(sb), extra))
- for fname in dirs:
- fullpath = os.path.join(path, fname)
+ for fullpath in dirs:
+ fname = os.path.basename(fullpath)
sb = os.lstat(fullpath)
extra = stat_to_extra(sb, fullpath)
print('%*s%s %s' % (depth, ' ', fname, \
@@ -138,7 +148,7 @@ def main():
# Copy the first argument's stat to the rootdir
statbuf = os.stat(args.paths[0])
if not stat.S_ISDIR(statbuf.st_mode):
- raise NotADirectoryError(path)
+ raise NotADirectoryError(args.paths[0])
print(stat_to_str(statbuf))
# All files under each path go in the root dir, recursively
^ permalink raw reply related [flat|nested] 15+ messages in thread