close(fd);
return 0;
}
- if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSGEOMETRY_V1, &fsgeo)) < 0) {
- perror("XFS_IOC_FSGEOMETRY_V1");
- close(fd);
- return 0;
- }
- if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSCOUNTS, &fscounts)) < 0) {
- perror("XFS_IOC_FSCOUNTS");
- close(fd);
- return 0;
+
+ if (!(mount->fs_flags & FS_FOREIGN)) {
+ if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSGEOMETRY_V1,
+ &fsgeo)) < 0) {
+ perror("XFS_IOC_FSGEOMETRY_V1");
+ close(fd);
+ return 0;
+ }
+ if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSCOUNTS,
+ &fscounts)) < 0) {
+ perror("XFS_IOC_FSCOUNTS");
+ close(fd);
+ return 0;
+ }
+
+ logsize = fsgeo.logstart ? fsgeo.logblocks : 0;
+ count = (fsgeo.datablocks - logsize) * fsgeo.blocksize;
+ free = fscounts.freedata * fsgeo.blocksize;
+ *bcount = BTOBB(count);
+ *bfree = BTOBB(free);
+ *bused = BTOBB(count - free);
+
+ count = fsgeo.rtextents * fsgeo.rtextsize * fsgeo.blocksize;
+ free = fscounts.freertx * fsgeo.rtextsize * fsgeo.blocksize;
+ *rcount = BTOBB(count);
+ *rfree = BTOBB(free);
+ *rused = BTOBB(count - free);
+ } else {
+ count = st.f_blocks * st.f_bsize;
+ free = st.f_bfree * st.f_bsize;
+ *bcount = BTOBB(count);
+ *bfree = BTOBB(free);
+ *bused = BTOBB(count - free);
+
+ *rcount = BTOBB(0);
+ *rfree = BTOBB(0);
+ *rused = BTOBB(0);
}
- logsize = fsgeo.logstart ? fsgeo.logblocks : 0;
- count = (fsgeo.datablocks - logsize) * fsgeo.blocksize;
- free = fscounts.freedata * fsgeo.blocksize;
- *bcount = BTOBB(count);
- *bfree = BTOBB(free);
- *bused = BTOBB(count - free);
*icount = st.f_files;
*ifree = st.f_ffree;
*iused = st.f_files - st.f_ffree;
- count = fsgeo.rtextents * fsgeo.rtextsize * fsgeo.blocksize;
- free = fscounts.freertx * fsgeo.rtextsize * fsgeo.blocksize;
- *rcount = BTOBB(count);
- *rfree = BTOBB(free);
- *rused = BTOBB(count - free);
-
close(fd);
return 1;
}
free_cmd.cfunc = free_f;
free_cmd.argmin = 0;
free_cmd.argmax = -1;
- free_cmd.args = _("[-bir] [-hn] [-f file]");
+ free_cmd.args = _("[-bir] [-hN] [-f file]");
free_cmd.oneline = _("show free and used counts for blocks and inodes");
free_cmd.help = free_help;
+ free_cmd.flags = CMD_FLAG_FOREIGN_OK;
add_command(&free_cmd);
}