[LTP] fsconfig04: Check FSCONFIG_SET_PATH
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Wed Jun 10 12:06:10 CEST 2026
Hi Wei,
On Wed, 10 Jun 2026 05:21:25 +0000, Wei Gao wrote:
> fsconfig04: Check FSCONFIG_SET_PATH
> + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", dev0, 0));
> + if (TST_RET == -1) {
> + tst_res(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed");
> + SAFE_CLOSE(fd);
> + return;
> + }
FSCONFIG_SET_STRING is not the subject of this test -- it is
infrastructure needed before the FSCONFIG_SET_PATH call under test.
If it fails, the test cannot proceed, so it should be reported as
TBROK, not TFAIL.
Using tst_brk(TBROK | TTERRNO, ...) would also simplify this block
because cleanup() already closes fd, making the explicit SAFE_CLOSE
unnecessary:
TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", dev0, 0));
if (TST_RET == -1)
tst_brk(TBROK | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed");
> + unsigned int major, minor, device_num;
> + unsigned int found = 0;
> +
> + SAFE_SSCANF(dev2, "/dev/%s", loop_name);
> +
> + snprintf(path, sizeof(path), "/sys/block/%s/dev", loop_name);
> + SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);
> + device_num = (major << 8) | minor;
> + snprintf(device_str, sizeof(device_str), "0x%04x", device_num);
The encoding (major << 8) | minor only matches the kernel's
new_encode_dev() when minor < 256. For minor >= 256 the kernel
stores (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12),
which is what tune2fs prints.
On a system with many loop devices in use the test could get a
loop device with minor >= 256, causing the computed string to
differ from tune2fs output and producing a false TFAIL.
Consider something like:
device_num = (minor & 0xff) | (major << 8)
| ((minor & ~0xff) << 12);
Verdict: Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list