From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Miklos Szeredi <miklos@szeredi.hu>,
libc-alpha@sourceware.org, linux-man <linux-man@vger.kernel.org>,
Rich Felker <dalias@libc.org>
Cc: Alejandro Colomar <alx@kernel.org>,
Linux API <linux-api@vger.kernel.org>,
linux-fsdevel@vger.kernel.org, Karel Zak <kzak@redhat.com>,
Ian Kent <raven@themaw.net>, David Howells <dhowells@redhat.com>,
Christian Brauner <christian@brauner.io>,
Amir Goldstein <amir73il@gmail.com>,
Florian Weimer <fweimer@redhat.com>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: proposed libc interface and man page for statmount(2)
Date: Thu, 16 Nov 2023 17:12:13 -0300 [thread overview]
Message-ID: <938766c0-4cee-4363-a089-d5a6b10698d0@linaro.org> (raw)
In-Reply-To: <CAJfpegsMahRZBk2d2vRLgO8ao9QUP28BwtfV1HXp5hoTOH6Rvw@mail.gmail.com>
On 15/11/23 12:08, Miklos Szeredi wrote:
> Hi,
>
> Attaching the proposed man page for the new statmount() syscall.
>
> It describes a libc interface that is slightly different from the raw
> kernel API. The differences from the two API's are also described in
> the man page.
>
> Raw:
>
> long syscall(SYS_statmount, const struct mnt_id_req *req,
> struct statmount *buf, size_t bufsize, unsigned int flags);
>
> Libc:
>
> struct statmount *statmount(uint64_t mnt_id, uint64_t request_mask,
> struct statmount *buf, size_t bufsize,
> unsigned int flags);
>
> I propose the libc one to allow automatically allocating the buffer if
> the buf argument is NULL, similar to getcwd(3).
The glibc getcwd implementation allocates a buffer with maximum size
of max(PATH_MAX, getpagesize()) and iff getpwd syscall fails it will
fallback to a generic implementation that keep calling openat and realloc
the buf if required. So for the generic case, it would require malloc
plus realloc (to free some unused memory).
Making statmount similar to getcwd would require something alike, where
the libc will loop to reallocate the buffer if syscall returns EOVERFLOW.
I am not sure this would be the best interface, come up the initial buffer
size and the increment might be tricky and not ideal for all usage cases.
Maybe setting the initial size depending of request_mask bits, by assuming
a reasonable size for STMT_FS_TYPE and PATH_MAX for STMT_MNT_ROOT/STMT_MNT_POINT
would be a reasonable initial size.
It also always pull malloc, which is not ideal for the static linking case
since the interface not always return the strings.
next prev parent reply other threads:[~2023-11-16 20:12 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 15:08 proposed libc interface and man page for statmount(2) Miklos Szeredi
2023-11-16 20:12 ` Adhemerval Zanella Netto [this message]
2023-11-16 20:36 ` Florian Weimer
2023-11-16 21:01 ` Miklos Szeredi
2023-11-17 14:22 ` Miklos Szeredi
2023-11-17 14:47 ` Florian Weimer
2023-11-17 15:13 ` Miklos Szeredi
2023-11-17 15:50 ` Miklos Szeredi
2023-11-20 11:55 ` Miklos Szeredi
2023-11-20 12:16 ` Florian Weimer
2023-11-20 12:34 ` Miklos Szeredi
2023-11-20 23:56 ` Ian Kent
2023-11-21 0:58 ` Ian Kent
2023-11-21 1:12 ` Ian Kent
2023-11-21 1:33 ` Ian Kent
2023-11-21 19:42 ` Miklos Szeredi
2023-11-21 20:42 ` Zack Weinberg
2023-11-21 23:28 ` Ian Kent
2023-11-22 16:18 ` Zack Weinberg
2023-11-21 23:07 ` Ian Kent
2023-11-22 10:18 ` Christian Brauner
2023-11-20 15:38 ` Christian Brauner
2023-11-20 15:30 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=938766c0-4cee-4363-a089-d5a6b10698d0@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=alx@kernel.org \
--cc=amir73il@gmail.com \
--cc=arnd@arndb.de \
--cc=christian@brauner.io \
--cc=dalias@libc.org \
--cc=dhowells@redhat.com \
--cc=fweimer@redhat.com \
--cc=kzak@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=raven@themaw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).