From 764b1982be7c4c80ad4bae1fd8d390d6d82f4323 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Thu, 29 Sep 2005 04:02:32 +0000 Subject: [PATCH] Cleanup fsxattr interace use, now that IRIX also supports projid via this mechanism. --- libxcmd/projects.c | 14 +------------- quota/free.c | 13 ++++--------- quota/project.c | 24 +++++++----------------- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/libxcmd/projects.c b/libxcmd/projects.c index 35cbb11ab..40d224370 100644 --- a/libxcmd/projects.c +++ b/libxcmd/projects.c @@ -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 } diff --git a/quota/free.c b/quota/free.c index 4234c8916..502b8ef7b 100644 --- a/quota/free.c +++ b/quota/free.c @@ -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; diff --git a/quota/project.c b/quota/project.c index d998c80e6..499c19393 100644 --- a/quota/project.c +++ b/quota/project.c @@ -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; -- 2.39.2