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;
}
int fd,
prid_t projid)
{
-#if defined(__sgi__)
- return fchproj(fd, projid);
-#else
struct fsxattr fsx;
int error;
error = xfsctl(name, fd, XFS_IOC_FSSETXATTR, &fsx);
}
return error;
-#endif
}
{
fs_disk_quota_t d;
struct fsxattr fsx;
- __uint32_t projid;
uint type = XFS_PROJ_QUOTA;
char *dev = path->fs_name;
int fd;
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;
struct FTW *data)
{
struct fsxattr fsx;
- prid_t prj;
int fd;
if ((fd = open(path, O_RDONLY|O_NOCTTY)) == -1)
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);
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;
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;