Re: [PATCH 2/2] selftests/overlayfs: verify device and inode numbers in /proc/pid/maps

From: Andrei Vagin
Date: Tue Dec 12 2023 - 14:45:49 EST


On Mon, Dec 11, 2023 at 11:30 AM Andrei Vagin <avagin@xxxxxxxxxx> wrote:
> +static long get_file_dev_and_inode(void *addr, struct statx *stx)
> +{
> + char buf[4096];
> + FILE *mapf;
> +
> + mapf = fopen("/proc/self/maps", "r");
> + if (mapf == NULL)
> + return pr_perror("fopen(/proc/self/maps)");
> +
> + while (fgets(buf, sizeof(buf), mapf)) {
> + unsigned long start, end;
> + uint32_t maj, min;
> + __u64 ino;
> +
> + if (sscanf(buf, "%lx-%lx %*s %*s %x:%x %llx",
> + &start, &end, &maj, &min, &ino) != 5)

inode is shown in the decimal format, so the last %llx has to be
replaced with %llu.
I will resend this test in reply to Amir's version of the first patch.

Thanks,
Andrei