'-m' is logically an independent option and should not be mixed and
matched with other options and also when used with '-h', help always
takes precedence over other options. Fix both cases of usage with
a bool flag, that gets set when parsing the command line option but
executes only it meets the rules of not mixing with other options.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit
ce809ea7519b2741edbb823618fdf6796de1f4d0)
{
bool do_not_fill_controller = false;
bool first_cgroup_is_dummy = false;
+ bool cgroup_mount_type = false;
bool fill_controller = false;
int ret = 0;
int c;
goto err;
break;
case 'm':
- ret = find_cgroup_mount_type();
- if (ret)
- goto err;
+ cgroup_mount_type = true;
break;
default:
usage(1, argv[0]);
exit(EXIT_BADARGS);
}
+ /* '-m' should not used with other options */
+ if (cgroup_mount_type && (fill_controller || do_not_fill_controller)) {
+ usage(1, argv[0]);
+ exit(EXIT_BADARGS);
+ }
+
+ if (cgroup_mount_type) {
+ ret = find_cgroup_mount_type();
+ if (ret)
+ goto err;
+ }
+
ret = parse_opt_args(argc, argv, cg_list, cg_list_len, first_cgroup_is_dummy);
if (ret)
goto err;