Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=7c1eff97fde...
Commit: 7c1eff97fde6b899904a97e366380a470c3f50a3
Parent: 07b91f6a29c3340f42c1d3bd5d759c55f17298f2
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Wed Dec 19 07:47:15 2012 -0600
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Jun 3 12:51:58 2013 -0500
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 206adfb..7ba30e9 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -826,7 +826,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)
@@ -847,7 +846,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;
}
/*
@@ -862,7 +861,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;
@@ -885,7 +884,7 @@ static int fix_xattr(struct gfs2_sbd *sbp, struct gfs2_buffer_head
*bh, struct g
}
brelse(eabh);
- return ret;
+ return 0;
}
/* ------------------------------------------------------------------------- */
@@ -904,8 +903,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 */
@@ -971,7 +970,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;