]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - quota/init.c
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2003-2005 Silicon Graphics, Inc.
7 #include "libfrog/paths.h"
15 bool foreign_allowed
= false;
17 static char **projopts
; /* table of project names (cmdline) */
18 static int nprojopts
; /* number of entries in name table. */
25 projopts
= realloc(projopts
, sizeof(char*) * nprojopts
);
30 projopts
[nprojopts
- 1] = optarg
;
37 _("Usage: %s [-V] [-x] [-f] [-p prog] [-c cmd]... [-d project]... [path]\n"),
44 unsigned int *blocksize
,
45 unsigned int *sectsize
)
67 * This function allows xfs_quota commands to iterate across all discovered
68 * quota enabled filesystems. Commands that should not iterate all filesystems
69 * should specify CMD_FLAG_ONESHOT in their command flags.
75 if (index
>= fs_count
)
79 fs_path
= &fs_table
[index
++];
80 /* skip project quota entries */
81 if ((fs_path
->fs_flags
& FS_PROJECT_PATH
))
84 /* only consider foreign filesystems if told so */
85 if (!foreign_allowed
&& (fs_path
->fs_flags
& FS_FOREIGN
))
88 /* We can use this one */
90 } while (index
< fs_count
);
92 if (fs_path
->fs_flags
& FS_PROJECT_PATH
)
94 if (!foreign_allowed
&& (fs_path
->fs_flags
& FS_FOREIGN
))
108 /* If it's an XFS filesystem, always run the command. */
109 if (!(fs_path
->fs_flags
& FS_FOREIGN
))
112 /* If the user specified foreign filesystems are ok (-f), run cmd. */
113 if (foreign_allowed
&&
114 (ct
->flags
& CMD_FLAG_FOREIGN_OK
))
117 /* If cmd not allowed on foreign fs, regardless of -f flag, skip it. */
118 if (!(ct
->flags
& CMD_FLAG_FOREIGN_OK
)) {
119 fprintf(stderr
, _("%s: command is for XFS filesystems only\n"),
124 /* foreign fs, but cmd only allowed via -f flag. Skip it. */
126 _("%s: foreign filesystem. Invoke xfs_quota with -f to enable.\n"),
138 progname
= basename(argv
[0]);
139 setlocale(LC_ALL
, "");
140 bindtextdomain(PACKAGE
, LOCALEDIR
);
143 while ((c
= getopt(argc
, argv
, "c:d:D:fP:p:t:xV")) != EOF
) {
145 case 'c': /* commands */
146 add_user_command(optarg
);
149 add_project_opt(optarg
);
152 foreign_allowed
= true;
158 projects_file
= optarg
;
161 projid_file
= optarg
;
170 printf(_("%s version %s\n"), progname
, VERSION
);
177 fs_table_initialise(argc
- optind
, &argv
[optind
], nprojopts
, projopts
);
181 add_command_iterator(filesystem_iterator
);
182 add_check_command(init_check_command
);
185 * Ensure that global commands don't end up with an invalid path pointer
186 * by setting the default device at the first specified on the CLI
189 fs_path
= fs_table_lookup(argv
[optind
], FS_MOUNT_POINT
);
191 fs_path
= &fs_table
[0];