]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Make fstat() and friends work.
authorEd Schouten <ed@FreeBSD.org>
Tue, 28 Jul 2015 06:36:49 +0000 (06:36 +0000)
committerEd Schouten <ed@FreeBSD.org>
Tue, 28 Jul 2015 06:36:49 +0000 (06:36 +0000)
commitcec575201a4c9c10aa39dda868fbed5c64908c17
tree68425b29eb6d3e6926ae7e7cc9b083ebd55cdabd
parentf40c76d8dedcc7cf095b00787567a4f1d575280f
Make fstat() and friends work.

Summary:
CloudABI provides access to two different stat structures:

- fdstat, containing file descriptor level status: oflags, file
  descriptor type and Capsicum rights, used by cap_rights_get(),
  fcntl(F_GETFL), getsockopt(SO_TYPE).
- filestat, containing your regular file status: timestamps, inode
  number, used by fstat().

Unlike FreeBSD's stat::st_mode, CloudABI file descriptor types don't
have overloaded meanings (e.g., returning S_ISCHR() for kqueues). Add a
utility function to extract the type of a file descriptor accurately.

CloudABI does not work with O_ACCMODEs. File descriptors have two sets
of Capsicum-style rights: rights that apply to the file descriptor
itself ('base') and rights that apply to any new file descriptors
yielded through openat() ('inheriting'). Though not perfect, we can
pretty safely decompose Capsicum rights to such a pair. This is done in
convert_capabilities().

Test Plan: Tests for these system calls are fairly extensive in cloudlibc.

Reviewers: jonathan, mjg, #manpages

Reviewed By: mjg

Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D3171
sys/compat/cloudabi/cloudabi_fd.c
sys/compat/cloudabi/cloudabi_file.c
sys/compat/cloudabi/cloudabi_util.h