gfs2-utils: master - gfs2_convert: mask out proper bits when identifying symlinks
Bob Peterson
rpeterso at fedoraproject.org
Fri Dec 21 16:39:58 UTC 2012
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=506995267a25075634a1427ec5960b5b98f7556a
Commit: 506995267a25075634a1427ec5960b5b98f7556a
Parent: caeb3efcb35b19c2a251cece2e59e13774baa108
Author: Bob Peterson <rpeterso at redhat.com>
AuthorDate: Wed Dec 19 07:47:15 2012 -0600
Committer: Bob Peterson <rpeterso at redhat.com>
CommitterDate: Thu Dec 20 14:31:17 2012 -0600
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 aa1d5aa..72c974f 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -830,7 +830,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)
@@ -851,7 +850,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;
}
/*
@@ -866,7 +865,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;
@@ -890,7 +889,7 @@ static int fix_xattr(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct g
}
brelse(eabh);
- return ret;
+ return 0;
}
/* ------------------------------------------------------------------------- */
@@ -913,8 +912,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 */
@@ -981,7 +980,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