]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Cleanup fsxattr interace use, now that IRIX also supports projid via this mechanism.
authorNathan Scott <nathans@sgi.com>
Thu, 29 Sep 2005 04:02:32 +0000 (04:02 +0000)
committerNathan Scott <nathans@sgi.com>
Thu, 29 Sep 2005 04:02:32 +0000 (04:02 +0000)
libxcmd/projects.c
quota/free.c
quota/project.c

index 35cbb11ab0aff4debfcfe1090cde4a7f677e7777..40d224370f93f5ecf2ced45b2922271419475975 100644 (file)
@@ -188,21 +188,13 @@ getprojid(
        int             fd,
        prid_t          *projid)
 {
-#if defined(__sgi__)
-       struct stat64   st;
-       if (fstat64(fd, &st) < 0) {
-               perror("fstat64");
-               return -1;
-       }
-       *projid = st.st_projid;
-#else
        struct fsxattr  fsx;
+
        if (xfsctl(name, fd, XFS_IOC_FSGETXATTR, &fsx)) {
                perror("XFS_IOC_FSGETXATTR");
                return -1;
        }
        *projid = fsx.fsx_projid;
-#endif
        return 0;
 }
 
@@ -212,9 +204,6 @@ setprojid(
        int             fd,
        prid_t          projid)
 {
-#if defined(__sgi__)
-       return fchproj(fd, projid);
-#else
        struct fsxattr  fsx;
        int             error;
 
@@ -223,5 +212,4 @@ setprojid(
                error = xfsctl(name, fd, XFS_IOC_FSSETXATTR, &fsx);
        }
        return error;
-#endif
 }
index 4234c89168678401b63dde7c18aa87db5dc3bfc5..502b8ef7b5c3b9abdea9d87afd5ea3b4ab008b11 100644 (file)
@@ -132,7 +132,6 @@ projects_free_space_data(
 {
        fs_disk_quota_t         d;
        struct fsxattr          fsx;
-       __uint32_t              projid;
        uint                    type = XFS_PROJ_QUOTA;
        char                    *dev = path->fs_name;
        int                     fd;
@@ -155,21 +154,17 @@ projects_free_space_data(
                return 0;
        }
 
-       if ((getprojid(path->fs_dir, fd, &projid)) < 0) {
-               close(fd);
-               return 0;
-       }
-       if (path->fs_prid != projid) {
+       if (path->fs_prid != fsx.fsx_projid) {
                fprintf(stderr,
                        _("%s: project ID %u (%s) doesn't match ID %u (%s)\n"),
                        progname, path->fs_prid, projects_file,
-                       projid, path->fs_dir);
+                       fsx.fsx_projid, path->fs_dir);
                close(fd);
                return 0;
        }
 
-       xfsquotactl(XFS_QSYNC, dev, type, projid, NULL);
-       if (xfsquotactl(XFS_GETQUOTA, dev, type, projid, (void *)&d) < 0) {
+       xfsquotactl(XFS_QSYNC, dev, type, fsx.fsx_projid, NULL);
+       if (xfsquotactl(XFS_GETQUOTA, dev, type, fsx.fsx_projid, &d) < 0) {
                perror("XFS_GETQUOTA");
                close(fd);
                return 0;
index d998c80e6f4fb814ecf8ed56cba27b949fba271a..499c19393c9783e10352737f0c06e00b4fb1f260 100644 (file)
@@ -95,7 +95,6 @@ check_project(
        struct FTW              *data)
 {
        struct fsxattr          fsx;
-       prid_t                  prj;
        int                     fd;
 
        if ((fd = open(path, O_RDONLY|O_NOCTTY)) == -1)
@@ -104,14 +103,11 @@ check_project(
        else if ((xfsctl(path, fd, XFS_IOC_FSGETXATTR, &fsx)) < 0)
                fprintf(stderr, _("%s: cannot get flags on %s: %s\n"),
                        progname, path, strerror(errno));
-       else if (getprojid(path, fd, &prj) < 0)
-               fprintf(stderr, _("%s: cannot get project ID on %s: %s\n"),
-                       progname, path, strerror(errno));
        else {
-               if (prj != prid)
+               if (fsx.fsx_projid != prid)
                        printf(_("%s - project identifier is not set"
                                 " (inode=%u, tree=%u)\n"),
-                               path, prj, prid);
+                               path, fsx.fsx_projid, prid);
                if (!(fsx.fsx_xflags & XFS_XFLAG_PROJINHERIT))
                        printf(_("%s - project inheritance flag is not set\n"),
                                path);
@@ -142,13 +138,10 @@ clear_project(
                return 0;
        }
 
+       fsx.fsx_projid = 0;
        fsx.fsx_xflags &= ~XFS_XFLAG_PROJINHERIT;
-
-       if (setprojid(path, fd, 0) < 0)
-               fprintf(stderr, _("%s: cannot clear project ID on %s: %s\n"),
-                       progname, path, strerror(errno));
-       else if (xfsctl(path, fd, XFS_IOC_FSSETXATTR, &fsx) < 0)
-               fprintf(stderr, _("%s: cannot clear flags on %s: %s\n"),
+       if (xfsctl(path, fd, XFS_IOC_FSSETXATTR, &fsx) < 0)
+               fprintf(stderr, _("%s: cannot clear project on %s: %s\n"),
                        progname, path, strerror(errno));
        close(fd);
        return 0;
@@ -175,13 +168,10 @@ setup_project(
                return 0;
        }
 
+       fsx.fsx_projid = prid;
        fsx.fsx_xflags |= XFS_XFLAG_PROJINHERIT;
-
        if (xfsctl(path, fd, XFS_IOC_FSSETXATTR, &fsx) < 0)
-               fprintf(stderr, _("%s: cannot set flags on %s: %s\n"),
-                       progname, path, strerror(errno));
-       else if (setprojid(path, fd, prid) < 0)
-               fprintf(stderr, _("%s: cannot set project ID on %s: %s\n"),
+               fprintf(stderr, _("%s: cannot set project on %s: %s\n"),
                        progname, path, strerror(errno));
        close(fd);
        return 0;