diff mbox series

[3/3] xfs_protofile: fix device number encoding

Message ID 173862239078.2460098.2761986507883680426.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [1/3] mkfs: fix file size setting when interpreting a protofile | expand

Commit Message

Darrick J. Wong Feb. 3, 2025, 10:40 p.m. UTC
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(-)

Comments

Christoph Hellwig Feb. 4, 2025, 4:56 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

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 ''