From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Convert libfrog functions to return negative error codes like libxfs does. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --- fsr/xfs_fsr.c | 4 ++-- growfs/xfs_growfs.c | 4 ++-- io/bmap.c | 2 +- io/bulkstat.c | 6 +++--- io/fsmap.c | 4 ++-- io/open.c | 2 +- io/stat.c | 2 +- libfrog/bulkstat.c | 2 +- libfrog/fsgeom.c | 18 +++++++++--------- quota/free.c | 2 +- quota/quot.c | 2 +- repair/xfs_repair.c | 2 +- rtcp/xfs_rtcp.c | 2 +- scrub/phase1.c | 4 ++-- spaceman/file.c | 2 +- spaceman/health.c | 2 +- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index af5d6169..3e9ba27c 100644 --- a/fsr/xfs_fsr.c +++ b/fsr/xfs_fsr.c @@ -602,7 +602,7 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange) 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)); @@ -748,7 +748,7 @@ fsrfile( * 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)); diff --git a/growfs/xfs_growfs.c b/growfs/xfs_growfs.c index eab15984..d1908046 100644 --- a/growfs/xfs_growfs.c +++ b/growfs/xfs_growfs.c @@ -166,7 +166,7 @@ main(int argc, char **argv) } /* 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"), @@ -352,7 +352,7 @@ main(int argc, char **argv) } } - 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)); diff --git a/io/bmap.c b/io/bmap.c index cf4ea12b..f838840e 100644 --- a/io/bmap.c +++ b/io/bmap.c @@ -106,7 +106,7 @@ bmap_f( 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"), diff --git a/io/bulkstat.c b/io/bulkstat.c index 0ea21584..e5ee4296 100644 --- a/io/bulkstat.c +++ b/io/bulkstat.c @@ -164,7 +164,7 @@ bulkstat_f( return 0; } - ret = xfd_prepare_geometry(&xfd); + ret = -xfd_prepare_geometry(&xfd); if (ret) { xfrog_perror(ret, "xfd_prepare_geometry"); exitcode = 1; @@ -266,7 +266,7 @@ bulkstat_single_f( } } - ret = xfd_prepare_geometry(&xfd); + ret = -xfd_prepare_geometry(&xfd); if (ret) { xfrog_perror(ret, "xfd_prepare_geometry"); exitcode = 1; @@ -422,7 +422,7 @@ inumbers_f( return 0; } - ret = xfd_prepare_geometry(&xfd); + ret = -xfd_prepare_geometry(&xfd); if (ret) { xfrog_perror(ret, "xfd_prepare_geometry"); exitcode = 1; diff --git a/io/fsmap.c b/io/fsmap.c index 12ec1e44..feacb264 100644 --- a/io/fsmap.c +++ b/io/fsmap.c @@ -448,11 +448,11 @@ fsmap_f( } 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; } diff --git a/io/open.c b/io/open.c index c07ecb04..3bbc5d0a 100644 --- a/io/open.c +++ b/io/open.c @@ -124,7 +124,7 @@ openfile( } else { int ret; - ret = xfrog_geometry(fd, geom); + ret = -xfrog_geometry(fd, geom); if (ret) { xfrog_perror(ret, "XFS_IOC_FSGEOMETRY"); close(fd); diff --git a/io/stat.c b/io/stat.c index db335780..d125a0f7 100644 --- a/io/stat.c +++ b/io/stat.c @@ -197,7 +197,7 @@ statfs_f( } 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 { diff --git a/libfrog/bulkstat.c b/libfrog/bulkstat.c index 538b5197..38d634f7 100644 --- a/libfrog/bulkstat.c +++ b/libfrog/bulkstat.c @@ -39,7 +39,7 @@ xfrog_bulkstat_prep_v1_emulation( if (xfd->fsgeom.blocksize > 0) return 0; - return xfd_prepare_geometry(xfd); + return -xfd_prepare_geometry(xfd); } /* Bulkstat a single inode using v5 ioctl. */ diff --git a/libfrog/fsgeom.c b/libfrog/fsgeom.c index 3ea91e3f..19a4911f 100644 --- a/libfrog/fsgeom.c +++ b/libfrog/fsgeom.c @@ -69,7 +69,7 @@ xfs_report_geom( (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, @@ -91,12 +91,12 @@ xfrog_geometry( 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( @@ -117,7 +117,7 @@ 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, @@ -128,7 +128,7 @@ xfd_open( xfd->fd = open(pathname, flags); if (xfd->fd < 0) - return errno; + return -errno; ret = xfd_prepare_geometry(xfd); if (ret) { @@ -141,7 +141,7 @@ xfd_open( /* * Release any resources associated with this xfs_fd structure. Returns zero - * or a positive error code. + * or a negative error code. */ int xfd_close( @@ -155,12 +155,12 @@ 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, @@ -172,6 +172,6 @@ xfrog_ag_geometry( ageo->ag_number = agno; ret = ioctl(fd, XFS_IOC_AG_GEOMETRY, ageo); if (ret) - return errno; + return -errno; return 0; } diff --git a/quota/free.c b/quota/free.c index 45ce2ceb..ea9c112f 100644 --- a/quota/free.c +++ b/quota/free.c @@ -69,7 +69,7 @@ mount_free_space_data( } 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); diff --git a/quota/quot.c b/quota/quot.c index 0f69fabd..df3825f2 100644 --- a/quota/quot.c +++ b/quota/quot.c @@ -146,7 +146,7 @@ quot_bulkstat_mount( *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; diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 7e810ef4..61ea3b11 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -641,7 +641,7 @@ check_fs_vs_host_sectsize( 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" diff --git a/rtcp/xfs_rtcp.c b/rtcp/xfs_rtcp.c index a5737699..7c4197b1 100644 --- a/rtcp/xfs_rtcp.c +++ b/rtcp/xfs_rtcp.c @@ -378,7 +378,7 @@ xfsrtextsize( char *path) progname, path, strerror(errno)); return -1; } - rval = xfrog_geometry(fd, &geo); + rval = -xfrog_geometry(fd, &geo); close(fd); if (rval) return -1; diff --git a/scrub/phase1.c b/scrub/phase1.c index 0d343b03..eabcaecf 100644 --- a/scrub/phase1.c +++ b/scrub/phase1.c @@ -60,7 +60,7 @@ scrub_cleanup( 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(); @@ -84,7 +84,7 @@ phase1_func( * 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) diff --git a/spaceman/file.c b/spaceman/file.c index b7794328..eec7ee9f 100644 --- a/spaceman/file.c +++ b/spaceman/file.c @@ -52,7 +52,7 @@ openfile( 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, diff --git a/spaceman/health.c b/spaceman/health.c index c3b89e8f..a10d2d4a 100644 --- a/spaceman/health.c +++ b/spaceman/health.c @@ -192,7 +192,7 @@ report_ag_sick( 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;