tools/verification/rv/src/rv.c

Source file repositories/reference/linux-study-clean/tools/verification/rv/src/rv.c

File Facts

System
Linux kernel
Corpus path
tools/verification/rv/src/rv.c
Extension
.c
Size
4154 bytes
Lines
202
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
			print_help = 1;
			retval = 0;
		} else if (argv[1][0] == '-') {
			/* assume invalid option */
			print_help = 1;
			retval = 1;
		} else
			container = argv[1];
	} else if (argc > 2) {
		/* more than 2 is always usage */
		print_help = 1;
		retval = 1;
	}
	if (print_help) {
		fprintf(stderr, "rv version %s\n", VERSION);
		for (i = 0; usage[i]; i++)
			fprintf(stderr, "%s\n", usage[i]);
		exit(retval);
	}

	ikm_list_monitors(container);

	exit(0);
}

/*
 * rv_mon - try to run a monitor passed as argument
 */
static void rv_mon(int argc, char **argv)
{
	char *monitor_name;
	int i, run = 0;

	static const char *const usage[] = {
		"",
		"  usage: rv mon [-h] monitor [monitor options]",
		"",
		"	run a monitor",
		"",
		"	-h/--help: print this menu",
		"",
		"	monitor [monitor options]: the monitor, passing",
		"	the arguments to the [monitor options]",
		NULL,
	};

	/* requires at least one argument */
	if (argc == 1) {

		fprintf(stderr, "rv version %s\n", VERSION);

		for (i = 0; usage[i]; i++)
			fprintf(stderr, "%s\n", usage[i]);
		exit(1);
	} else if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {

		fprintf(stderr, "rv version %s\n", VERSION);

		for (i = 0; usage[i]; i++)
			fprintf(stderr, "%s\n", usage[i]);
		exit(0);
	}

	monitor_name = argv[1];
	/*
	 * Call all possible monitor implementations, looking
	 * for the [monitor].
	 */
	run += ikm_run_monitor(monitor_name, argc-1, &argv[1]);

	if (!run)
		err_msg("rv: monitor %s does not exist\n", monitor_name);
	exit(!run);
}

static void usage(int exit_val, const char *fmt, ...)
{
	char message[1024];
	va_list ap;
	int i;

	static const char *const usage[] = {
		"",
		"  usage: rv command [-h] [command_options]",
		"",
		"	-h/--help: print this menu",
		"",
		"	command: run one of the following command:",
		"	  list: list all available monitors",

Annotation

Implementation Notes