From 06ec97a3f823f1f5d928fc9c2beb3a11c2c88487 Mon Sep 17 00:00:00 2001 From: Rahat Mahmood Date: Tue, 26 Mar 2019 16:15:55 -0700 Subject: Implement memfd_create. Memfds are simply anonymous tmpfs files with no associated mounts. Also implementing file seals, which Linux only implements for memfds at the moment. PiperOrigin-RevId: 240450031 Change-Id: I31de78b950101ae8d7a13d0e93fe52d98ea06f2f --- pkg/abi/linux/file.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'pkg/abi/linux/file.go') diff --git a/pkg/abi/linux/file.go b/pkg/abi/linux/file.go index e5a51a9fd..46b10ca97 100644 --- a/pkg/abi/linux/file.go +++ b/pkg/abi/linux/file.go @@ -236,3 +236,21 @@ var fileType = abi.ValueSet{ ModeCharacterDevice: "S_IFCHR", ModeNamedPipe: "S_IFIFO", } + +// Constants for memfd_create(2). Source: include/uapi/linux/memfd.h +const ( + MFD_CLOEXEC = 0x0001 + MFD_ALLOW_SEALING = 0x0002 +) + +// Constants related to file seals. Source: include/uapi/{asm-generic,linux}/fcntl.h +const ( + F_LINUX_SPECIFIC_BASE = 1024 + F_ADD_SEALS = F_LINUX_SPECIFIC_BASE + 9 + F_GET_SEALS = F_LINUX_SPECIFIC_BASE + 10 + + F_SEAL_SEAL = 0x0001 // Prevent further seals from being set. + F_SEAL_SHRINK = 0x0002 // Prevent file from shrinking. + F_SEAL_GROW = 0x0004 // Prevent file from growing. + F_SEAL_WRITE = 0x0008 // Prevent writes. +) -- cgit v1.2.3