Re: [PATCH 5/5 V3] xfs_io: add label command

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

 



On Thu, May 17, 2018 at 10:22:09AM -0500, Eric Sandeen wrote:
> This adds an online get/set/clear label command to xfs_io.
> 
> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> ---
> +static int
> +label_f(
> +	int		argc,
> +	char		**argv)
> +{
> +	int		c;
> +	int		error;
> +	char		label[FSLABEL_MAX];
> +
> +	if (argc == 1) {
> +		memset(label, 0, sizeof(label));
> +		error = ioctl(file->fd, FS_IOC_GETFSLABEL, &label);
> +		goto out;
> +	}
> +
> +	while ((c = getopt(argc, argv, "cs:")) != EOF) {
> +		switch (c) {
> +		case 'c':
> +			label[0] = '\0';
> +			break;
> +		case 's':
> +			strncpy(label, optarg, sizeof(label));
> +			break;
> +		default:

			exitcode = 1
			;
> +			return command_usage(&label_cmd);
> +		}
> +	}
> +
> +	/* Check for trailing arguments */
> +	if (argc != optind)

		exitcode = 1

> +		return command_usage(&label_cmd);
> +
> +	error = ioctl(file->fd, FS_IOC_SETFSLABEL, label);
> +out:
> +	if (error) {
> +		perror("label");
> +		exitcode = 1;
> +	} else {
> +		printf("label = \"%s\"\n", label);
> +	}
> +
> +	return 0;

Otherwise looks OK.

Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
-- 
Dave Chinner
david@xxxxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux