aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/cloudabi/cloudabi_fd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/cloudabi/cloudabi_fd.c')
-rw-r--r--sys/compat/cloudabi/cloudabi_fd.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/compat/cloudabi/cloudabi_fd.c b/sys/compat/cloudabi/cloudabi_fd.c
index 1fed2e7dcf4f..f16d66855ad4 100644
--- a/sys/compat/cloudabi/cloudabi_fd.c
+++ b/sys/compat/cloudabi/cloudabi_fd.c
@@ -290,7 +290,7 @@ cloudabi_convert_filetype(const struct file *fp)
}
/* Removes rights that conflict with the file descriptor type. */
-static void
+void
cloudabi_remove_conflicting_rights(cloudabi_filetype_t filetype,
cloudabi_rights_t *base, cloudabi_rights_t *inheriting)
{
@@ -499,6 +499,25 @@ cloudabi_sys_fd_stat_get(struct thread *td,
return (copyout(&fsb, (void *)uap->buf, sizeof(fsb)));
}
+/* Converts CloudABI rights to a set of Capsicum capabilities. */
+int
+cloudabi_convert_rights(cloudabi_rights_t in, cap_rights_t *out)
+{
+
+ cap_rights_init(out);
+#define MAPPING(cloudabi, ...) do { \
+ if (in & (cloudabi)) { \
+ cap_rights_set(out, ##__VA_ARGS__); \
+ in &= ~(cloudabi); \
+ } \
+} while (0);
+ RIGHTS_MAPPINGS
+#undef MAPPING
+ if (in != 0)
+ return (ENOTCAPABLE);
+ return (0);
+}
+
int
cloudabi_sys_fd_stat_put(struct thread *td,
struct cloudabi_sys_fd_stat_put_args *uap)