+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2005-2006 Silicon Graphics, Inc.
* All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <xfs/xfs.h>
-#include <xfs/command.h>
-#include <xfs/input.h>
-#include <xfs/path.h>
-#include <xfs/parent.h>
-#include <xfs/handle.h>
-#include <xfs/jdm.h>
+#include "command.h"
+#include "input.h"
+#include "path.h"
+#include "parent.h"
+#include "handle.h"
+#include "jdm.h"
#include "init.h"
#include "io.h"
if (sts != 0) {
fprintf(stderr,
_("inode-path for inode: %llu is incorrect - path \"%s\" non-existent\n"),
- bstatp->bs_ino, fullpath);
+ (unsigned long long) bstatp->bs_ino, fullpath);
if (verbose_flag) {
fprintf(stderr,
_("path \"%s\" does not stat for inode: %llu; err = %s\n"),
fullpath,
- bstatp->bs_ino,
+ (unsigned long long) bstatp->bs_ino,
strerror(errno));
}
err_status++;
if (statbuf.st_ino != bstatp->bs_ino) {
fprintf(stderr,
_("inode-path for inode: %llu is incorrect - wrong inode#\n"),
- bstatp->bs_ino);
+ (unsigned long long) bstatp->bs_ino);
if (verbose_flag) {
fprintf(stderr,
_("ino mismatch for path \"%s\" %llu vs %llu\n"),
if (parent->p_ino != statbuf.st_ino) {
fprintf(stderr,
_("inode-path for inode: %llu is incorrect - wrong parent inode#\n"),
- bstatp->bs_ino);
+ (unsigned long long) bstatp->bs_ino);
if (verbose_flag) {
fprintf(stderr,
_("ino mismatch for path \"%s\" %llu vs %llu\n"),
return;
} else {
if (verbose_flag > 1) {
- printf(_("parent ino match for %llu\n"), parent->p_ino);
+ printf(_("parent ino match for %llu\n"),
+ (unsigned long long) parent->p_ino);
}
}
}
parentbuf = (parent_t *)realloc(parentbuf, *parentbuf_size);
} else if (error) {
fprintf(stderr, _("parentpaths failed for ino %llu: %s\n"),
- statp->bs_ino,
+ (unsigned long long) statp->bs_ino,
strerror(errno));
err_status++;
break;
}
} while (error == ERANGE);
-
+
if (count == 0) {
/* no links for inode - something wrong here */
- fprintf(stderr, _("inode-path for inode: %llu is missing\n"), statp->bs_ino);
+ fprintf(stderr, _("inode-path for inode: %llu is missing\n"),
+ (unsigned long long) statp->bs_ino);
err_status++;
}
if (xfsctl(mntpt, fsfd, XFS_IOC_FSBULKSTAT_SINGLE, &bulkreq) < 0) {
fprintf(stderr,
_("failed to get bulkstat information for inode %llu\n"),
- p->bs_ino );
+ (unsigned long long) p->bs_ino);
continue;
}
if (!p->bs_nlink || !p->bs_mode || !p->bs_ino) {
fprintf(stderr,
_("failed to get valid bulkstat information for inode %llu\n"),
- p->bs_ino );
+ (unsigned long long) p->bs_ino);
continue;
}
}
}
if (verbose_flag > 1) {
- printf(_("checking inode %llu\n"), p->bs_ino);
+ printf(_("checking inode %llu\n"),
+ (unsigned long long) p->bs_ino);
}
/* print dotted progress */
if (!bstatbuf || !parentbuf) {
fprintf(stderr, _("unable to allocate buffers: %s\n"),
strerror(errno));
- return 1;
+ err_status = 1;
+ goto out;
}
if (do_bulkstat(parentbuf, &parentbuf_size, bstatbuf, fsfd, fshandlep) != 0)
if (err_status > 0)
fprintf(stderr, _("num errors: %d\n"), err_status);
else
- printf(_("succeeded checking %llu inodes\n"), inodes_checked);
+ printf(_("succeeded checking %llu inodes\n"),
+ (unsigned long long) inodes_checked);
+out:
free(bstatbuf);
free(parentbuf);
+ free(fshandlep);
return err_status;
}
static void
print_parent_entry(parent_t *parent, int fullpath)
{
- printf(_("p_ino = %llu\n"), parent->p_ino);
+ printf(_("p_ino = %llu\n"), (unsigned long long) parent->p_ino);
printf(_("p_gen = %u\n"), parent->p_gen);
printf(_("p_reclen = %u\n"), parent->p_reclen);
if (fullpath)
static int
parent_list(int fullpath)
{
- void *handlep;
+ void *handlep = NULL;
size_t handlen;
int error, i;
int retval = 1;
progname, path, strerror(errno));
goto error;
}
+ free_handle(fshandle, fshlen);
}
if (path_to_handle(path, &handlep, &handlen) != 0) {
if (!parentbuf) {
fprintf(stderr, _("%s: unable to allocate parent buffer: %s\n"),
progname, strerror(errno));
- return 1;
+ goto error;
}
if (fullpath) {
retval = 0;
error:
+ free(handlep);
free(parentbuf);
return retval;
}
if (!tab_init) {
tab_init = 1;
- fs_table_initialise();
+ fs_table_initialise(0, NULL, 0, NULL);
}
fs = fs_table_lookup(file->name, FS_MOUNT_POINT);
if (!fs) {