#include <sys/time.h>
-#define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */
+#define CMD_FLAG_GLOBAL (1<<31) /* don't iterate "args" */
+#define CMD_FLAG_FOREIGN_OK (1<<30) /* command not restricted to XFS */
typedef int (*cfunc_t)(int argc, char **argv);
typedef void (*helpfunc_t)(void);
#define FS_MOUNT_POINT (1<<0)
#define FS_PROJECT_PATH (1<<1)
+#define FS_FOREIGN (1<<2)
typedef struct fs_path {
char *fs_name; /* Data device for filesystem */
#define CMD_NOFILE_OK (1<<0) /* command doesn't need an open file */
#define CMD_NOMAP_OK (1<<1) /* command doesn't need a mapped region */
-#define CMD_FOREIGN_OK (1<<2) /* command not restricted to XFS files */
+#define CMD_FOREIGN_OK CMD_FLAG_FOREIGN_OK
extern char *progname;
extern int exitcode;
goto out_nodev;
}
+ if (!platform_test_xfs_path(dir))
+ flags |= FS_FOREIGN;
+
/*
* Make copies of the directory and data device path.
* The log device and real-time device, if non-null,
return errno;
while ((mnt = getmntent(mtp)) != NULL) {
- if (strcmp(mnt->mnt_type, "xfs") != 0)
- continue;
if (!realpath(mnt->mnt_dir, rmnt_dir))
continue;
if (!realpath(mnt->mnt_fsname, rmnt_fsname))
return errno;
for (i = 0; i < count; i++) {
- if (strcmp(stats[i].f_fstypename, "xfs") != 0)
- continue;
if (!realpath(stats[i].f_mntfromname, rmntfromname))
continue;
if (!realpath(stats[i].f_mntonname, rmntonname))
[
.B \-x
] [
+.B \-f
+] [
.B \-p
.I prog
] [
section below) which allow modifications to the quota system are
available only in expert mode.
.TP
+.B \-f
+Enable foreign filesystem mode.
+A limited number of user and administrative commands are available for
+use on some foreign (non-XFS) filesystems.
+.TP
.BI \-d " project"
Project names or numeric identifiers may be specified with this option,
which restricts the output of the individual
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdbool.h>
#include "command.h"
#include "init.h"
#include "quota.h"
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);
}
char *progname;
int exitcode;
int expert;
+bool foreign_allowed = false;
static char **projopts; /* table of project names (cmdline) */
static int nprojopts; /* number of entries in name table. */
usage(void)
{
fprintf(stderr,
- _("Usage: %s [-V] [-x] [-p prog] [-c cmd]... [-d project]... [path]\n"),
+ _("Usage: %s [-V] [-x] [-f] [-p prog] [-c cmd]... [-d project]... [path]\n"),
progname);
exit(1);
}
do {
fs_path = &fs_table[index++];
- } while ((fs_path->fs_flags & FS_PROJECT_PATH) && index < fs_count);
+ /* skip project quota entries */
+ if ((fs_path->fs_flags & FS_PROJECT_PATH))
+ continue;
+
+ /* only consider foreign filesystems if told so */
+ if (!foreign_allowed && (fs_path->fs_flags & FS_FOREIGN))
+ continue;
+
+ /* We can use this one */
+ break;
+ } while (index < fs_count);
if (fs_path->fs_flags & FS_PROJECT_PATH)
return 0;
+ if (!foreign_allowed && (fs_path->fs_flags & FS_FOREIGN))
+ return 0;
if (index > fs_count)
return 0;
return index;
}
+static int
+init_check_command(
+ const cmdinfo_t *ct)
+{
+ if (fs_path &&
+ !(ct->flags & CMD_FLAG_FOREIGN_OK) &&
+ (fs_path->fs_flags & FS_FOREIGN)) {
+ fprintf(stderr,
+ _("foreign mount active, %s command is for XFS filesystems only\n"),
+ ct->name);
+ return 0;
+ }
+ return 1;
+}
+
static void
init(
int argc,
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((c = getopt(argc, argv, "c:d:D:P:p:t:xV")) != EOF) {
+ while ((c = getopt(argc, argv, "c:d:D:fP:p:t:xV")) != EOF) {
switch (c) {
case 'c': /* commands */
add_user_command(optarg);
case 'd':
add_project_opt(optarg);
break;
+ case 'f':
+ foreign_allowed = true;
case 't':
mtab_file = optarg;
break;
init_commands();
add_args_command(init_args_command);
+ add_check_command(init_check_command);
/*
* Ensure that global commands don't end up with an invalid path pointer
extern char *progname;
extern int exitcode;
extern int expert;
+extern bool foreign_allowed;
extern void edit_init(void);
extern void free_init(void);
if (number) {
printf(_("%c%03d%c "), braces? '[':' ', index, braces? ']':' ');
}
+ printf("%s ", (path->fs_flags & FS_FOREIGN) ? "(F)" : " ");
printf(_("%-19s %s"), path->fs_dir, path->fs_name);
if (path->fs_flags & FS_PROJECT_PATH) {
prj = getprprid(path->fs_prid);
path_cmd.cfunc = path_f;
path_cmd.argmin = 0;
path_cmd.argmax = 1;
- path_cmd.flags = CMD_FLAG_GLOBAL;
+ path_cmd.flags = CMD_FLAG_GLOBAL | CMD_FLAG_FOREIGN_OK;
path_cmd.oneline = _("set current path, or show the list of paths");
print_cmd.name = "print";
print_cmd.cfunc = print_f;
print_cmd.argmin = 0;
print_cmd.argmax = 0;
- print_cmd.flags = CMD_FLAG_GLOBAL;
+ print_cmd.flags = CMD_FLAG_GLOBAL | CMD_FLAG_FOREIGN_OK;
print_cmd.oneline = _("list known mount points and projects");
if (expert)
project_cmd.argmax = -1;
project_cmd.oneline = _("check, setup or clear project quota trees");
project_cmd.help = project_help;
+ project_cmd.flags = CMD_FLAG_FOREIGN_OK;
if (expert)
add_command(&project_cmd);
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdbool.h>
#include "command.h"
#include <ctype.h>
#include <pwd.h>
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdbool.h>
#include "command.h"
#include <ctype.h>
#include <pwd.h>
quota_cmd.args = _("[-bir] [-g|-p|-u] [-hnNv] [-f file] [id|name]...");
quota_cmd.oneline = _("show usage and limits");
quota_cmd.help = quota_help;
+ quota_cmd.flags = CMD_FLAG_FOREIGN_OK;
add_command("a_cmd);
}
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
+#include <stdbool.h>
#include "command.h"
#include <sys/types.h>
#include <pwd.h>
if (type & XFS_USER_QUOTA) {
fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
while ((mount = fs_cursor_next_entry(&cursor))) {
+ if (!foreign_allowed && (mount->fs_flags & FS_FOREIGN))
+ continue;
if (xfsquotactl(XFS_QSYNC, mount->fs_name,
XFS_USER_QUOTA, 0, NULL) < 0
&& errno != ENOENT && errno != ENOSYS)
if (type & XFS_GROUP_QUOTA) {
fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
while ((mount = fs_cursor_next_entry(&cursor))) {
+ if (!foreign_allowed && (mount->fs_flags & FS_FOREIGN))
+ continue;
if (xfsquotactl(XFS_QSYNC, mount->fs_name,
XFS_GROUP_QUOTA, 0, NULL) < 0
&& errno != ENOENT && errno != ENOSYS)
if (type & XFS_PROJ_QUOTA) {
fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
while ((mount = fs_cursor_next_entry(&cursor))) {
+ if (!foreign_allowed && (mount->fs_flags & FS_FOREIGN))
+ continue;
if (xfsquotactl(XFS_QSYNC, mount->fs_name,
XFS_PROJ_QUOTA, 0, NULL) < 0
&& errno != ENOENT && errno != ENOSYS)
dump_cmd.args = _("[-g|-p|-u] [-f file]");
dump_cmd.oneline = _("dump quota information for backup utilities");
dump_cmd.help = dump_help;
+ dump_cmd.flags = CMD_FLAG_FOREIGN_OK;
report_cmd.name = "report";
report_cmd.altname = "repquota";
report_cmd.cfunc = report_f;
report_cmd.argmin = 0;
report_cmd.argmax = -1;
- report_cmd.flags = CMD_FLAG_GLOBAL;
report_cmd.args = _("[-bir] [-gpu] [-ahnt] [-f file]");
report_cmd.oneline = _("report filesystem quota information");
report_cmd.help = report_help;
+ report_cmd.flags = CMD_FLAG_GLOBAL | CMD_FLAG_FOREIGN_OK;
if (expert) {
add_command(&dump_cmd);
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
+#include <stdbool.h>
#include "command.h"
#include "init.h"
#include "quota.h"
off_cmd.args = _("[-gpu] [-v]");
off_cmd.oneline = _("permanently switch quota off for a path");
off_cmd.help = off_help;
+ off_cmd.flags = CMD_FLAG_FOREIGN_OK;
state_cmd.name = "state";
state_cmd.cfunc = state_f;
state_cmd.args = _("[-gpu] [-a] [-v] [-f file]");
state_cmd.oneline = _("get overall quota state information");
state_cmd.help = state_help;
+ state_cmd.flags = CMD_FLAG_FOREIGN_OK;
enable_cmd.name = "enable";
enable_cmd.cfunc = enable_f;
*/
#include <sys/types.h>
+#include <stdbool.h>
#include <pwd.h>
#include <grp.h>
#include <utmp.h>