/*
- * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
+ * Copyright (c) 2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation.
*
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <xfs/command.h>
" -i -- report the inode count values\n"
" -r -- report the realtime block count values\n"
" -h -- report in a human-readable format\n"
-" -n -- suppress the header from the output\n"
+" -N -- suppress the header from the output\n"
"\n"));
}
int fd;
if ((fd = open(mount->fs_dir, O_RDONLY)) < 0) {
+ exitcode = 1;
fprintf(stderr, "%s: cannot open %s: %s\n",
progname, mount->fs_dir, strerror(errno));
return 0;
*ifree = st.f_ffree;
*iused = st.f_files - st.f_ffree;
- count = fsgeo.rtextents * fsgeo.rtextsize;
- free = fscounts.freertx * fsgeo.rtextsize;
+ count = fsgeo.rtextents * fsgeo.rtextsize * fsgeo.blocksize;
+ free = fscounts.freertx * fsgeo.rtextsize * fsgeo.blocksize;
*rcount = BTOBB(count);
*rfree = BTOBB(free);
*rused = BTOBB(count - free);
__uint64_t *rused,
__uint64_t *rfree)
{
+ fs_quota_stat_t qfs;
fs_disk_quota_t d;
struct fsxattr fsx;
- __uint32_t projid;
uint type = XFS_PROJ_QUOTA;
char *dev = path->fs_name;
int fd;
+ if (xfsquotactl(XFS_GETQSTAT, dev, type, 0, &qfs) < 0 ||
+ !(qfs.qs_flags & XFS_QUOTA_PDQ_ACCT))
+ return 0;
+
if ((fd = open(path->fs_dir, O_RDONLY)) < 0) {
+ exitcode = 1;
fprintf(stderr, "%s: cannot open %s: %s\n",
progname, path->fs_dir, strerror(errno));
return 0;
}
if ((xfsctl(path->fs_dir, fd, XFS_IOC_FSGETXATTR, &fsx)) < 0) {
+ exitcode = 1;
perror("XFS_IOC_FSGETXATTR");
close(fd);
return 0;
}
if (!(fsx.fsx_xflags & XFS_XFLAG_PROJINHERIT)) {
+ exitcode = 1;
fprintf(stderr, _("%s: project quota flag not set on %s\n"),
progname, path->fs_dir);
close(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) {
+ exitcode = 1;
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;
}
- 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;
char *fname = NULL;
int c, flags = 0, form = 0, type = 0;
- while ((c = getopt(argc, argv, "bf:hnir")) != EOF) {
+ while ((c = getopt(argc, argv, "bf:hNir")) != EOF) {
switch (c) {
case 'f':
fname = optarg;
case 'h':
flags |= HUMAN_FLAG;
break;
- case 'n':
+ case 'N':
flags |= NO_HEADER_FLAG;
break;
default: