Lines Matching refs:fd
32 #include "fd-util.h"
41 int fd;
69 fd = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
70 if (fd < 0)
73 return fd;
76 int memfd_map(int fd, uint64_t offset, size_t size, void **p) {
80 assert(fd >= 0);
84 sealed = memfd_get_sealed(fd);
89 q = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, offset);
91 q = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset);
100 int memfd_set_sealed(int fd) {
103 assert(fd >= 0);
105 r = fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE | F_SEAL_SEAL);
112 int memfd_get_sealed(int fd) {
115 assert(fd >= 0);
117 r = fcntl(fd, F_GET_SEALS);
124 int memfd_get_size(int fd, uint64_t *sz) {
128 assert(fd >= 0);
131 r = fstat(fd, &stat);
139 int memfd_set_size(int fd, uint64_t sz) {
142 assert(fd >= 0);
144 r = ftruncate(fd, sz);
152 _cleanup_close_ int fd = -1;
158 fd = memfd_new(name);
159 if (fd < 0)
160 return fd;
162 r = memfd_set_size(fd, sz);
166 r = memfd_map(fd, 0, sz, p);
170 r = fd;
171 fd = -1;