Re: [PATCH] fsfreeze: suspend and resume access to an filesystem

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

 



Le jeudi 13 mai 2010 à 13:42 +0200, Karel Zak a écrit :
> On Wed, May 12, 2010 at 06:27:16AM -0400, Hajime Taira wrote:
> > I'm sorry. My source code was so dirty.
> > I fixed all problem. Thank you for your advice.
> 
>  Thanks. I have a little modified the code to match with 
>  the rest of util-linux-ng (or at least with new utils in the
>  package). Please, review.
> 

> +int main(int argc, char **argv)
> +{
> +	int fd = -1, c;
> +	int freeze = -1, rc = EXIT_FAILURE;
> +	char *path;
> +	struct stat sb;
> +
> +	struct option longopts[] = {
> +	    { "help",      0, 0, 'h' },
> +	    { "freeze",    0, 0, 'f' },
> +	    { "unfreeze",  0, 0, 'u' },
> +	    { NULL,        0, 0, 0 }
> +	};
> +

You can make mount point an argument to --freeze, --unfreeze, see below

> +	setlocale(LC_ALL, "");
> +	bindtextdomain(PACKAGE, LOCALEDIR);
> +	textdomain(PACKAGE);
> +
> +	while ((c = getopt_long(argc, argv, "hfu", longopts, NULL)) != -1) {
> +		switch(c) {
> +		case 'h':
> +			usage(stdout);
> +			break;
> +		case 'f':
> +			freeze = TRUE;
> +			break;
> +		case 'u':
> +			freeze = FALSE;
> +			break;
> +		default:
> +			usage(stderr);
> +			break;
> +		}
> +	}
> +
> +	if (freeze == -1)
> +		errx(EXIT_FAILURE, _("no action specified"));
> +	if (optind == argc)
> +		errx(EXIT_FAILURE, _("no filename specified"));
> +

Otherwise, check that optind + 1 == argc to allow only one mount point
to be specified.

Regards.

-- 
Yann Droneaud

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux