Page MenuHomeFreeBSD

Make fstat() and friends work.
ClosedPublic

Authored by ed on Jul 23 2015, 3:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 11, 4:18 PM
Unknown Object (File)
Mon, Nov 11, 4:18 PM
Unknown Object (File)
Sat, Nov 9, 4:31 PM
Unknown Object (File)
Thu, Nov 7, 11:42 PM
Unknown Object (File)
Wed, Nov 6, 11:10 PM
Unknown Object (File)
Wed, Nov 6, 11:06 PM
Unknown Object (File)
Wed, Nov 6, 10:18 PM
Unknown Object (File)
Thu, Oct 31, 1:58 AM
Subscribers

Details

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.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ed retitled this revision from to Make fstat() and friends work..
ed updated this object.
ed edited the test plan for this revision. (Show Details)
ed added reviewers: jonathan, mjg.
sys/compat/cloudabi/cloudabi_fd.c
398 ↗(On Diff #7225)

There is no need to do it like this, and the kernel is slowly moving towards removal of shared locking of the fd table.

You can do this locklessly just fine, take a look at fget_mmap.

Can't comment about the rest of the patch.

sys/compat/cloudabi/cloudabi_fd.c
398 ↗(On Diff #7225)

Thanks for the quick review!

My concern was that if I do this without locks, I would not be able to get the rights of the file descriptor without a race, right?

Rework fd_stat_get() to not hold the table lock.

sys/compat/cloudabi/cloudabi_fd.c
398 ↗(On Diff #7234)

Does this look better?

mjg edited edge metadata.
mjg added inline comments.
sys/compat/cloudabi/cloudabi_fd.c
398 ↗(On Diff #7234)

Looks good, thanks.

Can't comment on the rest of the patch, ack on this.

This revision is now accepted and ready to land.Jul 23 2015, 11:32 PM
ed edited edge metadata.

For consistency, also add stat().

This revision now requires review to proceed.Jul 24 2015, 7:53 AM
ed edited edge metadata.

Also update the manual page to reflect the changes in behaviour.

ed edited edge metadata.

Remove manual page change, as it was intended for D3039.

This revision was automatically updated to reflect the committed changes.