Re: [PATCH] libxfs: detect zoned disks and prevent their raw use

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

 



On Fri, 2018-06-15 at 13:50 -0700, Luis R. Rodriguez wrote:
> +static int
> +is_zoned_disk(char *path)
> +{
> +	char str[PATH_MAX];
> +	char *devname = basename(path);
> +	FILE *file;
> +	int len;
> +
> +
> +	len = snprintf(str, sizeof(str), "/sys/block/%s/queue/zoned", devname);

Have you considered to use asprintf() instead of using snprintf() and a fixed
size buffer?

> +
> +	/* Indicates truncation */
> +	if (len >= PATH_MAX) {
> +		errno = ENAMETOOLONG;
> +		return -1;
> +	}
> +
> +	file = fopen(str, "r");
> +	if (!file)
> +		return 0;
> +
> +	fclose(file);
> +
> +	return 1;
> +}

I think that you have to read the sysfs file and only return 1 for host-managed
drives. Creating a filesystem on top of a host-aware drive should not be forbidden.
Please also rename "is_zoned_disk()" into "is_host_managed()" or so.

Thanks,

Bart.




��.n��������+%������w��{.n�����{�����jg��������ݢj����G�������j:+v���w�m������w�������h�����٥




[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