{
struct bbmap map;
char *link;
- int ret = 0;
+ int rval = 1;
push_cur();
map.nmaps = 1;
print_warning("cannot read %s block %u/%u (%llu)",
typtab[btype].name, agno, agbno, s);
- if (stop_on_read_error)
- ret = -1;
+ rval = !stop_on_read_error;
goto out_pop;
}
link = iocur_top->data;
}
iocur_top->need_crc = 1;
- ret = write_buf(iocur_top);
+ if (write_buf(iocur_top))
+ rval = 0;
out_pop:
pop_cur();
- return ret;
+ return rval;
}
#define MAX_REMOTE_VALS 4095
typnm_t btype,
xfs_fileoff_t last)
{
+ int rval = 1;
char *dp;
- int ret = 0;
int i;
for (i = 0; i < c; i++) {
print_warning("cannot read %s block %u/%u (%llu)",
typtab[btype].name, agno, agbno, s);
- if (stop_on_read_error)
- ret = -EIO;
+ rval = !stop_on_read_error;
goto out_pop;
}
}
write:
- ret = write_buf(iocur_top);
+ if (write_buf(iocur_top))
+ rval = 0;
out_pop:
pop_cur();
- if (ret)
+ if (!rval)
break;
o++;
s++;
}
- return ret;
+ return rval;
}
/*
xfs_fileoff_t last)
{
char *dp;
- int ret = 0;
+ int rval = 1;
while (c > 0) {
unsigned int bm_len;
print_warning("cannot read %s block %u/%u (%llu)",
typtab[btype].name, agno, agbno, s);
- if (stop_on_read_error)
- ret = -1;
+ rval = !stop_on_read_error;
goto out_pop;
}
}
iocur_top->need_crc = 1;
write:
- ret = write_buf(iocur_top);
+ if (write_buf(iocur_top))
+ rval = 0;
out_pop:
pop_cur();
mfsb_map.nmaps = 0;
- if (ret)
+ if (!rval)
break;
}
c -= bm_len;
s += bm_len;
}
- return ret;
+ return rval;
}
static bool
return process_symlink_block(o, s, c, btype, last);
default:
print_warning("bad type for multi-fsb object %d", btype);
- return -EINVAL;
+ return 1;
}
}
/* inode copy routines */
static int
process_bmbt_reclist(
- xfs_bmbt_rec_t *rp,
- int numrecs,
+ xfs_bmbt_rec_t *rp,
+ int numrecs,
typnm_t btype)
{
int i;
xfs_agnumber_t agno;
xfs_agblock_t agbno;
bool is_multi_fsb = is_multi_fsb_object(mp, btype);
- int error;
+ int rval = 1;
if (btype == TYP_DATA)
return 1;
/* multi-extent blocks require special handling */
if (is_multi_fsb)
- error = process_multi_fsb_objects(o, s, c, btype,
+ rval = process_multi_fsb_objects(o, s, c, btype,
last);
else
- error = process_single_fsb_objects(o, s, c, btype,
+ rval = process_single_fsb_objects(o, s, c, btype,
last);
- if (error)
- return 0;
+ if (!rval)
+ break;
}
- return 1;
+ return rval;
}
static int
return 1;
}
-static int
+static void
process_dev_inode(
struct xfs_dinode *dip)
{
if (show_warnings)
print_warning("inode %llu has unexpected extents",
(unsigned long long)cur_ino);
- return 0;
- } else {
- if (zero_stale_data) {
- unsigned int size = sizeof(xfs_dev_t);
+ return;
+ }
+ if (zero_stale_data) {
+ unsigned int size = sizeof(xfs_dev_t);
- memset(XFS_DFORK_DPTR(dip) + size, 0,
- XFS_DFORK_DSIZE(dip, mp) - size);
- }
- return 1;
+ memset(XFS_DFORK_DPTR(dip) + size, 0,
+ XFS_DFORK_DSIZE(dip, mp) - size);
}
}
struct xfs_dinode *dip,
bool free_inode)
{
- int success;
+ int rval = 1;
bool crc_was_ok = false; /* no recalc by default */
bool need_new_crc = false;
- success = 1;
cur_ino = XFS_AGINO_TO_INO(mp, agno, agino);
/* we only care about crc recalculation if we will modify the inode. */
/* copy appropriate data fork metadata */
switch (be16_to_cpu(dip->di_mode) & S_IFMT) {
case S_IFDIR:
- success = process_inode_data(dip, TYP_DIR2);
+ rval = process_inode_data(dip, TYP_DIR2);
if (dip->di_format == XFS_DINODE_FMT_LOCAL)
need_new_crc = 1;
break;
case S_IFLNK:
- success = process_inode_data(dip, TYP_SYMLINK);
+ rval = process_inode_data(dip, TYP_SYMLINK);
if (dip->di_format == XFS_DINODE_FMT_LOCAL)
need_new_crc = 1;
break;
case S_IFREG:
- success = process_inode_data(dip, TYP_DATA);
+ rval = process_inode_data(dip, TYP_DATA);
break;
case S_IFIFO:
case S_IFCHR:
case S_IFBLK:
case S_IFSOCK:
- success = process_dev_inode(dip);
+ process_dev_inode(dip);
need_new_crc = 1;
break;
default:
break;
}
nametable_clear();
+ if (!rval)
+ goto done;
/* copy extended attributes if they exist and forkoff is valid */
- if (success && XFS_DFORK_DSIZE(dip, mp) < XFS_LITINO(mp)) {
+ if (XFS_DFORK_DSIZE(dip, mp) < XFS_LITINO(mp)) {
attr_data.remote_val_count = 0;
switch (dip->di_aformat) {
case XFS_DINODE_FMT_LOCAL:
break;
case XFS_DINODE_FMT_EXTENTS:
- success = process_exinode(dip, TYP_ATTR);
+ rval = process_exinode(dip, TYP_ATTR);
break;
case XFS_DINODE_FMT_BTREE:
- success = process_btinode(dip, TYP_ATTR);
+ rval = process_btinode(dip, TYP_ATTR);
break;
}
nametable_clear();
if (crc_was_ok && need_new_crc)
libxfs_dinode_calc_crc(mp, dip);
- return success;
+
+ return rval;
}
static uint32_t inodes_copied;
/* process_inode handles free inodes, too */
if (!process_inode(agno, agino + ioff + i, dip,
- XFS_INOBT_IS_FREE_DISK(rp, ioff + i)))
+ XFS_INOBT_IS_FREE_DISK(rp, ioff + i)))
goto pop_out;
inodes_copied++;
xfs_agblock_t agbno;
xfs_agino_t agino;
int offset;
- int rval = 0;
+ int rval = 1;
if (ino == 0 || ino == NULLFSINO)
return 1;