Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/gen/memfd_create.c
- This file was copied from lib/libc/sys/shm_open.c.
Show All 22 Lines | |||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/filio.h> | #include <sys/filio.h> | ||||
#include <sys/mman.h> | #include <sys/mman.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <limits.h> | |||||
#include <stdlib.h> | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | |||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
emaste: are any of these headers no longer needed in one or the other of these files? | |||||
#include "libc_private.h" | #include "libc_private.h" | ||||
__weak_reference(shm_open, _shm_open); | |||||
__weak_reference(shm_open, __sys_shm_open); | |||||
#define MEMFD_NAME_PREFIX "memfd:" | #define MEMFD_NAME_PREFIX "memfd:" | ||||
int | |||||
shm_open(const char *path, int flags, mode_t mode) | |||||
{ | |||||
return (__sys_shm_open2(path, flags | O_CLOEXEC, mode, 0, NULL)); | |||||
} | |||||
int | |||||
shm_create_largepage(const char *path, int flags, int psind, int alloc_policy, | |||||
mode_t mode) | |||||
{ | |||||
struct shm_largepage_conf slc; | |||||
int error, fd, saved_errno; | |||||
fd = __sys_shm_open2(path, flags | O_CREAT, mode, SHM_LARGEPAGE, NULL); | |||||
if (fd == -1) | |||||
return (-1); | |||||
memset(&slc, 0, sizeof(slc)); | |||||
slc.psind = psind; | |||||
slc.alloc_policy = alloc_policy; | |||||
error = ioctl(fd, FIOSSHMLPGCNF, &slc); | |||||
if (error == -1) { | |||||
saved_errno = errno; | |||||
close(fd); | |||||
errno = saved_errno; | |||||
return (-1); | |||||
} | |||||
return (fd); | |||||
} | |||||
/* | /* | ||||
* The path argument is passed to the kernel, but the kernel doesn't currently | * The path argument is passed to the kernel, but the kernel doesn't currently | ||||
* do anything with it. Linux exposes it in linprocfs for debugging purposes | * do anything with it. Linux exposes it in linprocfs for debugging purposes | ||||
* only, but our kernel currently will not do the same. | * only, but our kernel currently will not do the same. | ||||
*/ | */ | ||||
int | int | ||||
memfd_create(const char *name, unsigned int flags) | memfd_create(const char *name, unsigned int flags) | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
are any of these headers no longer needed in one or the other of these files?