return -1;
}
- ret = xfd_open(&fsxfd, mntdir, O_RDONLY);
+ ret = -xfd_open(&fsxfd, mntdir, O_RDONLY);
if (ret) {
fsrprintf(_("unable to open XFS file: %s: %s\n"),
mntdir, strerror(ret));
* Need to open something on the same filesystem as the
* file. Open the parent.
*/
- error = xfd_open(&fsxfd, getparent(fname), O_RDONLY);
+ error = -xfd_open(&fsxfd, getparent(fname), O_RDONLY);
if (error) {
fsrprintf(_("unable to open sys handle for XFS file %s: %s\n"),
fname, strerror(error));
}
/* get the current filesystem size & geometry */
- ret = xfrog_geometry(ffd, &geo);
+ ret = -xfrog_geometry(ffd, &geo);
if (ret) {
fprintf(stderr,
_("%s: cannot determine geometry of filesystem mounted at %s: %s\n"),
}
}
- ret = xfrog_geometry(ffd, &ngeo);
+ ret = -xfrog_geometry(ffd, &ngeo);
if (ret) {
fprintf(stderr, _("%s: XFS_IOC_FSGEOMETRY xfsctl failed: %s\n"),
progname, strerror(ret));
bmv_iflags &= ~(BMV_IF_PREALLOC|BMV_IF_NO_DMAPI_READ);
if (vflag) {
- c = xfrog_geometry(file->fd, &fsgeo);
+ c = -xfrog_geometry(file->fd, &fsgeo);
if (c) {
fprintf(stderr,
_("%s: can't get geometry [\"%s\"]: %s\n"),
return 0;
}
- ret = xfd_prepare_geometry(&xfd);
+ ret = -xfd_prepare_geometry(&xfd);
if (ret) {
xfrog_perror(ret, "xfd_prepare_geometry");
exitcode = 1;
}
}
- ret = xfd_prepare_geometry(&xfd);
+ ret = -xfd_prepare_geometry(&xfd);
if (ret) {
xfrog_perror(ret, "xfd_prepare_geometry");
exitcode = 1;
return 0;
}
- ret = xfd_prepare_geometry(&xfd);
+ ret = -xfd_prepare_geometry(&xfd);
if (ret) {
xfrog_perror(ret, "xfd_prepare_geometry");
exitcode = 1;
}
if (vflag) {
- c = xfrog_geometry(file->fd, &fsgeo);
+ c = -xfrog_geometry(file->fd, &fsgeo);
if (c) {
fprintf(stderr,
_("%s: can't get geometry [\"%s\"]: %s\n"),
- progname, file->name, strerror(errno));
+ progname, file->name, strerror(c));
exitcode = 1;
return 0;
}
} else {
int ret;
- ret = xfrog_geometry(fd, geom);
+ ret = -xfrog_geometry(fd, geom);
if (ret) {
xfrog_perror(ret, "XFS_IOC_FSGEOMETRY");
close(fd);
}
if (file->flags & IO_FOREIGN)
return 0;
- ret = xfrog_geometry(file->fd, &fsgeo);
+ ret = -xfrog_geometry(file->fd, &fsgeo);
if (ret) {
xfrog_perror(ret, "XFS_IOC_FSGEOMETRY");
} else {
if (xfd->fsgeom.blocksize > 0)
return 0;
- return xfd_prepare_geometry(xfd);
+ return -xfd_prepare_geometry(xfd);
}
/* Bulkstat a single inode using v5 ioctl. */
(unsigned long long)geo->rtextents);
}
-/* Try to obtain the xfs geometry. On error returns a positive error code. */
+/* Try to obtain the xfs geometry. On error returns a negative error code. */
int
xfrog_geometry(
int fd,
if (!ret)
return 0;
- return errno;
+ return -errno;
}
/*
* Prepare xfs_fd structure for future ioctl operations by computing the xfs
- * geometry for @xfd->fd. Returns zero or a positive error code.
+ * geometry for @xfd->fd. Returns zero or a negative error code.
*/
int
xfd_prepare_geometry(
return 0;
}
-/* Open a file on an XFS filesystem. Returns zero or a positive error code. */
+/* Open a file on an XFS filesystem. Returns zero or a negative error code. */
int
xfd_open(
struct xfs_fd *xfd,
xfd->fd = open(pathname, flags);
if (xfd->fd < 0)
- return errno;
+ return -errno;
ret = xfd_prepare_geometry(xfd);
if (ret) {
/*
* Release any resources associated with this xfs_fd structure. Returns zero
- * or a positive error code.
+ * or a negative error code.
*/
int
xfd_close(
ret = close(xfd->fd);
xfd->fd = -1;
if (ret < 0)
- return errno;
+ return -errno;
return 0;
}
-/* Try to obtain an AG's geometry. Returns zero or a positive error code. */
+/* Try to obtain an AG's geometry. Returns zero or a negative error code. */
int
xfrog_ag_geometry(
int fd,
ageo->ag_number = agno;
ret = ioctl(fd, XFS_IOC_AG_GEOMETRY, ageo);
if (ret)
- return errno;
+ return -errno;
return 0;
}
}
if (!(mount->fs_flags & FS_FOREIGN)) {
- ret = xfrog_geometry(fd, &fsgeo);
+ ret = -xfrog_geometry(fd, &fsgeo);
if (ret) {
xfrog_perror(ret, "XFS_IOC_FSGEOMETRY");
close(fd);
*dp = NULL;
ndu[0] = ndu[1] = ndu[2] = 0;
- ret = xfd_open(&fsxfd, fsdir, O_RDONLY);
+ ret = -xfd_open(&fsxfd, fsdir, O_RDONLY);
if (ret) {
xfrog_perror(ret, fsdir);
return;
fd = libxfs_device_to_fd(x.ddev);
- ret = xfrog_geometry(fd, &geom);
+ ret = -xfrog_geometry(fd, &geom);
if (ret) {
do_log(_("Cannot get host filesystem geometry.\n"
"Repair may fail if there is a sector size mismatch between\n"
progname, path, strerror(errno));
return -1;
}
- rval = xfrog_geometry(fd, &geo);
+ rval = -xfrog_geometry(fd, &geo);
close(fd);
if (rval)
return -1;
if (ctx->datadev)
disk_close(ctx->datadev);
fshandle_destroy();
- error = xfd_close(&ctx->mnt);
+ error = -xfd_close(&ctx->mnt);
if (error)
str_liberror(ctx, error, _("closing mountpoint fd"));
fs_table_destroy();
* CAP_SYS_ADMIN, which we probably need to do anything fancy
* with the (XFS driver) kernel.
*/
- error = xfd_open(&ctx->mnt, ctx->mntpoint,
+ error = -xfd_open(&ctx->mnt, ctx->mntpoint,
O_RDONLY | O_NOATIME | O_DIRECTORY);
if (error) {
if (error == EPERM)
struct fs_path *fsp;
int ret;
- ret = xfd_open(xfd, path, O_RDONLY);
+ ret = -xfd_open(xfd, path, O_RDONLY);
if (ret) {
if (ret == ENOTTY)
fprintf(stderr,
char descr[256];
int ret;
- ret = xfrog_ag_geometry(file->xfd.fd, agno, &ageo);
+ ret = -xfrog_ag_geometry(file->xfd.fd, agno, &ageo);
if (ret) {
xfrog_perror(ret, "ag_geometry");
return 1;