[Ocfs2-tools-devel] [PATCH 11/39] ocfs2_controld: Add the test client

Sunil Mushran Sunil.Mushran at oracle.com
Wed May 21 18:03:57 PDT 2008


Joel Becker wrote:
> The test_client allows us to poke ocfs2_controld without trying to
> actually run mount(1).
>
> Signed-off-by: Joel Becker <joel.becker at oracle.com>
>   
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>


Some help here for the args (usage) would be nice, eventhough this
is a test program.


> +static int parse_options(int argc, char **argv, int *op, char ***args)
> +{
> +	int rc = 0;
> +
> +	if (argc < 2) {
> +		fprintf(stderr, "Operation required\n");
> +		return -EINVAL;
> +	}
> +
> +	if (!strcmp(argv[1], "mount")) {
> +		if (argc == 6) {
> +			*op = OP_MOUNT;
> +			*args = argv + 2;
> +		} else {
> +			fprintf(stderr, "Invalid number of arguments\n");
> +			rc = -EINVAL;
> +		}
> +	} else if (!strcmp(argv[1], "umount")) {
> +		if (argc == 4) {
> +			*op = OP_UMOUNT;
> +			*args = argv + 2;
> +		} else {
> +			fprintf(stderr, "Invalid number of arguments\n");
> +			rc = -EINVAL;
> +		}
> +	} else {
> +		fprintf(stderr, "Invalid operation: %s\n", argv[1]);
> +		rc = -EINVAL;
> +	}
> +
> +	return rc;
> +}
>   




More information about the Ocfs2-tools-devel mailing list