xfs
[Top] [All Lists]

[PATCH 2/2] mkfs: proto file creation does not set ftype correctly

To: xfs@xxxxxxxxxxx
Subject: [PATCH 2/2] mkfs: proto file creation does not set ftype correctly
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 27 Feb 2014 20:45:44 +1100
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1393494344-30056-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1393494344-30056-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

Hence running xfs_repair on a ftype enable filesystem that has
contents created by a proto file will throw warnings on mismatched
ftype entries and correct them. xfs/031 fails due to this problem.

Fix it by settin gup the xname structure with the correct type
fields.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 mkfs/proto.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/mkfs/proto.c b/mkfs/proto.c
index 4cc0df6..4d3680d 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -438,6 +438,7 @@ parseproto(
        creds.cr_gid = (int)getnum(pp);
        xname.name = (uchar_t *)name;
        xname.len = name ? strlen(name) : 0;
+       xname.type = 0;
        tp = libxfs_trans_alloc(mp, 0);
        flags = XFS_ILOG_CORE;
        xfs_bmap_init(&flist, &first);
@@ -453,6 +454,7 @@ parseproto(
                if (buf)
                        free(buf);
                libxfs_trans_ijoin(tp, pip, 0);
+               xname.type = XFS_DIR3_FT_REG_FILE;
                newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &flist);
                libxfs_trans_ihold(tp, pip);
                break;
@@ -469,6 +471,7 @@ parseproto(
 
                libxfs_trans_ijoin(tp, pip, 0);
 
+               xname.type = XFS_DIR3_FT_REG_FILE;
                newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &flist);
                libxfs_trans_ihold(tp, pip);
                libxfs_trans_log_inode(tp, ip, flags);
@@ -490,6 +493,7 @@ parseproto(
                        fail(_("Inode allocation failed"), error);
                }
                libxfs_trans_ijoin(tp, pip, 0);
+               xname.type = XFS_DIR3_FT_BLKDEV;
                newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &flist);
                libxfs_trans_ihold(tp, pip);
                flags |= XFS_ILOG_DEV;
@@ -504,6 +508,7 @@ parseproto(
                if (error)
                        fail(_("Inode allocation failed"), error);
                libxfs_trans_ijoin(tp, pip, 0);
+               xname.type = XFS_DIR3_FT_CHRDEV;
                newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &flist);
                libxfs_trans_ihold(tp, pip);
                flags |= XFS_ILOG_DEV;
@@ -516,6 +521,7 @@ parseproto(
                if (error)
                        fail(_("Inode allocation failed"), error);
                libxfs_trans_ijoin(tp, pip, 0);
+               xname.type = XFS_DIR3_FT_FIFO;
                newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &flist);
                libxfs_trans_ihold(tp, pip);
                break;
@@ -529,6 +535,7 @@ parseproto(
                        fail(_("Inode allocation failed"), error);
                flags |= newfile(tp, ip, &flist, &first, 1, 1, buf, len);
                libxfs_trans_ijoin(tp, pip, 0);
+               xname.type = XFS_DIR3_FT_SYMLINK;
                newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &flist);
                libxfs_trans_ihold(tp, pip);
                break;
@@ -546,6 +553,7 @@ parseproto(
                        isroot = 1;
                } else {
                        libxfs_trans_ijoin(tp, pip, 0);
+                       xname.type = XFS_DIR3_FT_DIR;
                        newdirent(mp, tp, pip, &xname, ip->i_ino,
                                  &first, &flist);
                        pip->i_d.di_nlink++;
-- 
1.8.4.rc3

<Prev in Thread] Current Thread [Next in Thread>