Author: ed
Date: Sat Aug  1 07:51:48 2015
New Revision: 286147
URL: https://svnweb.freebsd.org/changeset/base/286147

Log:
  Allow CloudABI processes to create shared memory objects.
  
  Summary:
  Use the newly created `kern_shm_open()` function to create objects with
  just the rights that are actually needed.
  
  Reviewers: jhb, kib
  
  Subscribers: imp
  
  Differential Revision: https://reviews.freebsd.org/D3260

Modified:
  head/sys/compat/cloudabi/cloudabi_fd.c

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==============================================================================
--- head/sys/compat/cloudabi/cloudabi_fd.c      Sat Aug  1 07:21:14 2015        
(r286146)
+++ head/sys/compat/cloudabi/cloudabi_fd.c      Sat Aug  1 07:51:48 2015        
(r286147)
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/capsicum.h>
 #include <sys/filedesc.h>
 #include <sys/proc.h>
+#include <sys/mman.h>
 #include <sys/socketvar.h>
 #include <sys/syscallsubr.h>
 #include <sys/sysproto.h>
@@ -97,11 +98,16 @@ int
 cloudabi_sys_fd_create1(struct thread *td,
     struct cloudabi_sys_fd_create1_args *uap)
 {
+       struct filecaps fcaps = {};
        struct socket_args socket_args = {
                .domain = AF_UNIX,
        };
 
        switch (uap->type) {
+       case CLOUDABI_FILETYPE_SHARED_MEMORY:
+               cap_rights_init(&fcaps.fc_rights, CAP_FSTAT, CAP_FTRUNCATE,
+                   CAP_MMAP_RWX);
+               return (kern_shm_open(td, SHM_ANON, O_RDWR, 0, &fcaps));
        case CLOUDABI_FILETYPE_SOCKET_DGRAM:
                socket_args.type = SOCK_DGRAM;
                return (sys_socket(td, &socket_args));
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to