Thread (28 messages) 28 messages, 12 authors, 2016-04-18

Re: [PATCH v2 0/2] vfs: Define new syscall getumask.

flat view

From: Josh Triplett <josh@joshtriplett.org>
Date: 2016-04-18 03:00:49
Also in: lkml

On Sun, Apr 17, 2016 at 07:15:31PM -0700, H. Peter Anvin wrote:
On 04/17/16 19:12, Josh Triplett wrote:
quoted
quoted
I really like the 'libinux' idea, did anyone every hack up a first-pass
at this?  And I'm guessing we have more syscalls now that would need to
be added (like getrandom(), but that shouldn't be too difficult.
Personally, I'd suggest that libinux should wire up *all* (non-obsolete)
syscalls, not just those that haven't already been exposed via any
particular libc implementation.  Each such syscall function would have
minimal overhead, since unlike libc these wrappers would not have any
special handling (other than use of the vdso) and would directly map to
the kernel syscall signature.  Given a standard prefix like sys_ or
linux_, that would provide a clear distinction between direct-syscall
functions and libc functions, and avoid any future conflict if libc adds
a function named the same as the syscall.

As a random example, sys_getpid() would *always* call the getpid
syscall, rather than reading a cache within the library.  (And
sys_gettid would call the gettid syscall, rather than failing to exist.)
I'm not so sure this is a good idea.  It has definite pros and cons.  In
some ways it pushes it more to be like syscall(3).
It seems like one of the main problems with syscall() is that it forces
userspace to handle weird ABI issues, such as syscall numbers varying by
architecture, encoding of 64-bit arguments on 32-bit platforms (see the
example in the syscall manpage), and other subtleties that will break on
architectures other than the one the developer is most likely to be
running.  libinux bindings would eliminate those issues.

What cases do you have in mind where the libinux binding should look
different than the C API of the SYSCALL_DEFINE'd function in the kernel?

Users can still call the libc syscall when they want libc's behavior;
for syscalls that have a libc binding, most users will want that
version.  But I've often needed to call the underlying syscall even for
syscalls that *do* have a libc binding, for various purposes, and having
a standard way to do that while still having safe type signatures seems
helpful.

This would also make it much easier to write an alternative libc, or a
language standard library that doesn't want to depend on libc.

- Josh Triplett
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help