gfs2-utils: master - gfs2_convert: clear out old di_mode before setting it

Bob Peterson rpeterso at fedoraproject.org
Fri Dec 21 16:39:56 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=caeb3efcb35b19c2a251cece2e59e13774baa108
Commit:        caeb3efcb35b19c2a251cece2e59e13774baa108
Parent:        fd9ccf25cadd901079a6a801b098c606223375d2
Author:        Bob Peterson <rpeterso at redhat.com>
AuthorDate:    Tue Dec 18 14:14:08 2012 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Thu Dec 20 14:31:11 2012 -0600

gfs2_convert: clear out old di_mode before setting it

This patch clears the dinode 'di_mode' inode type field before
setting it based on the GFS1 value. In rare circumstances
(e.g. fsck.gfs2 ran on a GFS1 file system and created lost+found
with both GFS1 and GFS2 data) di_mode might have an old value.
In these cases, simply doing a logical 'or' with the correct
value produces an invalid value. Zeroing it out beforehand ensures
it is set correctly based on the GFS1 type.

rhbz#888053
---
 gfs2/convert/gfs2_convert.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index a38bbff..aa1d5aa 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -916,6 +916,7 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
 	inode->i_di.di_num.no_formal_ino = sbp->md.next_inum;           ;
 	
 	/* Fix the inode type: gfs1 uses di_type, gfs2 uses di_mode. */
+	inode->i_di.di_mode &= ~S_IFMT;
 	switch (inode->i_di.__pad1) { /* formerly di_type */
 	case GFS_FILE_DIR:           /* directory        */
 		inode->i_di.di_mode |= S_IFDIR;


More information about the cluster-commits mailing list