* [PATCH 1/3] mkfs: fix file size setting when interpreting a protofile
2025-02-03 22:40 [PATCHSET] xfsprogs: random bug fixes Darrick J. Wong
@ 2025-02-03 22:40 ` Darrick J. Wong
2025-02-04 4:53 ` Christoph Hellwig
2025-02-03 22:40 ` [PATCH 2/3] xfs_protofile: fix mode formatting error Darrick J. Wong
2025-02-03 22:40 ` [PATCH 3/3] xfs_protofile: fix device number encoding Darrick J. Wong
2 siblings, 1 reply; 7+ messages in thread
From: Darrick J. Wong @ 2025-02-03 22:40 UTC (permalink / raw)
To: djwong, aalbersh; +Cc: hch, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
When we're copying a regular file into the filesystem, we should set the
size of the new file to the size indicated by the stat data, not the
highest offset written, because we now use SEEK_DATA/HOLE to ignore
sparse regions.
Fixes: 73fb78e5ee8940 ("mkfs: support copying in large or sparse files")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
mkfs/proto.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/mkfs/proto.c b/mkfs/proto.c
index 4e9e28d4eea1ca..6dd3a2005b15b3 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -313,7 +313,6 @@ writefile(
struct xfs_mount *mp = ip->i_mount;
struct stat statbuf;
off_t data_pos;
- off_t eof = 0;
int error;
/* do not try to read from non-regular files */
@@ -340,8 +339,6 @@ writefile(
}
writefile_range(ip, fname, fd, data_pos, hole_pos - data_pos);
- eof = hole_pos;
-
data_pos = lseek(fd, hole_pos, SEEK_DATA);
}
if (data_pos < 0 && errno != ENXIO)
@@ -354,7 +351,7 @@ writefile(
fail(_("error creating isize transaction"), error);
libxfs_trans_ijoin(tp, ip, 0);
- ip->i_disk_size = eof;
+ ip->i_disk_size = statbuf.st_size;
libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
error = -libxfs_trans_commit(tp);
if (error)
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/3] xfs_protofile: fix mode formatting error
2025-02-03 22:40 [PATCHSET] xfsprogs: random bug fixes Darrick J. Wong
2025-02-03 22:40 ` [PATCH 1/3] mkfs: fix file size setting when interpreting a protofile Darrick J. Wong
@ 2025-02-03 22:40 ` Darrick J. Wong
2025-02-04 4:53 ` Christoph Hellwig
2025-02-03 22:40 ` [PATCH 3/3] xfs_protofile: fix device number encoding Darrick J. Wong
2 siblings, 1 reply; 7+ messages in thread
From: Darrick J. Wong @ 2025-02-03 22:40 UTC (permalink / raw)
To: djwong, aalbersh; +Cc: hch, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
The protofile parser expects the mode to be specified with three octal
digits. Unfortunately, the generator doesn't get that right if the mode
doesn't have any of bits 8-11 (aka no owner access privileges) set.
Fixes: 6aace700b7b82d ("mkfs: add a utility to generate protofiles")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
mkfs/xfs_protofile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkfs/xfs_protofile.in b/mkfs/xfs_protofile.in
index 9aee4336888523..356d3d80b32521 100644
--- a/mkfs/xfs_protofile.in
+++ b/mkfs/xfs_protofile.in
@@ -45,7 +45,7 @@ def stat_to_str(statbuf):
perms = stat.S_IMODE(statbuf.st_mode)
- return '%s%s%s%o %d %d' % (type, suid, sgid, perms, statbuf.st_uid, \
+ return '%s%s%s%03o %d %d' % (type, suid, sgid, perms, statbuf.st_uid, \
statbuf.st_gid)
def stat_to_extra(statbuf, fullpath):
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/3] xfs_protofile: fix device number encoding
2025-02-03 22:40 [PATCHSET] xfsprogs: random bug fixes Darrick J. Wong
2025-02-03 22:40 ` [PATCH 1/3] mkfs: fix file size setting when interpreting a protofile Darrick J. Wong
2025-02-03 22:40 ` [PATCH 2/3] xfs_protofile: fix mode formatting error Darrick J. Wong
@ 2025-02-03 22:40 ` Darrick J. Wong
2025-02-04 4:56 ` Christoph Hellwig
2 siblings, 1 reply; 7+ messages in thread
From: Darrick J. Wong @ 2025-02-03 22:40 UTC (permalink / raw)
To: djwong, aalbersh; +Cc: hch, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
Actually crack major/minor device numbers from the stat results that we
get when we encounter a character/block device file.
Fixes: 6aace700b7b82d ("mkfs: add a utility to generate protofiles")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
mkfs/xfs_protofile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkfs/xfs_protofile.in b/mkfs/xfs_protofile.in
index 356d3d80b32521..e83c39f5325846 100644
--- a/mkfs/xfs_protofile.in
+++ b/mkfs/xfs_protofile.in
@@ -54,7 +54,7 @@ def stat_to_extra(statbuf, fullpath):
if stat.S_ISREG(statbuf.st_mode):
return ' %s' % fullpath
elif stat.S_ISCHR(statbuf.st_mode) or stat.S_ISBLK(statbuf.st_mode):
- return ' %d %d' % (statbuf.st_rdev, statbuf.st_rdev)
+ return ' %d %d' % (os.major(statbuf.st_rdev), os.minor(statbuf.st_rdev))
elif stat.S_ISLNK(statbuf.st_mode):
return ' %s' % os.readlink(fullpath)
return ''
^ permalink raw reply related [flat|nested] 7+ messages in thread