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)"