Re: [PATCH 2/6] Btrfs-progs: add btrfsck functionality to btrfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



H Iam,

On 02/08/2013 01:36 AM, Ian Kumlien wrote:
> This patch includes the functionality of btrfs, it's
> found as "btrfs check" however it makes the binary
> behave differently depending on what it's run as.
[...]

>  
> +static int cmd_dummy(int argc, char **argv)
> +{
> +	return 0;

I think we should warn that fsck.btrfs does nothing. Something like:
 +	fprintf(stderr, "WARNING: fsck.btrfs does nothing. "
		"Try 'btrfs check'\n");



> +}
> +
> +/* change behaviour depending on what we're called */
> +const struct cmd_group function_cmd_group = {
> +	NULL, NULL,
> +	{
> +		{ "btrfsck", cmd_check, NULL, NULL, 0 },
> +		{ "fsck.btrfs", cmd_dummy, NULL, NULL, 0 },
> +		{ 0, 0, 0, 0, 0 }
> +	},
> +};
> +
>  int main(int argc, char **argv)
>  {
>  	const struct cmd_struct *cmd;
> +	char *called_as = strrchr(argv[0], '/');
> +	if (called_as)
> +		argv[0] = ++called_as;
>  
>  	crc32c_optimization_init();
>  
> -	argc--;
> -	argv++;
> -	handle_options(&argc, &argv);
> -	if (argc > 0) {
> -		if (!prefixcmp(argv[0], "--"))
> -			argv[0] += 2;
> -	} else {
> -		usage_command_group(&btrfs_cmd_group, 0, 0);
> -		exit(1);
> -	}
> +	/* if we have cmd, we're started as a sub command */
> +	if (parse_one_exact_token(argv[0], &function_cmd_group, &cmd) < 0)
> +	{
> +		argc--;
> +		argv++;
>  
> -	cmd = parse_command_token(argv[0], &btrfs_cmd_group);
> +		handle_options(&argc, &argv);
> +		if (argc > 0) {
> +			if (!prefixcmp(argv[0], "--"))
> +				argv[0] += 2;

I can't understand the reason to skip '--' ? But this question is not
related to your patch...

> +		} else {
> +			usage_command_group(&btrfs_cmd_group, 0, 0);
[...]

-- 
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux