]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libfrog: convert fsgeom.c functions to negative error codes
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 6 Nov 2019 22:32:33 +0000 (17:32 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 6 Nov 2019 22:32:33 +0000 (17:32 -0500)
Convert libfrog functions to return negative error codes like libxfs
does.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
16 files changed:
fsr/xfs_fsr.c
growfs/xfs_growfs.c
io/bmap.c
io/bulkstat.c
io/fsmap.c
io/open.c
io/stat.c
libfrog/bulkstat.c
libfrog/fsgeom.c
quota/free.c
quota/quot.c
repair/xfs_repair.c
rtcp/xfs_rtcp.c
scrub/phase1.c
spaceman/file.c
spaceman/health.c

index af5d6169eb8ab4c98dca582be28a0b14482d1472..3e9ba27ca84e7f4b1eb2a8fcaa660dc92289730b 100644 (file)
@@ -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));
index 6c62833b1eb15bd3739134f5ac20a85d666ef927..d27e3b94e0c46c06b85d95f4432d85bdf7dc8975 100644 (file)
@@ -169,7 +169,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"),
@@ -355,7 +355,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));
index cf4ea12b75a7eadc84cd1ff2c1c4409f8ed8f4ab..f838840eb5336270b1c77f27250baabb0ca0c121 100644 (file)
--- 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"),
index 9641370b85d635fe476fecd8d6e2c180718a0f7d..b081567fffa90eb3e45a34261d1a68bce7a9b5e8 100644 (file)
@@ -163,7 +163,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;
@@ -271,7 +271,7 @@ bulkstat_single_f(
                }
        }
 
-       ret = xfd_prepare_geometry(&xfd);
+       ret = -xfd_prepare_geometry(&xfd);
        if (ret) {
                xfrog_perror(ret, "xfd_prepare_geometry");
                exitcode = 1;
@@ -419,7 +419,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;
index 12ec1e442aff025553db03420de6821ececd6470..feacb264a9d0755968e3ded9f9eab772c49e6059 100644 (file)
@@ -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;
                }
index a5192e87288f45e389e7fdf4706e3263c84f6369..464bcad99a15a293fd92a9cf8089f8462df3b576 100644 (file)
--- 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);
index db3357805499b6d14d23f08b10657757841dad40..d125a0f78539779d99a7d0679cdc9cab32ab5c5b 100644 (file)
--- 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 {
index 538b5197039a122ad2b4218427b4e95c03dd9dd5..38d634f7b3d46bb6420c52e6df37eee29efdde21 100644 (file)
@@ -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. */
index 3ea91e3fa2f2a2a250a3697131fb104777f47455..19a4911fcf085890f210a02a08a7f4123e0f30c5 100644 (file)
@@ -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;
 }
index 45ce2ceb04d59f6bf0053763f79dbe47f71cd587..ea9c112f314a1287b7f999a2de79fb8bdcd9dbbf 100644 (file)
@@ -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);
index 0f69fabd83d156ce96318ab0c5c9f600ab6ed2f1..df3825f2a4f8cc1cdec9e676b0a965c26209da53 100644 (file)
@@ -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;
index 3338a7b8c97fec254cb2a5a3b2998273e1812f09..9295673dde724009cf5a250f810a1596d0774b48 100644 (file)
@@ -642,7 +642,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"
index a5737699303dac3bb1d34934ee077789adb7485f..7c4197b1314ceb1a6e6d8075ab6d0582da2eb459 100644 (file)
@@ -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;
index e0382b04501f9e0b6dbfb0182fcbb4dd7abf3807..6125d3245dda7fbf88e228aa38cdea879f815f9e 100644 (file)
@@ -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)
index b779432858c8cfb64c2885f9d820c73dcaa1581c..eec7ee9f4ba9a59af996b9458bef3cc70c700ccc 100644 (file)
@@ -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,
index a0079bd78fa3c5df9d9d8f495c22788166b71c9b..c6d936fb185f4e71e69ece6b40c5ed8e15f85f0d 100644 (file)
@@ -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;