[LTP] [PATCH v4 3/4] syscalls/statx11: Add basic test for STATX_DIOALIGN on block device

Eric Biggers ebiggers@kernel.org
Thu Apr 27 00:12:21 CEST 2023


On Thu, Apr 06, 2023 at 01:40:21PM +0800, Yang Xu wrote:
> +static void verify_statx(void)
> +{
> +	struct statx buf;
> +
> +	memset(&buf, 0, sizeof(buf));

It is not necessary to memset struct statx to 0 before calling statx().

> +#ifdef HAVE_STRUCT_STATX_STX_DIO_MEM_ALIGN

Again, this looks wrong.  If the system headers are outdated, then LTP should
use its in-tree header instead.

> +static void setup(void)
> +{
> +	char *dev_name;
> +
> +	dev_name = basename((char *)tst_device->dev);

This is modifying a const string, which seems problematic.

> +	sprintf(sys_bdev_logical_path, "/sys/block/%s/queue/logical_block_size", dev_name);
> +	while (access(sys_bdev_logical_path, F_OK) != 0) {
> +		dev_name[strlen(dev_name)-1] = '\0';
> +		sprintf(sys_bdev_logical_path, "/sys/block/%s/queue/logical_block_size", dev_name);
> +	}

What is this code doing?  Is it trying to strip off the partition number of the
block device name?  If so, it is incorrect because it assumes the partition
number is only 1 digit long, which is not guaranteed.

How about just using /sys/class/block/%s/queue, which works for partitions?

- Eric


More information about the ltp mailing list