]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - quota/quot.c
xfs: fix maxicount division by zero error
[thirdparty/xfsprogs-dev.git] / quota / quot.c
index 7edfad1686d1acbc8ccad291fe586fad815712ff..8544aef634f93164b890892899b3d4c3d5073e2a 100644 (file)
@@ -11,6 +11,7 @@
 #include <grp.h>
 #include "init.h"
 #include "quota.h"
+#include "libfrog/logging.h"
 #include "libfrog/fsgeom.h"
 #include "libfrog/bulkstat.h"
 
@@ -145,30 +146,27 @@ 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) {
-               errno = ret;
-               perror(fsdir);
+               xfrog_perror(ret, fsdir);
                return;
        }
 
-       breq = xfrog_bulkstat_alloc_req(NBSTAT, 0);
-       if (!breq) {
-               perror("calloc");
+       ret = -xfrog_bulkstat_alloc_req(NBSTAT, 0, &breq);
+       if (ret) {
+               xfrog_perror(ret, "calloc");
                xfd_close(&fsxfd);
                return;
        }
 
-       while ((sts = xfrog_bulkstat(&fsxfd, breq)) == 0) {
+       while ((sts = -xfrog_bulkstat(&fsxfd, breq)) == 0) {
                if (breq->hdr.ocount == 0)
                        break;
                for (i = 0; i < breq->hdr.ocount; i++)
                        quot_bulkstat_add(&breq->bulkstat[i], flags);
        }
-       if (sts < 0) {
-               errno = sts;
-               perror("XFS_IOC_FSBULKSTAT");
-       }
+       if (sts < 0)
+               xfrog_perror(sts, "XFS_IOC_FSBULKSTAT");
        free(breq);
        xfd_close(&fsxfd);
 }