cluster: RHEL510 - gfs2_convert: mask out proper bits when identifying symlinks

Bob Peterson rpeterso at fedoraproject.org
Fri Apr 5 15:24:19 UTC 2013


Gitweb:        http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=6e4fb7809d4146929c22b8683cb436d38fccdf1d
Commit:        6e4fb7809d4146929c22b8683cb436d38fccdf1d
Parent:        400a5cc46d6295d1d93394186fba5f505f6cb606
Author:        Bob Peterson <rpeterso at redhat.com>
AuthorDate:    Wed Dec 19 07:47:15 2012 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Fri Apr 5 07:02:14 2013 -0700

gfs2_convert: mask out proper bits when identifying symlinks

This patch masks out the proper file type bit in order to
distinguish files from symlinks. Include stat.h defines:
So the check for "di_mode & S_IFLNK" will match regular files,
not just symlinks. The problem was that gfs2_convert was matching
regular files and treating them as symlinks, which destroyed
the di_blocks field in the dinode. The patch also has some minor
cleanups.

rhbz#887374
---
 gfs2/convert/gfs2_convert.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index f22b2d3..1b3f44b 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -828,7 +828,6 @@ static int has_cdpn(const char *str)
 
 static int fix_cdpn_symlink(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct gfs2_inode *ip)
 {
-	int ret = 0;
 	char *linkptr = NULL;
 
 	if (ip->i_di.di_height != 0)
@@ -849,7 +848,7 @@ static int fix_cdpn_symlink(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, s
 				  (osi_list_t *)&cdpns_to_fix);
 	}
 
-	return ret;
+	return 0;
 }
 
 /*
@@ -864,7 +863,7 @@ static int fix_cdpn_symlink(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, s
  */
 static int fix_xattr(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct gfs2_inode *ip)
 {
-	int ret = 0, len, old_hdr_sz, new_hdr_sz;
+	int len, old_hdr_sz, new_hdr_sz;
 	struct gfs2_buffer_head *eabh;
 	char *buf;
 
@@ -887,7 +886,7 @@ static int fix_xattr(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct g
 	}
         brelse(eabh);
 
-	return ret;
+	return 0;
 }
 
 /* ------------------------------------------------------------------------- */
@@ -906,8 +905,8 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
 	inode_was_gfs1 = (inode->i_di.di_num.no_formal_ino ==
 					  inode->i_di.di_num.no_addr);
 	/* Fix the inode number: */
-	inode->i_di.di_num.no_formal_ino = sbp->md.next_inum;           ;
-	
+	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 */
@@ -973,7 +972,7 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
 		if (adjust_indirect_blocks(sbp, inode))
 			return -1;
 		/* Check for cdpns */
-		if (inode->i_di.di_mode & S_IFLNK) {
+		if (S_ISLNK(inode->i_di.di_mode)) {
 			ret = fix_cdpn_symlink(sbp, bh, inode);
 			if (ret)
 				return -1;


More information about the cluster-commits mailing list