[LTP] [PATCH v12] fsconfig04: Check FSCONFIG_SET_PATH
Petr Vorel
pvorel@suse.cz
Thu Aug 6 13:30:13 CEST 2026
Hi Wei,
> The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect;
> most of the calls there just set a dummy "sync" parameter. This test
> case aims to verify if the FSCONFIG_SET_PATH operation can be used
> to dynamically change the external journal device of an ext3 or ext4
> filesystem.
LGTM, thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>
...
> + char loop_name[NAME_MAX];
> + char path[PATH_MAX + 32];
> + char device_str[NAME_MAX];
> + unsigned int major, minor, device_num;
> + unsigned int found = 0;
very nit: I'd use bool for found (but of course it can stay as int).
> +
> + 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 = (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
> + snprintf(device_str, sizeof(device_str), "0x%04x", device_num);
> +
> + char line[PATH_MAX];
> + FILE *tune2fs;
> +
> + snprintf(path, sizeof(path), "tune2fs -l %s 2>&1", dev0);
> + tune2fs = SAFE_POPEN(path, "r");
> +
> + while (fgets(line, PATH_MAX, tune2fs)) {
> + if (*line && strstr(line, "Journal device:") && strstr(line, device_str)) {
> + found = 1;
> + break;
> + }
> + }
> +
> + if (found == 1)
> + tst_res(TPASS, "Device found in journal");
> + else
> + tst_res(TFAIL, "Device not found in journal");
> +
> + pclose(tune2fs);
> + SAFE_CLOSE(fd);
> +}
> +
> +static struct tst_test test = {
> + .test_all = run,
> + .setup = setup,
> + .cleanup = cleanup,
> + .needs_root = 1,
> + .needs_tmpdir = 1,
.needs_tmpdir is probably useless (run: 'cd doc/ && make clean && make' to see
the errors) => I can delete it before merge.
Kind regards,
Petr
More information about the ltp
mailing list