#define rounddown(x, y) (((x)/(y))*(y))
#define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0)
-extern int platform_check_ismounted(char *, char *, struct stat64 *, int);
+extern int platform_check_ismounted(char *, char *, struct stat *, int);
int logfd;
char *logfile_name;
xfs_agblock_t first_agbno;
-__uint64_t barcount[11];
+uint64_t barcount[11];
unsigned int num_targets;
target_control *target;
if (target[i].err_type == 0)
do_log(_("write error"));
else
- do_log(_("lseek64 error"));
+ do_log(_("lseek error"));
do_log(_(" at offset %lld\n"), target[i].position);
}
}
buf = &w_buf;
if (target[args->id].position != buf->position) {
- if (lseek64(args->fd, buf->position, SEEK_SET) < 0) {
+ if (lseek(args->fd, buf->position, SEEK_SET) < 0) {
error = target[args->id].err_type = 1;
} else {
target[args->id].position = buf->position;
target[i].position);
} else {
do_warn(
- _("%s: lseek64 error on target %d \"%s\" at offset %lld\n"),
+ _("%s: lseek error on target %d \"%s\" at offset %lld\n"),
progname, i, target[i].name,
target[i].position);
}
}
void
-init_bar(__uint64_t source_blocks)
+init_bar(uint64_t source_blocks)
{
int i;
}
int
-bump_bar(int tenths, __uint64_t numblocks)
+bump_bar(int tenths, uint64_t numblocks)
{
static char *bar[11] = {
" 0% ",
}
if (source_position != buf->position) {
- lres = lseek64(fd, buf->position, SEEK_SET);
+ lres = lseek(fd, buf->position, SEEK_SET);
if (lres < 0LL) {
- do_warn(_("%s: lseek64 failure at offset %lld\n"),
+ do_warn(_("%s: lseek failure at offset %lld\n"),
progname, source_position);
die_perror();
}
write_wbuf(void)
{
int i;
+ int badness = 0;
/* verify target threads */
for (i = 0; i < num_targets; i++)
for (i = 0; i < num_targets; i++)
if (target[i].state != INACTIVE)
pthread_mutex_unlock(&targ[i].wait); /* wake up */
+ else
+ badness++;
+
+ /*
+ * If all the targets are inactive then there won't be any io
+ * threads left to release mainwait. We're screwed, so bail out.
+ */
+ if (badness == num_targets) {
+ check_errors();
+ exit(1);
+ }
signal_maskfunc(SIGCHLD, SIG_UNBLOCK);
pthread_mutex_lock(&mainwait);
xfs_off_t pos;
size_t length;
int c;
- __uint64_t size, sizeb;
- __uint64_t numblocks = 0;
+ uint64_t size, sizeb;
+ uint64_t numblocks = 0;
int wblocks = 0;
int num_threads = 0;
struct dioattr d;
extern int optind;
libxfs_init_t xargs;
thread_args *tcarg;
- struct stat64 statbuf;
+ struct stat statbuf;
progname = basename(argv[0]);
die_perror();
}
- if (fstat64(source_fd, &statbuf) < 0) {
+ if (fstat(source_fd, &statbuf) < 0) {
do_log(_("%s: couldn't stat source \"%s\"\n"),
progname, source_name);
die_perror();
for (i = 0; i < num_targets; i++) {
int write_last_block = 0;
- if (stat64(target[i].name, &statbuf) < 0) {
+ if (stat(target[i].name, &statbuf) < 0) {
/* ok, assume it's a file and create it */
do_out(_("Creating file %s\n"), target[i].name);
if (write_last_block) {
/* ensure regular files are correctly sized */
- if (ftruncate64(target[i].fd, mp->m_sb.sb_dblocks *
+ if (ftruncate(target[i].fd, mp->m_sb.sb_dblocks *
source_blocksize)) {
do_log(_("%s: cannot grow data section.\n"),
progname);
off = mp->m_sb.sb_dblocks * source_blocksize;
off -= sizeof(lb);
- if (pwrite64(target[i].fd, lb, sizeof(lb), off) < 0) {
+ if (pwrite(target[i].fd, lb, sizeof(lb), off) < 0) {
do_log(_("%s: failed to write last block\n"),
progname);
do_log(_("\tIs target \"%s\" too small?\n"),
num_ags = mp->m_sb.sb_agcount;
init_bar(mp->m_sb.sb_blocksize / BBSIZE
- * ((__uint64_t)mp->m_sb.sb_dblocks
- - (__uint64_t)mp->m_sb.sb_fdblocks + 10 * num_ags));
+ * ((uint64_t)mp->m_sb.sb_dblocks
+ - (uint64_t)mp->m_sb.sb_fdblocks + 10 * num_ags));
kids = num_targets;
((char *) btree_buf.data +
pos - btree_buf.position);
- ASSERT(be32_to_cpu(block->bb_magic) == XFS_ABTB_MAGIC);
+ ASSERT(be32_to_cpu(block->bb_magic) == XFS_ABTB_MAGIC ||
+ be32_to_cpu(block->bb_magic) == XFS_ABTB_CRC_MAGIC);
}
/*
check_errors();
libxfs_umount(mp);
+ libxfs_destroy();
return 0;
}