Re: [PATCH] samples: add a mountinfo program to demonstrate statmount()/listmount()

From: Miklos Szeredi
Date: Wed Nov 13 2024 - 09:25:42 EST


On Tue, 12 Nov 2024 at 22:21, Jeff Layton <jlayton@xxxxxxxxxx> wrote:

> + /* Walk the returned mntids and print info about each */
> + for (i = 0; i < count; ++i) {
> + int ret = dump_mountinfo(mntid[i], mnt_ns_id);
> +
> + if (ret != 0)
> + return ret;
> + }
> + /* Set up last_mnt_id to pick up where we left off */
> + last_mnt_id = mntid[count - 1] + 1;

The +1 is wrong, see do_listmount(), which already increments the last ID:

first = mnt_find_id_at(ns, last_mnt_id + 1);

I also have some ideas for "cooked" interfaces that are easier to use.
See here:

https://lore.kernel.org/all/CAJfpegsMahRZBk2d2vRLgO8ao9QUP28BwtfV1HXp5hoTOH6Rvw@xxxxxxxxxxxxxx/
https://lore.kernel.org/all/CAJfpeguMViqawKfJtM7_M9=m+6WsTcPfa_18t_rM9iuMG096RA@xxxxxxxxxxxxxx/

I can do an incremental patch to add these ideas to this example.

Thanks,
Miklos