From patchwork Tue Mar 13 11:42:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 131431 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp619064ljb; Tue, 13 Mar 2018 04:42:15 -0700 (PDT) X-Google-Smtp-Source: AG47ELvUfgOveKkEU9AM0lJ1hubEBBCeHwadajvbDM6MGtuthnqziEQtBcjoA9uk1/Y0XvPQDQhl X-Received: by 2002:a17:902:bb83:: with SMTP id m3-v6mr265180pls.235.1520941335603; Tue, 13 Mar 2018 04:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520941335; cv=none; d=google.com; s=arc-20160816; b=XAcfYkX/qwZY+aUylV03J6nSrroS9ME+vBzfHbtMbypXsBmB84SwZ+q+WA5ki+YzXd zPM93AFZrKtoctHgz0Ssvk4uiwYZ8WJO6cyTM6duxfqQYHKWwcKyt5YK41iYQAZmBDtR ZRI1hlCAc27M2BxDSDfSWCMzZXAS/bdMq/LFUDVlXf8P9j9SF0F9bBvEm5xjXSk4HHq1 MSwKV1LONnc7IP/nAXfw4qC0a8yznyyI6HBdmDeJzl+nMH1yRTqRxFn+/50IJf7FK1d6 DpPgHmj5gG23Az63qlrARUXJ5NcqikbG5DKQSRomrwia2/LSOgxkPgUUX5Y9oiSfMe49 F1PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=mQ8zbWENCu2CDUgwSwEKEIrJu0LNsZ1EwdmZYLMq7R0=; b=LuSVH/NlRZIyDOSLrvPHatquq5ULjWofYbWMGMtFfFDM9i6vBtLGX/Il3QbcnRVLdi 45cWJ5/91Kmn8sjk1RKrbAueQkRzTBDK0HlhG3nbIyU0VPsWiI8vz2SBmwy5kVyxB/XN uKBrlaioLYdJ/ZAL8vDyp+pI0BMVn4tQdv/5wwW8NeQTm03/DC0Jw9wUJBZVWWaT/Jeo qDPMEq3wwAKbRzlmDSWNduwINKb+AV3Do8HK3VAMdTLXnH54IUqZmjduUcX28dQcklZL e1pBCiWv4l4lSyShy7Lvw1JBugJyOZSryk5TIDELXSUBViHq8p3sfIilCwThS6S/w/F3 ftVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=idlzWbUR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 80si23648pfn.73.2018.03.13.04.42.15; Tue, 13 Mar 2018 04:42:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=idlzWbUR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932957AbeCMLmM (ORCPT + 28 others); Tue, 13 Mar 2018 07:42:12 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:43352 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932669AbeCMLmK (ORCPT ); Tue, 13 Mar 2018 07:42:10 -0400 Received: by mail-lf0-f66.google.com with SMTP id q69-v6so28220649lfi.10 for ; Tue, 13 Mar 2018 04:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mQ8zbWENCu2CDUgwSwEKEIrJu0LNsZ1EwdmZYLMq7R0=; b=idlzWbURkGDxKk4ForsAuhpxnRcwyU0+5CnojegklP8YzFS4gSeeVDblZiz0zytxod +SA8kjPS88Bc6mMiUtMB4szo1yxUefB9MHY0xOdBvJMbiWAYe7It0QbfD/R8Bu8nZojB w9jZPbPJC4unrBtoa1oi+3w7iXDcSJn+8v45U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mQ8zbWENCu2CDUgwSwEKEIrJu0LNsZ1EwdmZYLMq7R0=; b=BVNXX5BFPaDeaf/zDaXpUVwOiLPyF3Bm8bfFfgtzvMc9nIcp60C4QHs6a1rOEhCph8 9hE56wQ4dte16G9gvTA8JukggAzJTZ6nHHxal/kX/nn5PqKHsJK+/+08Zla+s4VWx9KP 94Ea9BjNRSPERdNnJ4mNMmxBXacEkNIXSyl1NmRIGgZXLG5pySogg5+KmKiMBB0zP2JL TkL/+4vzsPx0oWitcNKslGwZm+AxfSFavSYxxfuObhXNfLtDFOP5SONxUN2+L+MnG25j 5+3V2pt7CgjYGBU/OGRH5VUZhT3ExPU4/hdw3EfGKf8e4H6CIexuLIrP7Kd+EHTPYIrz HNjQ== X-Gm-Message-State: AElRT7HJvZ97vEWEeZn7OC5h6yel2OPlGenYa11+blOWttFSsFdyQXAG JpYunULPdJAn14vNNHksiN67gg== X-Received: by 2002:a19:9a0a:: with SMTP id c10-v6mr274353lfe.30.1520941329259; Tue, 13 Mar 2018 04:42:09 -0700 (PDT) Received: from localhost (c-073070d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.48.7]) by smtp.gmail.com with ESMTPSA id x23sm4816ljc.33.2018.03.13.04.42.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 04:42:08 -0700 (PDT) From: Anders Roxell To: shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, dh.herrmann@gmail.com, Anders Roxell Subject: [PATCH 1/2] selftests/memfd/memfd_test.c: fix implicit declaration Date: Tue, 13 Mar 2018 12:42:04 +0100 Message-Id: <20180313114205.27714-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc warns about implicit declaration. gcc -D_FILE_OFFSET_BITS=64 -I../../../../include/uapi/ -I../../../../include/ -I../../../../usr/include/ memfd_test.c common.o -o memfd_test memfd_test.c: In function ‘mfd_assert_get_seals’: memfd_test.c:74:6: warning: implicit declaration of function ‘fcntl’ [-Wimplicit-function-declaration] r = fcntl(fd, F_GET_SEALS); ^~~~~ memfd_test.c: In function ‘mfd_assert_open’: memfd_test.c:197:6: warning: implicit declaration of function ‘open’ [-Wimplicit-function-declaration] r = open(buf, flags, mode); ^~~~ memfd_test.c: In function ‘mfd_assert_write’: memfd_test.c:328:6: warning: implicit declaration of function ‘fallocate’ [-Wimplicit-function-declaration] r = fallocate(fd, ^~~~~~~~~ In the current code, we include the headers that the functions want according to the man pages, and we add some defines that will be used if they isn't found in glibc. The defines was added into the kernel source in kernel >= 3.16 and glibc requires kernel header files >= 3.2. Fixes: 4f5ce5e8d7e2 ("selftests: add memfd_create() + sealing tests") Signed-off-by: Anders Roxell --- tools/testing/selftests/memfd/memfd_test.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index 10baa1652fc2..0dbeb29c094c 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -14,13 +13,37 @@ #include #include #include +#include #include #include #include +#include #include #include "common.h" +#ifndef F_LINUX_SPECIFIC_BASE +# define F_LINUX_SPECIFIC_BASE 1024 +#endif +#ifndef F_ADD_SEALS +# define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) +#endif +#ifndef F_GET_SEALS +# define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) +#endif +#ifndef F_SEAL_SEAL +# define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ +#endif +#ifndef F_SEAL_SHRINK +# define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ +#endif +#ifndef F_SEAL_GROW +# define F_SEAL_GROW 0x0004 /* prevent file from growing */ +#endif +#ifndef F_SEAL_WRITE +# define F_SEAL_WRITE 0x0008 /* prevent writes */ +#endif + #define MEMFD_STR "memfd:" #define MEMFD_HUGE_STR "memfd-hugetlb:" #define SHARED_FT_STR "(shared file-table)" From patchwork Tue Mar 13 11:42:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 131432 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp619216ljb; Tue, 13 Mar 2018 04:42:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELv2DAzRyqTJgUwxKYJroPLKd34uq2PRGi0qzgrUhLfKs7LEVR3vnhCe2SnCn8jIVRLVxE1L X-Received: by 10.98.144.146 with SMTP id q18mr294419pfk.103.1520941343625; Tue, 13 Mar 2018 04:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520941343; cv=none; d=google.com; s=arc-20160816; b=K5VqdxRAWF16ErIc2hVIJaHkp6M2mKBQOoYsUyc5XCGiLrLypH2EgMcrma7ioridEX vq+sOlTYQQ/ga1O+tFgsksE8Fc7jKSPJXusiBYBa8weqP2RLzeuWgR9txIejtTI+W9zv 5cs7D2rosTqxthpIhV14SyP8UDqjB7RNPv08MwSz3CYTtw2qKfksoYcHUA88bxEGbZxj kjH+pAXsRY/ogiUy5aIPDCbvfjc62iNqjPs2fjp3n1HgKifR9r095Ot8PJc1MsH/kjIw Wu5XAm/fXcsCd8HNAYoym5mchWuf0nfOBY6FH7k5NA9D7pKARX9v/izQgWIS5kW5GVVo vdyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=z7eOzM4NjLXkwpOxgvzFW4bfF9fIxg4RofWBiydaSIc=; b=Ck3B/jDBrnMF9jJiiYwe58Tep5Td0wkTIpjlTJKdasVExfajlCZuscCXLcCqSIxuZ6 2eE8pSoEjW4ja6MSOf9YjIwyYSKlay5voO3CDtOLtEWHtbw6OcWksOymF+3CfRr6Zibn 0xfyR4LaxHyodR/LpWmh/uJtLZ/UDYnBYxtAgDwt8gzvIWEJrRgX74sWMqpETVNc0eym VC5/DxVzoRCnMwpAUKzRwdQhNbScf3kdKNdZHmE16hjUNxBVgXl/Tb31/hQoahLpQTll Mz3svEoweLbQoXNrLwnlCedfJy92ahX0dDUhwfLROQ08b1TQdmGQsfPTjFx9W2q9tbTf BWCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YllNYYuT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 80si23648pfn.73.2018.03.13.04.42.23; Tue, 13 Mar 2018 04:42:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YllNYYuT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932995AbeCMLmU (ORCPT + 28 others); Tue, 13 Mar 2018 07:42:20 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33819 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932669AbeCMLmP (ORCPT ); Tue, 13 Mar 2018 07:42:15 -0400 Received: by mail-lf0-f65.google.com with SMTP id l191-v6so28259479lfe.1 for ; Tue, 13 Mar 2018 04:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z7eOzM4NjLXkwpOxgvzFW4bfF9fIxg4RofWBiydaSIc=; b=YllNYYuTheZeY0dyvxHmxlqU7ZLuXWGyP1HGyJFxdLjNHgzOBd41GqMPQKS4E7ZclK TdtqefA4wCWTPLwJxdxWSxmjgPzpdFm199qLic6uKnghvUfsbmXJRhLbb8etONC7og/w cZZGi+aZ9HaaccgIxnL5oFPJgUG+zwj/kGPKE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z7eOzM4NjLXkwpOxgvzFW4bfF9fIxg4RofWBiydaSIc=; b=LFdpvDpUmejrUq4FngLABTzluV9c5ZA2oqDqDs4rTPb1DcPETVe3SsGQF2DkvCgVtB Njbcb2p91mPuBIzyIzetMQWikVh/jSJlNh/RLA9zvtCB4xPmyJUw96Xl66aEtgiVsjsR E1mTOM8ex75gr4EwhRxpL99pg0P4BwoRjrr4h9LfS/ZEsG2Te5B6vB6h5tflaKuRnmGd gkg+79xv1iTu9t1A406a0/AXSx8+M+aFDRTXBCVn7Diuu97qHUD41/RB2rHnSXiJ0Vmw AjO6MGCmvdPVKKAjvBHM7kAz+zga3+IRnoXjtwPoo2Yt0qrFirTqdX+s6zTfduzesDD4 3Drw== X-Gm-Message-State: AElRT7EC8KY6xLuUeUIIiMRobY85z4hm7KOrQ0I3gqfag6A+wrKY0ydD GC1J2BGa/rBSFDOD6ygdEbn1nw== X-Received: by 2002:a19:fe2:: with SMTP id 95-v6mr254738lfp.13.1520941333593; Tue, 13 Mar 2018 04:42:13 -0700 (PDT) Received: from localhost (c-073070d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.48.7]) by smtp.gmail.com with ESMTPSA id q24-v6sm5431lff.32.2018.03.13.04.42.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 04:42:12 -0700 (PDT) From: Anders Roxell To: shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, dh.herrmann@gmail.com, Anders Roxell Subject: [PATCH 2/2] selftests/memfd/fuse_test: fix implicit declaration Date: Tue, 13 Mar 2018 12:42:05 +0100 Message-Id: <20180313114205.27714-2-anders.roxell@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180313114205.27714-1-anders.roxell@linaro.org> References: <20180313114205.27714-1-anders.roxell@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc warns about implicit declaration. gcc -D_FILE_OFFSET_BITS=64 -I../../../../include/uapi/ -I../../../../include/ -I../../../../usr/include/ fuse_test.c common.o -o fuse_test fuse_test.c: In function ‘mfd_assert_get_seals’: fuse_test.c:67:6: warning: implicit declaration of function ‘fcntl’ [-Wimplicit-function-declaration] r = fcntl(fd, F_GET_SEALS); ^~~~~ fuse_test.c: In function ‘main’: fuse_test.c:261:7: warning: implicit declaration of function ‘open’ [-Wimplicit-function-declaration] fd = open(argv[1], O_RDONLY | O_CLOEXEC); ^~~~ make: Leaving directory 'tools/testing/selftests/memfd' In the current code, we include the headers that the functions want according to the man pages, and we move common code for memfd to common.c. Moved F_ADD_SEALS and friends to memfd/common.h since both fuse_test and memfd_test uses them. Fixes: 87b2d44026e0 ("selftests: add memfd/sealing page-pinning tests") Signed-off-by: Anders Roxell --- tools/testing/selftests/memfd/common.c | 41 ++++++++++++++++++++- tools/testing/selftests/memfd/common.h | 26 +++++++++++++ tools/testing/selftests/memfd/fuse_test.c | 46 ++--------------------- tools/testing/selftests/memfd/memfd_test.c | 59 ------------------------------ 4 files changed, 70 insertions(+), 102 deletions(-) -- 2.11.0 diff --git a/tools/testing/selftests/memfd/common.c b/tools/testing/selftests/memfd/common.c index 8eb3d75f6e60..d1faee61782b 100644 --- a/tools/testing/selftests/memfd/common.c +++ b/tools/testing/selftests/memfd/common.c @@ -4,8 +4,10 @@ #include #include -#include #include +#include +#include +#include #include #include @@ -44,3 +46,40 @@ int sys_memfd_create(const char *name, unsigned int flags) return syscall(__NR_memfd_create, name, flags); } + +unsigned int mfd_assert_get_seals(int fd) +{ + int r; + + r = fcntl(fd, F_GET_SEALS); + if (r < 0) { + printf("GET_SEALS(%d) failed: %m\n", fd); + abort(); + } + + return (unsigned int)r; +} + +void mfd_assert_add_seals(int fd, unsigned int seals) +{ + int r; + unsigned int s; + + s = mfd_assert_get_seals(fd); + r = fcntl(fd, F_ADD_SEALS, seals); + if (r < 0) { + printf("ADD_SEALS(%d, %u -> %u) failed: %m\n", fd, s, seals); + abort(); + } +} + +void mfd_assert_has_seals(int fd, unsigned int seals) +{ + unsigned int s; + + s = mfd_assert_get_seals(fd); + if (s != seals) { + printf("%u != %u = GET_SEALS(%d)\n", seals, s, fd); + abort(); + } +} diff --git a/tools/testing/selftests/memfd/common.h b/tools/testing/selftests/memfd/common.h index 522d2c630bd8..333baf79ffc4 100644 --- a/tools/testing/selftests/memfd/common.h +++ b/tools/testing/selftests/memfd/common.h @@ -1,9 +1,35 @@ #ifndef COMMON_H_ #define COMMON_H_ +#ifndef F_LINUX_SPECIFIC_BASE +# define F_LINUX_SPECIFIC_BASE 1024 +#endif +#ifndef F_ADD_SEALS +# define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) +#endif +#ifndef F_GET_SEALS +# define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) +#endif +#ifndef F_SEAL_SEAL +# define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ +#endif +#ifndef F_SEAL_SHRINK +# define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ +#endif +#ifndef F_SEAL_GROW +# define F_SEAL_GROW 0x0004 /* prevent file from growing */ +#endif +#ifndef F_SEAL_WRITE +# define F_SEAL_WRITE 0x0008 /* prevent writes */ +#endif + extern int hugetlbfs_test; unsigned long default_huge_page_size(void); int sys_memfd_create(const char *name, unsigned int flags); +void mfd_assert_add_seals(int fd, unsigned int seals); +void mfd_assert_has_seals(int fd, unsigned int seals); +unsigned int mfd_assert_get_seals(int fd); + #endif diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c index b018e835737d..70df77ac1386 100644 --- a/tools/testing/selftests/memfd/fuse_test.c +++ b/tools/testing/selftests/memfd/fuse_test.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -28,9 +27,11 @@ #include #include #include +#include #include #include #include +#include #include #include "common.h" @@ -60,49 +61,10 @@ static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags) return fd; } -static __u64 mfd_assert_get_seals(int fd) +static int mfd_busy_add_seals(int fd, unsigned int seals) { long r; - - r = fcntl(fd, F_GET_SEALS); - if (r < 0) { - printf("GET_SEALS(%d) failed: %m\n", fd); - abort(); - } - - return r; -} - -static void mfd_assert_has_seals(int fd, __u64 seals) -{ - __u64 s; - - s = mfd_assert_get_seals(fd); - if (s != seals) { - printf("%llu != %llu = GET_SEALS(%d)\n", - (unsigned long long)seals, (unsigned long long)s, fd); - abort(); - } -} - -static void mfd_assert_add_seals(int fd, __u64 seals) -{ - long r; - __u64 s; - - s = mfd_assert_get_seals(fd); - r = fcntl(fd, F_ADD_SEALS, seals); - if (r < 0) { - printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", - fd, (unsigned long long)s, (unsigned long long)seals); - abort(); - } -} - -static int mfd_busy_add_seals(int fd, __u64 seals) -{ - long r; - __u64 s; + unsigned int s; r = fcntl(fd, F_GET_SEALS); if (r < 0) diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index 0dbeb29c094c..af722a639a64 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -22,28 +22,6 @@ #include "common.h" -#ifndef F_LINUX_SPECIFIC_BASE -# define F_LINUX_SPECIFIC_BASE 1024 -#endif -#ifndef F_ADD_SEALS -# define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) -#endif -#ifndef F_GET_SEALS -# define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) -#endif -#ifndef F_SEAL_SEAL -# define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ -#endif -#ifndef F_SEAL_SHRINK -# define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ -#endif -#ifndef F_SEAL_GROW -# define F_SEAL_GROW 0x0004 /* prevent file from growing */ -#endif -#ifndef F_SEAL_WRITE -# define F_SEAL_WRITE 0x0008 /* prevent writes */ -#endif - #define MEMFD_STR "memfd:" #define MEMFD_HUGE_STR "memfd-hugetlb:" #define SHARED_FT_STR "(shared file-table)" @@ -90,43 +68,6 @@ static void mfd_fail_new(const char *name, unsigned int flags) } } -static unsigned int mfd_assert_get_seals(int fd) -{ - int r; - - r = fcntl(fd, F_GET_SEALS); - if (r < 0) { - printf("GET_SEALS(%d) failed: %m\n", fd); - abort(); - } - - return (unsigned int)r; -} - -static void mfd_assert_has_seals(int fd, unsigned int seals) -{ - unsigned int s; - - s = mfd_assert_get_seals(fd); - if (s != seals) { - printf("%u != %u = GET_SEALS(%d)\n", seals, s, fd); - abort(); - } -} - -static void mfd_assert_add_seals(int fd, unsigned int seals) -{ - int r; - unsigned int s; - - s = mfd_assert_get_seals(fd); - r = fcntl(fd, F_ADD_SEALS, seals); - if (r < 0) { - printf("ADD_SEALS(%d, %u -> %u) failed: %m\n", fd, s, seals); - abort(); - } -} - static void mfd_fail_add_seals(int fd, unsigned int seals) { int r;