From 0310b312a7e5dffcdf24ae835ed732f7a6a9c471 Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Tue, 14 Apr 2020 17:53:23 -0400 Subject: kernel-5.7.0-0.rc1.20200414git8632e9b5645b.1 This is an automated commit generated from the kernel-5.7.0-0.rc1.20200414git8632e9b5645b.1 tag in https://gitlab.com/cki-project/kernel-ark.git --- tests/memory/memfd_create/t_memfd_create.c | 106 ----------------------------- 1 file changed, 106 deletions(-) delete mode 100644 tests/memory/memfd_create/t_memfd_create.c (limited to 'tests/memory/memfd_create/t_memfd_create.c') diff --git a/tests/memory/memfd_create/t_memfd_create.c b/tests/memory/memfd_create/t_memfd_create.c deleted file mode 100644 index 4250d7174..000000000 --- a/tests/memory/memfd_create/t_memfd_create.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - * - */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include - -#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ -} while (0) - -int main(int argc, char *argv[]) -{ - int fd; - unsigned int seals; - char *addr; - char *name, *seals_arg; - ssize_t len; - char* message = "this is a test message for memfd\n"; - - if (argc < 3) { - fprintf(stderr, "%s name size [seals]\n", argv[0]); - fprintf(stderr, "\t'seals' can contain any of the " - "following characters:\n"); - fprintf(stderr, "\t\tg - F_SEAL_GROW\n"); - fprintf(stderr, "\t\ts - F_SEAL_SHRINK\n"); - fprintf(stderr, "\t\tw - F_SEAL_WRITE\n"); - fprintf(stderr, "\t\tS - F_SEAL_SEAL\n"); - exit(EXIT_FAILURE); - } - - name = argv[1]; - len = atoi(argv[2]); - seals_arg = argv[3]; - - /* Create an anonymous file in tmpfs; allow seals to be - placed on the file */ - - fd = syscall(SYS_memfd_create, name, MFD_ALLOW_SEALING); - if (fd == -1) - errExit("memfd_create"); - - /* Size the file as specified on the command line */ - - if (ftruncate(fd, len) == -1) - errExit("truncate"); - - if (write(fd, message, strlen(message)) <= 0) - errExit("write"); - - /* Code to map the file and populate the mapping with data - omitted */ - - /* If a 'seals' command-line argument was supplied, set some - seals on the file */ - - if (seals_arg != NULL) { - seals = 0; - - if (strchr(seals_arg, 'g') != NULL) - seals |= F_SEAL_GROW; - if (strchr(seals_arg, 's') != NULL) - seals |= F_SEAL_SHRINK; - if (strchr(seals_arg, 'w') != NULL) - seals |= F_SEAL_WRITE; - if (strchr(seals_arg, 'S') != NULL) - seals |= F_SEAL_SEAL; - - if (fcntl(fd, F_ADD_SEALS, seals) == -1) - errExit("fcntl"); - } - - /* Output the pathname of (a symbolic link to) the file - created by memfd_create() */ - - printf("/proc/%ld/fd/%d\n", (long) getpid(), fd); - - fflush(stdout); - - /* Keep running, so that the file created by memfd_create() - continues to exist */ - - pause(); - - exit(EXIT_SUCCESS); -} - -- cgit