From patchwork Wed May 15 11:33:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VsD/b/Lm; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=615fRiQv; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VsD/b/Lm; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=615fRiQv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWMn4lF4z1yfq for ; Wed, 15 May 2024 21:34:12 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 659A23CF7E8 for ; Wed, 15 May 2024 13:34:10 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 0105B3CF771 for ; Wed, 15 May 2024 13:33:49 +0200 (CEST) Authentication-Results: in-6.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.130; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 5319F1405178 for ; Wed, 15 May 2024 13:33:48 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7A0FA33AD5; Wed, 15 May 2024 11:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GPBu/Kwt4gjg3JOKzrYBzfQhrZ0phXwv7ub7nBkXCAU=; b=VsD/b/LmQzS05pupk39ZmBa/xJFRLiJYpQnAvpxJYcEzMlWfyBkGdUSO+YVycw0S+ZCcNt 4zyFSoOMQKRULexKOGNEXUCJKRVu/4ly/hCRLByqW0lDYMMRXmVL4Gw7Gv43/z7syVn8YS XxpNiDytnvq7pAXfMrEtyARJWdtg2bs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GPBu/Kwt4gjg3JOKzrYBzfQhrZ0phXwv7ub7nBkXCAU=; b=615fRiQvKNqlJsaaGwgcKgRRAzpEsuZxuZ04RjLZQhtyMsM3lSFLfLlUfVQhoox25zIB++ 5wXcnHQPfd7lGmDg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="VsD/b/Lm"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=615fRiQv DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GPBu/Kwt4gjg3JOKzrYBzfQhrZ0phXwv7ub7nBkXCAU=; b=VsD/b/LmQzS05pupk39ZmBa/xJFRLiJYpQnAvpxJYcEzMlWfyBkGdUSO+YVycw0S+ZCcNt 4zyFSoOMQKRULexKOGNEXUCJKRVu/4ly/hCRLByqW0lDYMMRXmVL4Gw7Gv43/z7syVn8YS XxpNiDytnvq7pAXfMrEtyARJWdtg2bs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GPBu/Kwt4gjg3JOKzrYBzfQhrZ0phXwv7ub7nBkXCAU=; b=615fRiQvKNqlJsaaGwgcKgRRAzpEsuZxuZ04RjLZQhtyMsM3lSFLfLlUfVQhoox25zIB++ 5wXcnHQPfd7lGmDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5616213A62; Wed, 15 May 2024 11:33:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KL4GE5ydRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:48 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:29 +0200 Message-Id: <20240515113338.554-2-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 7A0FA33AD5 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email, suse.de:dkim, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-6.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-6.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 01/10] Add SAFE_STATX macro X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Signed-off-by: Andrea Cervesato --- include/tst_safe_macros.h | 7 +++++++ lib/tst_safe_macros.c | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h index 8de8ef106..43ff50a33 100644 --- a/include/tst_safe_macros.h +++ b/include/tst_safe_macros.h @@ -503,4 +503,11 @@ int safe_sscanf(const char *file, const int lineno, const char *restrict buffer, #define SAFE_SSCANF(buffer, format, ...) \ safe_sscanf(__FILE__, __LINE__, (buffer), (format), ##__VA_ARGS__) +struct statx; +int safe_statx(const char *file, const int lineno, + int dirfd, const char *pathname, int flags, unsigned int mask, + struct statx *buf); +#define SAFE_STATX(dirfd, pathname, flags, mask, buf) \ + safe_statx(__FILE__, __LINE__, (dirfd), (pathname), (flags), (mask), (buf)) + #endif /* TST_SAFE_MACROS_H__ */ diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c index 39b8cc924..f50a7bcc2 100644 --- a/lib/tst_safe_macros.c +++ b/lib/tst_safe_macros.c @@ -20,6 +20,7 @@ #include "tst_safe_macros.h" #include "lapi/personality.h" #include "lapi/pidfd.h" +#include "lapi/stat.h" int safe_access(const char *file, const int lineno, const char *pathname, int mode) @@ -710,3 +711,24 @@ int safe_mprotect(const char *file, const int lineno, return rval; } + +int safe_statx(const char *file, const int lineno, + int dirfd, const char *pathname, int flags, unsigned int mask, + struct statx *buf) +{ + int rval; + + rval = statx(dirfd, pathname, flags, mask, buf); + + if (rval == -1) { + tst_brk_(file, lineno, TBROK | TERRNO, + "statx(%d,%s,%d,%u,%p) failed", dirfd, pathname, flags, mask, buf); + } else if (rval) { + tst_brk_(file, lineno, TBROK | TERRNO, + "Invalid statx(%d,%s,%d,%u,%p) return value %d", + dirfd, pathname, flags, mask, buf, + rval); + } + + return rval; +} From patchwork Wed May 15 11:33:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oBIlAOEp; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=JkmfBS+0; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oBIlAOEp; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=JkmfBS+0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWQv4nz3z1ymw for ; Wed, 15 May 2024 21:36:55 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2CC633CF904 for ; Wed, 15 May 2024 13:36:53 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 081533CF85A for ; Wed, 15 May 2024 13:33:58 +0200 (CEST) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 5D6FB6067C0 for ; Wed, 15 May 2024 13:33:49 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AE387205DE; Wed, 15 May 2024 11:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e8gMqyoX+j4jyjVTOX4f33XCpw7DAsOHvXUBGu/ivDk=; b=oBIlAOEprhQqEfBQTwT+aBzQQAqI5oV54rxoqfRKpuPAUhmks0T1blzQGvbPjSitxTP5uI 7C58JE2py6fldOWS9aUpsO8w+CR5RFrR6LqG41NFnlNJV9XzkS8aGWoqZAIbJKrU3YTwDf VnEC7exVlsGCdHjb0kB7Op8ecu+jYpM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e8gMqyoX+j4jyjVTOX4f33XCpw7DAsOHvXUBGu/ivDk=; b=JkmfBS+0eWoX5y4QcNIquL88grOak45zhOQKIl2UCFZVU30Kc7/0H++f1C7TLQlXr0lW0/ P9+6noVyRyj9zaCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=oBIlAOEp; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=JkmfBS+0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e8gMqyoX+j4jyjVTOX4f33XCpw7DAsOHvXUBGu/ivDk=; b=oBIlAOEprhQqEfBQTwT+aBzQQAqI5oV54rxoqfRKpuPAUhmks0T1blzQGvbPjSitxTP5uI 7C58JE2py6fldOWS9aUpsO8w+CR5RFrR6LqG41NFnlNJV9XzkS8aGWoqZAIbJKrU3YTwDf VnEC7exVlsGCdHjb0kB7Op8ecu+jYpM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e8gMqyoX+j4jyjVTOX4f33XCpw7DAsOHvXUBGu/ivDk=; b=JkmfBS+0eWoX5y4QcNIquL88grOak45zhOQKIl2UCFZVU30Kc7/0H++f1C7TLQlXr0lW0/ P9+6noVyRyj9zaCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 86C651372E; Wed, 15 May 2024 11:33:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +AkHH5ydRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:48 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:30 +0200 Message-Id: <20240515113338.554-3-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: AE387205DE X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email, suse.de:dkim, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, configure.ac:url] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 02/10] Add listmount/statmount fallback declarations X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Signed-off-by: Andrea Cervesato --- configure.ac | 5 +++ include/lapi/mount.h | 70 ++++++++++++++++++++++++++++++ include/lapi/stat.h | 10 ++++- include/lapi/syscalls/aarch64.in | 2 + include/lapi/syscalls/arc.in | 2 + include/lapi/syscalls/arm.in | 2 + include/lapi/syscalls/hppa.in | 2 + include/lapi/syscalls/i386.in | 2 + include/lapi/syscalls/ia64.in | 2 + include/lapi/syscalls/loongarch.in | 2 + include/lapi/syscalls/mips_n32.in | 2 + include/lapi/syscalls/mips_n64.in | 2 + include/lapi/syscalls/mips_o32.in | 2 + include/lapi/syscalls/powerpc.in | 2 + include/lapi/syscalls/powerpc64.in | 2 + include/lapi/syscalls/s390.in | 2 + include/lapi/syscalls/s390x.in | 2 + include/lapi/syscalls/sh.in | 2 + include/lapi/syscalls/sparc.in | 2 + include/lapi/syscalls/sparc64.in | 2 + include/lapi/syscalls/x86_64.in | 2 + 21 files changed, 120 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1f7aa70bd..95c91c6af 100644 --- a/configure.ac +++ b/configure.ac @@ -113,6 +113,7 @@ AC_CHECK_FUNCS_ONCE([ \ io_uring_register \ io_uring_enter \ kcmp \ + listmount \ mallinfo \ mallinfo2 \ mallopt \ @@ -142,6 +143,7 @@ AC_CHECK_FUNCS_ONCE([ \ setns \ sigpending \ splice \ + statmount \ statx \ stime \ sync_file_range \ @@ -232,6 +234,9 @@ AC_CHECK_TYPES([struct mount_attr],,,[ #endif ]) +AC_CHECK_TYPES([struct mnt_id_req],,,[#include ]) +AC_CHECK_TYPES([struct statmount],,,[#include ]) + # Tools knobs # Bash diff --git a/include/lapi/mount.h b/include/lapi/mount.h index c1af944fe..01a0fd2d6 100644 --- a/include/lapi/mount.h +++ b/include/lapi/mount.h @@ -2,12 +2,15 @@ /* * Copyright (c) Linux Test Project, 2015-2022 * Copyright (c) 2015 Cui Bixuan + * Copyright (C) 2024 SUSE LLC Andrea Cervesato */ #ifndef LAPI_MOUNT_H__ #define LAPI_MOUNT_H__ +#include #include +#include "config.h" #ifndef MS_REC # define MS_REC 16384 @@ -37,4 +40,71 @@ # define MS_NOSYMFOLLOW 256 #endif +#ifndef HAVE_STRUCT_MNT_ID_REQ +struct mnt_id_req { + uint32_t size; + uint32_t spare; + uint64_t mnt_id; + uint64_t param; +}; +#endif + +#ifndef HAVE_STRUCT_STATMOUNT +struct statmount { + uint32_t size; + uint32_t __spare1; + uint64_t mask; + uint32_t sb_dev_major; + uint32_t sb_dev_minor; + uint64_t sb_magic; + uint32_t sb_flags; + uint32_t fs_type; + uint64_t mnt_id; + uint64_t mnt_parent_id; + uint32_t mnt_id_old; + uint32_t mnt_parent_id_old; + uint64_t mnt_attr; + uint64_t mnt_propagation; + uint64_t mnt_peer_group; + uint64_t mnt_master; + uint64_t propagate_from; + uint32_t mnt_root; + uint32_t mnt_point; + uint64_t __spare2[50]; + char str[]; +}; +#endif + +#ifndef MNT_ID_REQ_SIZE_VER0 +# define MNT_ID_REQ_SIZE_VER0 24 +#endif + +#ifndef STATMOUNT_SB_BASIC +# define STATMOUNT_SB_BASIC 0x00000001U +#endif + +#ifndef STATMOUNT_MNT_BASIC +# define STATMOUNT_MNT_BASIC 0x00000002U +#endif + +#ifndef STATMOUNT_PROPAGATE_FROM +# define STATMOUNT_PROPAGATE_FROM 0x00000004U +#endif + +#ifndef STATMOUNT_MNT_ROOT +# define STATMOUNT_MNT_ROOT 0x00000008U +#endif + +#ifndef STATMOUNT_MNT_POINT +# define STATMOUNT_MNT_POINT 0x00000010U +#endif + +#ifndef STATMOUNT_FS_TYPE +# define STATMOUNT_FS_TYPE 0x00000020U +#endif + +#ifndef LSMT_ROOT +# define LSMT_ROOT 0xffffffffffffffff +#endif + #endif /* LAPI_MOUNT_H__ */ diff --git a/include/lapi/stat.h b/include/lapi/stat.h index 3606c9eb0..84dc76faf 100644 --- a/include/lapi/stat.h +++ b/include/lapi/stat.h @@ -95,7 +95,11 @@ struct statx { uint32_t stx_dev_major; uint32_t stx_dev_minor; /* 0x90 */ - uint64_t __spare2[14]; + __u64 stx_mnt_id; + __u32 stx_dio_mem_align; + __u32 stx_dio_offset_align; + /* 0xa0 */ + __u64 __spare3[12]; /* 0x100 */ }; #endif @@ -229,4 +233,8 @@ static inline int statx(int dirfd, const char *pathname, unsigned int flags, # define STATX_ATTR_VERITY 0x00100000 #endif +#ifndef STATX_MNT_ID_UNIQUE +# define STATX_MNT_ID_UNIQUE 0x00004000U +#endif + #endif /* LAPI_STAT_H__ */ diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in index 2cb6c2d87..3b32a3b2a 100644 --- a/include/lapi/syscalls/aarch64.in +++ b/include/lapi/syscalls/aarch64.in @@ -297,4 +297,6 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 _sysctl 1078 diff --git a/include/lapi/syscalls/arc.in b/include/lapi/syscalls/arc.in index 3e2ee9061..1a3a908e4 100644 --- a/include/lapi/syscalls/arc.in +++ b/include/lapi/syscalls/arc.in @@ -317,3 +317,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in index 7bdbca533..78d84549f 100644 --- a/include/lapi/syscalls/arm.in +++ b/include/lapi/syscalls/arm.in @@ -395,3 +395,5 @@ faccessat2 (__NR_SYSCALL_BASE+439) epoll_pwait2 (__NR_SYSCALL_BASE+441) quotactl_fd (__NR_SYSCALL_BASE+443) futex_waitv (__NR_SYSCALL_BASE+449) +statmount (__NR_SYSCALL_BASE+457) +listmount (__NR_SYSCALL_BASE+458) diff --git a/include/lapi/syscalls/hppa.in b/include/lapi/syscalls/hppa.in index 8ebdafafb..1f01a4a0c 100644 --- a/include/lapi/syscalls/hppa.in +++ b/include/lapi/syscalls/hppa.in @@ -44,3 +44,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in index 1472631c4..f4e6589ab 100644 --- a/include/lapi/syscalls/i386.in +++ b/include/lapi/syscalls/i386.in @@ -431,3 +431,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/ia64.in b/include/lapi/syscalls/ia64.in index 0ea6e9722..dd8b8c79f 100644 --- a/include/lapi/syscalls/ia64.in +++ b/include/lapi/syscalls/ia64.in @@ -344,3 +344,5 @@ faccessat2 1463 epoll_pwait2 1465 quotactl_fd 1467 futex_waitv 1473 +statmount 1481 +listmount 1482 diff --git a/include/lapi/syscalls/loongarch.in b/include/lapi/syscalls/loongarch.in index 301f611f6..f48c0658c 100644 --- a/include/lapi/syscalls/loongarch.in +++ b/include/lapi/syscalls/loongarch.in @@ -305,3 +305,5 @@ memfd_secret 447 process_mrelease 448 futex_waitv 449 set_mempolicy_home_node 450 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/mips_n32.in b/include/lapi/syscalls/mips_n32.in index e818c9d92..af5928c0e 100644 --- a/include/lapi/syscalls/mips_n32.in +++ b/include/lapi/syscalls/mips_n32.in @@ -371,3 +371,5 @@ epoll_pwait2 6441 mount_setattr 6442 quotactl_fd 6443 futex_waitv 6449 +statmount 6457 +listmount 6458 diff --git a/include/lapi/syscalls/mips_n64.in b/include/lapi/syscalls/mips_n64.in index 6e15f43b3..a6d83e2e0 100644 --- a/include/lapi/syscalls/mips_n64.in +++ b/include/lapi/syscalls/mips_n64.in @@ -347,3 +347,5 @@ epoll_pwait2 5441 mount_setattr 5442 quotactl_fd 5443 futex_waitv 5449 +statmount 5457 +listmount 5458 diff --git a/include/lapi/syscalls/mips_o32.in b/include/lapi/syscalls/mips_o32.in index 921d5d331..eda7388a3 100644 --- a/include/lapi/syscalls/mips_o32.in +++ b/include/lapi/syscalls/mips_o32.in @@ -417,3 +417,5 @@ epoll_pwait2 4441 mount_setattr 4442 quotactl_fd 4443 futex_waitv 4449 +statmount 4457 +listmount 4458 diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in index 545d9d3d6..1b40ea53d 100644 --- a/include/lapi/syscalls/powerpc.in +++ b/include/lapi/syscalls/powerpc.in @@ -424,3 +424,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in index 545d9d3d6..1b40ea53d 100644 --- a/include/lapi/syscalls/powerpc64.in +++ b/include/lapi/syscalls/powerpc64.in @@ -424,3 +424,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in index 7213ac5f8..6593a4ff7 100644 --- a/include/lapi/syscalls/s390.in +++ b/include/lapi/syscalls/s390.in @@ -411,3 +411,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in index 879012e2b..b98e727d6 100644 --- a/include/lapi/syscalls/s390x.in +++ b/include/lapi/syscalls/s390x.in @@ -359,3 +359,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in index 7d5192a27..59178113e 100644 --- a/include/lapi/syscalls/sh.in +++ b/include/lapi/syscalls/sh.in @@ -405,3 +405,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in index 91d2fb1c2..56a244ceb 100644 --- a/include/lapi/syscalls/sparc.in +++ b/include/lapi/syscalls/sparc.in @@ -410,3 +410,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in index 1f2fc59b7..84051a600 100644 --- a/include/lapi/syscalls/sparc64.in +++ b/include/lapi/syscalls/sparc64.in @@ -375,3 +375,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in index dc61aa56e..935c5d7bc 100644 --- a/include/lapi/syscalls/x86_64.in +++ b/include/lapi/syscalls/x86_64.in @@ -352,6 +352,8 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +statmount 457 +listmount 458 rt_sigaction 512 rt_sigreturn 513 ioctl 514 From patchwork Wed May 15 11:33:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=XUudth+o; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=LUv2dyhA; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=XUudth+o; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=LUv2dyhA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWMR2Zl8z1yfq for ; Wed, 15 May 2024 21:33:55 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 9F71B3CF785 for ; Wed, 15 May 2024 13:33:52 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id E4AD63CF75A for ; Wed, 15 May 2024 13:33:49 +0200 (CEST) Authentication-Results: in-3.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.130; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 52EBC1A0C278 for ; Wed, 15 May 2024 13:33:49 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DFE9133ADE; Wed, 15 May 2024 11:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bFp1ujAIA/zECwSOzdfpYjXhDcjJ+Dn3X0D6RjX8hSs=; b=XUudth+ozauxLcJ8FN/HufOmhpq8jLtYkPgcSf7aLqbZ9WOpFRDERhXnPJBPuJsauBzl3q zRgNHxuAyNsnnE4wMadf3saK5FRQSJo0KPhdv+WnMvpCeuPdE4NDU5eWqCK5h4MH4ubOPZ UOlo1HFQF8qfwO6DnK/KAiCEl4tPNi8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bFp1ujAIA/zECwSOzdfpYjXhDcjJ+Dn3X0D6RjX8hSs=; b=LUv2dyhAl7dRmk61bgee2sypAZniwWaSnXQcsAqj2G+PTKWL+4ANtRIaorLE/WPYXbDYXU oepwRalPgyBG4KAA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bFp1ujAIA/zECwSOzdfpYjXhDcjJ+Dn3X0D6RjX8hSs=; b=XUudth+ozauxLcJ8FN/HufOmhpq8jLtYkPgcSf7aLqbZ9WOpFRDERhXnPJBPuJsauBzl3q zRgNHxuAyNsnnE4wMadf3saK5FRQSJo0KPhdv+WnMvpCeuPdE4NDU5eWqCK5h4MH4ubOPZ UOlo1HFQF8qfwO6DnK/KAiCEl4tPNi8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bFp1ujAIA/zECwSOzdfpYjXhDcjJ+Dn3X0D6RjX8hSs=; b=LUv2dyhAl7dRmk61bgee2sypAZniwWaSnXQcsAqj2G+PTKWL+4ANtRIaorLE/WPYXbDYXU oepwRalPgyBG4KAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B9F1113A66; Wed, 15 May 2024 11:33:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 0Hh3K5ydRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:48 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:31 +0200 Message-Id: <20240515113338.554-4-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-3.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 03/10] Add listmount01 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies that listmount() is properly recognizing a mounted root directory using LSMT_ROOT flag. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 2 + .../kernel/syscalls/listmount/.gitignore | 1 + testcases/kernel/syscalls/listmount/Makefile | 7 ++ .../kernel/syscalls/listmount/listmount.h | 26 ++++++++ .../kernel/syscalls/listmount/listmount01.c | 66 +++++++++++++++++++ 5 files changed, 102 insertions(+) create mode 100644 testcases/kernel/syscalls/listmount/.gitignore create mode 100644 testcases/kernel/syscalls/listmount/Makefile create mode 100644 testcases/kernel/syscalls/listmount/listmount.h create mode 100644 testcases/kernel/syscalls/listmount/listmount01.c diff --git a/runtest/syscalls b/runtest/syscalls index d9cf37510..8fd4a9a0a 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -706,6 +706,8 @@ linkat02 linkat02 listen01 listen01 +listmount01 listmount01 + listxattr01 listxattr01 listxattr02 listxattr02 listxattr03 listxattr03 diff --git a/testcases/kernel/syscalls/listmount/.gitignore b/testcases/kernel/syscalls/listmount/.gitignore new file mode 100644 index 000000000..5257b298c --- /dev/null +++ b/testcases/kernel/syscalls/listmount/.gitignore @@ -0,0 +1 @@ +listmount01 diff --git a/testcases/kernel/syscalls/listmount/Makefile b/testcases/kernel/syscalls/listmount/Makefile new file mode 100644 index 000000000..8cf1b9024 --- /dev/null +++ b/testcases/kernel/syscalls/listmount/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2024 SUSE LLC Andrea Cervesato + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/listmount/listmount.h b/testcases/kernel/syscalls/listmount/listmount.h new file mode 100644 index 000000000..93766cd33 --- /dev/null +++ b/testcases/kernel/syscalls/listmount/listmount.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +#ifndef LISTMOUNT_H + +#define _GNU_SOURCE + +#include "tst_test.h" +#include "lapi/mount.h" +#include "lapi/syscalls.h" + +static inline ssize_t listmount(uint64_t mnt_id, uint64_t last_mnt_id, + uint64_t list[], size_t num, unsigned int flags) +{ + struct mnt_id_req req = { + .size = MNT_ID_REQ_SIZE_VER0, + .mnt_id = mnt_id, + .param = last_mnt_id, + }; + + return tst_syscall(__NR_listmount, &req, list, num, flags); +} + +#endif diff --git a/testcases/kernel/syscalls/listmount/listmount01.c b/testcases/kernel/syscalls/listmount/listmount01.c new file mode 100644 index 000000000..20cc90507 --- /dev/null +++ b/testcases/kernel/syscalls/listmount/listmount01.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/** + * [Description] + * + * This test verifies that listmount() is properly recognizing a mounted + * root directory using LSMT_ROOT flag. + * + * [Algorithm] + * + * * move into a new unshared namespace + * * mount() a root inside temporary folder and get its mount ID + * * get list of mounted IDs using listmount(LSMT_ROOT, ..) + * * verify that the root mount ID is the only mount ID present inside the list + */ + +#include "listmount.h" +#include "lapi/stat.h" +#include "lapi/sched.h" + +#define MNTPOINT "mntpoint" +#define LISTSIZE 32 + +static uint64_t root_id; + +static void run(void) +{ + uint64_t list[LISTSIZE]; + + TST_EXP_POSITIVE(listmount(LSMT_ROOT, 0, list, LISTSIZE, 0)); + if (TST_RET == -1) + return; + + TST_EXP_EQ_LI(TST_RET, 1); + TST_EXP_EQ_LI(list[0], root_id); +} + +static void setup(void) +{ + struct statx sx; + + SAFE_UNSHARE(CLONE_NEWNS); + + SAFE_CHROOT(MNTPOINT); + SAFE_MOUNT("", "/", NULL, MS_REC | MS_PRIVATE, NULL); + SAFE_STATX(AT_FDCWD, "/", 0, STATX_MNT_ID_UNIQUE, &sx); + + root_id = sx.stx_mnt_id; +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .forks_child = 1, + .min_kver = "6.8", + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + NULL + }, +}; From patchwork Wed May 15 11:33:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Io4fhTbr; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=/cZo4b00; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Io4fhTbr; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=/cZo4b00; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWQH5Wkqz1ymw for ; Wed, 15 May 2024 21:36:23 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 514563CF864 for ; Wed, 15 May 2024 13:36:21 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 67B183CF771 for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Authentication-Results: in-3.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 45F5E1A00616 for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1CCEC205DD; Wed, 15 May 2024 11:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7t6HtRml77kFvTFKI6ZlzSMqN0i1+8wET235ZCa8dnw=; b=Io4fhTbraXptd09TiEcmjQwCIr4u0TeE5+qZvNY9wXwZITm0DGi2E3pRaxp3WB3VghoLZ+ QpY1mOJGZjVf01VZQrHrAwzpNZS43UC2UUv1ye91zzpKoC+3sLSoDC4ubOWfV1JvwH0FF2 Ldtyo2waX4Kn99U29kDjOZzJDF6fGxE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7t6HtRml77kFvTFKI6ZlzSMqN0i1+8wET235ZCa8dnw=; b=/cZo4b001dY7uT4E+4TCtN+gD7r6QGYGwFBAYDHRayJwPbcyANfT0zgtd3XvNUb/F+wqpl eTDfsG3ca3YXSJAg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7t6HtRml77kFvTFKI6ZlzSMqN0i1+8wET235ZCa8dnw=; b=Io4fhTbraXptd09TiEcmjQwCIr4u0TeE5+qZvNY9wXwZITm0DGi2E3pRaxp3WB3VghoLZ+ QpY1mOJGZjVf01VZQrHrAwzpNZS43UC2UUv1ye91zzpKoC+3sLSoDC4ubOWfV1JvwH0FF2 Ldtyo2waX4Kn99U29kDjOZzJDF6fGxE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7t6HtRml77kFvTFKI6ZlzSMqN0i1+8wET235ZCa8dnw=; b=/cZo4b001dY7uT4E+4TCtN+gD7r6QGYGwFBAYDHRayJwPbcyANfT0zgtd3XvNUb/F+wqpl eTDfsG3ca3YXSJAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id EC1021372E; Wed, 15 May 2024 11:33:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SOfAN5ydRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:48 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:32 +0200 Message-Id: <20240515113338.554-5-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-3.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 04/10] Add listmount02 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies that listmount() is properly reading groups of mount IDs. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + .../kernel/syscalls/listmount/.gitignore | 1 + .../kernel/syscalls/listmount/listmount02.c | 106 ++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 testcases/kernel/syscalls/listmount/listmount02.c diff --git a/runtest/syscalls b/runtest/syscalls index 8fd4a9a0a..355c182f8 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -707,6 +707,7 @@ linkat02 linkat02 listen01 listen01 listmount01 listmount01 +listmount02 listmount02 listxattr01 listxattr01 listxattr02 listxattr02 diff --git a/testcases/kernel/syscalls/listmount/.gitignore b/testcases/kernel/syscalls/listmount/.gitignore index 5257b298c..30bbf9f02 100644 --- a/testcases/kernel/syscalls/listmount/.gitignore +++ b/testcases/kernel/syscalls/listmount/.gitignore @@ -1 +1,2 @@ listmount01 +listmount02 diff --git a/testcases/kernel/syscalls/listmount/listmount02.c b/testcases/kernel/syscalls/listmount/listmount02.c new file mode 100644 index 000000000..712f17a50 --- /dev/null +++ b/testcases/kernel/syscalls/listmount/listmount02.c @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/** + * [Description] + * + * This test verifies that listmount() is properly reading groups of mount IDs. + * + * [Algorithm] + * + * * move into a new unshared namespace + * * mount() our new root inside temporary folder + * * generate a full mounts tree inside root folder + * * read the full list of mounted IDs using listmount(LSMT_ROOT, ..) + * * read the list of mounted IDs using groups of fixed size + * * compare the first mount list with the second mount list + */ + +#include "listmount.h" +#include "lapi/sched.h" + +#define MNTPOINT "mntpoint" +#define BIND_MOUNTS 7 +#define GROUPS_SIZE 3 +#define LISTSIZE (1 << BIND_MOUNTS) + +static void run(void) +{ + ssize_t ret; + size_t id, tot_ids, count = 0; + uint64_t mount_ids[LISTSIZE]; + uint64_t list[LISTSIZE]; + + for (int i = 0; i < BIND_MOUNTS; i++) + SAFE_MOUNT("/", "/", NULL, MS_BIND, NULL); + + tst_res(TINFO, "Reading all %d mount IDs in once", LISTSIZE); + + TST_EXP_POSITIVE(listmount(LSMT_ROOT, 0, mount_ids, LISTSIZE, 0)); + if (TST_RET == -1) + goto end; + + tot_ids = (size_t)TST_RET; + + if (tot_ids != LISTSIZE) { + tst_res(TFAIL, "listmount() returned %lu but %d was expected", + tot_ids, LISTSIZE); + goto end; + } + + tst_res(TINFO, "Reading groups of %d mount IDs", GROUPS_SIZE); + + while (count < LISTSIZE) { + id = count ? list[count - 1] : 0; + ret = listmount(LSMT_ROOT, id, list + count, GROUPS_SIZE, 0); + + tst_res(TDEBUG, "listmount(LSMT_ROOT, %lu, list + %lu, %d, 0)", + id, count, GROUPS_SIZE); + + if (ret == -1) { + tst_res(TFAIL, "listmount() failed with %s", tst_strerrno(errno)); + goto end; + } + + count += ret; + + if (TST_RET < GROUPS_SIZE) + break; + } + + for (size_t i = 0; i < LISTSIZE; i++) { + if (mount_ids[i] != list[i]) { + tst_res(TFAIL, "Mount ID differs at %ld index", i); + goto end; + } + } + + tst_res(TPASS, "All mount IDs have been correctly read"); + +end: + SAFE_UMOUNT("/"); +} + +static void setup(void) +{ + SAFE_UNSHARE(CLONE_NEWNS); + SAFE_CHROOT(MNTPOINT); + + SAFE_MOUNT("", "/", NULL, MS_REC | MS_SHARED, NULL); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .forks_child = 1, + .min_kver = "6.8", + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + NULL + }, +}; From patchwork Wed May 15 11:33:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935552 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Rjn45JIu; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=eTTnd2IA; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Rjn45JIu; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=eTTnd2IA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWNX2l07z1yfq for ; Wed, 15 May 2024 21:34:52 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 5E8F43CF8C0 for ; Wed, 15 May 2024 13:34:49 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 263D53CF772 for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Authentication-Results: in-6.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:1; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 446F014060DD for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4E26033ADF; Wed, 15 May 2024 11:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B6eURaw0BpIjuDhs+K4lJN3NGByIlcvSsqcfPYpTYwg=; b=Rjn45JIu5D/mVmN0qVQgS9wSCl8A0IGwQAL1tycQxCrMExUWfCpMmGMkoGkVP6xXBe/Z2t 7qyo/5LdpCCShJ1//qESGlQZIHerTauf27BSve8mlH6vq/7YbThJVi9Gf19CwqF1jpNIBy iVivc4IZGTffuJwNzBSV/UX5n0Ew9vg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B6eURaw0BpIjuDhs+K4lJN3NGByIlcvSsqcfPYpTYwg=; b=eTTnd2IAO8i1JfYuxwuqylawMtb92b4ZdmXiEScRUZdasQXRFpb8ogoLAAu0jQ4qY4ZaHq nqHVx6IGB43EtxBw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B6eURaw0BpIjuDhs+K4lJN3NGByIlcvSsqcfPYpTYwg=; b=Rjn45JIu5D/mVmN0qVQgS9wSCl8A0IGwQAL1tycQxCrMExUWfCpMmGMkoGkVP6xXBe/Z2t 7qyo/5LdpCCShJ1//qESGlQZIHerTauf27BSve8mlH6vq/7YbThJVi9Gf19CwqF1jpNIBy iVivc4IZGTffuJwNzBSV/UX5n0Ew9vg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B6eURaw0BpIjuDhs+K4lJN3NGByIlcvSsqcfPYpTYwg=; b=eTTnd2IAO8i1JfYuxwuqylawMtb92b4ZdmXiEScRUZdasQXRFpb8ogoLAAu0jQ4qY4ZaHq nqHVx6IGB43EtxBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 297C413A62; Wed, 15 May 2024 11:33:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eFg7CJ2dRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:49 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:33 +0200 Message-Id: <20240515113338.554-6-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-6.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-6.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 05/10] Add stamount01 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies that statmount() is working with no mask flags. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 2 + .../kernel/syscalls/statmount/.gitignore | 1 + testcases/kernel/syscalls/statmount/Makefile | 7 ++ .../kernel/syscalls/statmount/statmount.h | 26 +++++++ .../kernel/syscalls/statmount/statmount01.c | 69 +++++++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 testcases/kernel/syscalls/statmount/.gitignore create mode 100644 testcases/kernel/syscalls/statmount/Makefile create mode 100644 testcases/kernel/syscalls/statmount/statmount.h create mode 100644 testcases/kernel/syscalls/statmount/statmount01.c diff --git a/runtest/syscalls b/runtest/syscalls index 355c182f8..407cae890 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1537,6 +1537,8 @@ stat03_64 stat03_64 stat04 symlink01 -T stat04 stat04_64 symlink01 -T stat04_64 +statmount01 statmount01 + statfs01 statfs01 statfs01_64 statfs01_64 statfs02 statfs02 diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore new file mode 100644 index 000000000..f1529eb29 --- /dev/null +++ b/testcases/kernel/syscalls/statmount/.gitignore @@ -0,0 +1 @@ +statmount01 diff --git a/testcases/kernel/syscalls/statmount/Makefile b/testcases/kernel/syscalls/statmount/Makefile new file mode 100644 index 000000000..8cf1b9024 --- /dev/null +++ b/testcases/kernel/syscalls/statmount/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2024 SUSE LLC Andrea Cervesato + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/statmount/statmount.h b/testcases/kernel/syscalls/statmount/statmount.h new file mode 100644 index 000000000..e807c8288 --- /dev/null +++ b/testcases/kernel/syscalls/statmount/statmount.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +#ifndef STATMOUNT_H + +#define _GNU_SOURCE + +#include "tst_test.h" +#include "lapi/mount.h" +#include "lapi/syscalls.h" + +static inline int statmount(uint64_t mnt_id, uint64_t mask, struct statmount *buf, + size_t bufsize, unsigned int flags) +{ + struct mnt_id_req req = { + .size = MNT_ID_REQ_SIZE_VER0, + .mnt_id = mnt_id, + .param = mask, + }; + + return tst_syscall(__NR_statmount, &req, buf, bufsize, flags); +} + +#endif diff --git a/testcases/kernel/syscalls/statmount/statmount01.c b/testcases/kernel/syscalls/statmount/statmount01.c new file mode 100644 index 000000000..4bf879916 --- /dev/null +++ b/testcases/kernel/syscalls/statmount/statmount01.c @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/** + * [Description] + * + * This test verifies that statmount() is working with no mask flags. + * + * [Algorithm] + * + * * create a mount point + * * run statmount() on the mount point without giving any mask + * * read results and check that mask and size are correct + */ + +#include "statmount.h" +#include "lapi/stat.h" +#include "lapi/sched.h" + +#define MNTPOINT "mntpoint" + +static uint64_t root_id; +static struct statmount *st_mount; + +static void run(void) +{ + memset(st_mount, 0, sizeof(struct statmount)); + + TST_EXP_PASS(statmount( + root_id, + 0, + st_mount, + sizeof(struct statmount), + 0)); + + if (TST_RET == -1) + return; + + TST_EXP_EQ_LI(st_mount->mask, 0); + TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount)); +} + +static void setup(void) +{ + struct statx sx; + + SAFE_STATX(AT_FDCWD, MNTPOINT, 0, STATX_MNT_ID_UNIQUE, &sx); + + root_id = sx.stx_mnt_id; +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .min_kver = "6.8", + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + NULL + }, + .bufs = (struct tst_buffers []) { + {&st_mount, .size = sizeof(struct statmount)}, + {} + } +}; From patchwork Wed May 15 11:33:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935553 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eh/JNKHx; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yXv1fvni; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eh/JNKHx; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yXv1fvni; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWNq58C1z1ymf for ; Wed, 15 May 2024 21:35:07 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 57FE53CF844 for ; Wed, 15 May 2024 13:35:05 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id A9F0E3CF7A1 for ; Wed, 15 May 2024 13:33:51 +0200 (CEST) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:1; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 7823010060A4 for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7FAD333AE0; Wed, 15 May 2024 11:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n1LGhqS+6aUQK94XOnfnXri6oBu2Hk8YSzG8xUkuc28=; b=eh/JNKHxtXETgP1KQi73mu2M/H1tJoO+dX3jpmdZFnU5yTY86zhj4qr2GKTciNo9UfUe0p yKZZZXmxxBIHdBgzWwW19zvuw99daRBS2mIpVRsUQDXQwZXaqXD3gyaxWWviO0TVe2uhea TZxqqanlgXeNJKFyVHy4CHl6sRJJFu8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n1LGhqS+6aUQK94XOnfnXri6oBu2Hk8YSzG8xUkuc28=; b=yXv1fvninGlWjAjx0LztaugITYqSfxKoN0WUr0N/vV6VRB2V6g2fx+kabiX2ouJs6OCu5i DPN9Y+ET6+T3+7Aw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n1LGhqS+6aUQK94XOnfnXri6oBu2Hk8YSzG8xUkuc28=; b=eh/JNKHxtXETgP1KQi73mu2M/H1tJoO+dX3jpmdZFnU5yTY86zhj4qr2GKTciNo9UfUe0p yKZZZXmxxBIHdBgzWwW19zvuw99daRBS2mIpVRsUQDXQwZXaqXD3gyaxWWviO0TVe2uhea TZxqqanlgXeNJKFyVHy4CHl6sRJJFu8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n1LGhqS+6aUQK94XOnfnXri6oBu2Hk8YSzG8xUkuc28=; b=yXv1fvninGlWjAjx0LztaugITYqSfxKoN0WUr0N/vV6VRB2V6g2fx+kabiX2ouJs6OCu5i DPN9Y+ET6+T3+7Aw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5B0C21372E; Wed, 15 May 2024 11:33:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id wG8CFJ2dRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:49 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:34 +0200 Message-Id: <20240515113338.554-7-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 06/10] Add statmount02 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies that statmount() is correctly reading basic filesystem info using STATMOUNT_SB_BASIC. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + .../kernel/syscalls/statmount/.gitignore | 1 + .../kernel/syscalls/statmount/statmount02.c | 76 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 testcases/kernel/syscalls/statmount/statmount02.c diff --git a/runtest/syscalls b/runtest/syscalls index 407cae890..5f1df42ca 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1538,6 +1538,7 @@ stat04 symlink01 -T stat04 stat04_64 symlink01 -T stat04_64 statmount01 statmount01 +statmount02 statmount02 statfs01 statfs01 statfs01_64 statfs01_64 diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore index f1529eb29..a30b9565f 100644 --- a/testcases/kernel/syscalls/statmount/.gitignore +++ b/testcases/kernel/syscalls/statmount/.gitignore @@ -1 +1,2 @@ statmount01 +statmount02 diff --git a/testcases/kernel/syscalls/statmount/statmount02.c b/testcases/kernel/syscalls/statmount/statmount02.c new file mode 100644 index 000000000..b110e992d --- /dev/null +++ b/testcases/kernel/syscalls/statmount/statmount02.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/** + * [Description] + * + * This test verifies that statmount() is correctly reading basic filesystem + * info using STATMOUNT_SB_BASIC. + * The btrfs validation is currently skipped due to the lack of support for VFS. + * + * [Algorithm] + * + * * create a mount point and read its mount info + * * run statmount() on the mount point using STATMOUNT_SB_BASIC + * * read results and check if mount info are correct + */ + +#include "statmount.h" +#include "lapi/stat.h" +#include "lapi/sched.h" +#include + +#define MNTPOINT "mntpoint" + +static struct statmount *st_mount; +static struct statx *sx_mount; +static struct statfs *sf_mount; + +static void run(void) +{ + memset(st_mount, 0, sizeof(struct statmount)); + + TST_EXP_PASS(statmount( + sx_mount->stx_mnt_id, + STATMOUNT_SB_BASIC, + st_mount, + sizeof(struct statmount), + 0)); + + if (TST_RET == -1) + return; + + TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_SB_BASIC); + TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount)); + TST_EXP_EQ_LI(st_mount->sb_dev_major, sx_mount->stx_dev_major); + TST_EXP_EQ_LI(st_mount->sb_dev_minor, sx_mount->stx_dev_minor); + TST_EXP_EQ_LI(st_mount->sb_magic, sf_mount->f_type); +} + +static void setup(void) +{ + SAFE_STATX(AT_FDCWD, MNTPOINT, 0, STATX_MNT_ID_UNIQUE, sx_mount); + SAFE_STATFS(MNTPOINT, sf_mount); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .min_kver = "6.8", + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + "btrfs", + NULL + }, + .bufs = (struct tst_buffers []) { + {&st_mount, .size = sizeof(struct statmount)}, + {&sx_mount, .size = sizeof(struct statx)}, + {&sf_mount, .size = sizeof(struct statfs)}, + {} + } +}; From patchwork Wed May 15 11:33:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935555 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=PtvX1f0Q; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=GzCw8crP; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=PtvX1f0Q; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=GzCw8crP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWPR4WnCz1ymw for ; Wed, 15 May 2024 21:35:39 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3D79F3CB75D for ; Wed, 15 May 2024 13:35:37 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id ED92F3CF771 for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Authentication-Results: in-3.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.130; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 13A1C1A0C689 for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B0AA633AE1; Wed, 15 May 2024 11:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6FBwUiHxgGuJToDPCl/CxD15WUb4m4zjOr/qjrAZEQA=; b=PtvX1f0QPvq514MCZdQrE7K40EtIXuuweMSFCCerPb0xTbqjF+diL3wy0+g0d/jiyGkNig L4rbwRPDn5C9OMmoI0EJP994w2G/vPH75GQG0r4eRacWgexZ50EHPDEJG/jLXe8v99y2rJ FGxoaVFbQbux5ZfMq8A4/pq3omZA81o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6FBwUiHxgGuJToDPCl/CxD15WUb4m4zjOr/qjrAZEQA=; b=GzCw8crP5fl7w+55Zy29b8bDzViohLJ/88vF/3ErULP7WxXn+7jC7bOedPf+f0P14b8UPk 9j8pmyHna4yUozAg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=PtvX1f0Q; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=GzCw8crP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6FBwUiHxgGuJToDPCl/CxD15WUb4m4zjOr/qjrAZEQA=; b=PtvX1f0QPvq514MCZdQrE7K40EtIXuuweMSFCCerPb0xTbqjF+diL3wy0+g0d/jiyGkNig L4rbwRPDn5C9OMmoI0EJP994w2G/vPH75GQG0r4eRacWgexZ50EHPDEJG/jLXe8v99y2rJ FGxoaVFbQbux5ZfMq8A4/pq3omZA81o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6FBwUiHxgGuJToDPCl/CxD15WUb4m4zjOr/qjrAZEQA=; b=GzCw8crP5fl7w+55Zy29b8bDzViohLJ/88vF/3ErULP7WxXn+7jC7bOedPf+f0P14b8UPk 9j8pmyHna4yUozAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8B90013A66; Wed, 15 May 2024 11:33:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8GgiIJ2dRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:49 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:35 +0200 Message-Id: <20240515113338.554-8-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: B0AA633AE1 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, suse.com:email, suse.de:dkim] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-3.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 07/10] Add statmount03 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies that statmount() is correctly reading mount information (mount id, parent mount id, mount attributes etc.) using STATMOUNT_MNT_BASIC. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + .../kernel/syscalls/statmount/.gitignore | 1 + .../kernel/syscalls/statmount/statmount03.c | 99 +++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 testcases/kernel/syscalls/statmount/statmount03.c diff --git a/runtest/syscalls b/runtest/syscalls index 5f1df42ca..116106521 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1539,6 +1539,7 @@ stat04_64 symlink01 -T stat04_64 statmount01 statmount01 statmount02 statmount02 +statmount03 statmount03 statfs01 statfs01 statfs01_64 statfs01_64 diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore index a30b9565f..2a02bf721 100644 --- a/testcases/kernel/syscalls/statmount/.gitignore +++ b/testcases/kernel/syscalls/statmount/.gitignore @@ -1,2 +1,3 @@ statmount01 statmount02 +statmount03 diff --git a/testcases/kernel/syscalls/statmount/statmount03.c b/testcases/kernel/syscalls/statmount/statmount03.c new file mode 100644 index 000000000..6140940bd --- /dev/null +++ b/testcases/kernel/syscalls/statmount/statmount03.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/** + * [Description] + * + * This test verifies that statmount() is correctly reading mount information + * (mount id, parent mount id, mount attributes etc.) using STATMOUNT_MNT_BASIC. + * + * [Algorithm] + * + * * create a mount point + * * create a new parent folder inside the mount point and obtain its mount info + * * create the new "/" mount folder and obtain its mount info + * * run statmount() on the mount point using STATMOUNT_MNT_BASIC + * * read results and check if mount info are correct + */ + +#include "statmount.h" +#include "lapi/stat.h" +#include "lapi/sched.h" + +#define MNTPOINT "mntpoint" +#define MYPARENT MNTPOINT "/myroot" + +static uint64_t root_id; +static uint64_t root_id_old; +static uint64_t parent_id; +static uint64_t parent_id_old; +static struct statmount *st_mount; + +static void run(void) +{ + memset(st_mount, 0, sizeof(struct statmount)); + + TST_EXP_PASS(statmount( + root_id, + STATMOUNT_MNT_BASIC, + st_mount, + sizeof(struct statmount), + 0)); + + if (TST_RET == -1) + return; + + TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_MNT_BASIC); + TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount)); + TST_EXP_EQ_LI(st_mount->mnt_id, root_id); + TST_EXP_EQ_LI(st_mount->mnt_id_old, root_id_old); + TST_EXP_EQ_LI(st_mount->mnt_parent_id, parent_id); + TST_EXP_EQ_LI(st_mount->mnt_parent_id_old, parent_id_old); + TST_EXP_EQ_LI(st_mount->mnt_propagation, MS_PRIVATE); +} + +static void setup(void) +{ + struct statx sx; + + SAFE_UNSHARE(CLONE_NEWNS); + SAFE_MKDIR(MYPARENT, 0700); + + SAFE_STATX(AT_FDCWD, MYPARENT, 0, STATX_MNT_ID_UNIQUE, &sx); + parent_id = sx.stx_mnt_id; + + SAFE_STATX(AT_FDCWD, MYPARENT, 0, STATX_MNT_ID, &sx); + parent_id_old = sx.stx_mnt_id; + + SAFE_MOUNT("", "/", NULL, MS_REC | MS_PRIVATE, NULL); + SAFE_MOUNT(MYPARENT, MYPARENT, NULL, MS_BIND, NULL); + SAFE_CHROOT(MYPARENT); + SAFE_CHDIR("/"); + + SAFE_STATX(AT_FDCWD, "/", 0, STATX_MNT_ID_UNIQUE, &sx); + root_id = sx.stx_mnt_id; + + SAFE_STATX(AT_FDCWD, "/", 0, STATX_MNT_ID, &sx); + root_id_old = sx.stx_mnt_id; +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .min_kver = "6.8", + .needs_tmpdir = 1, + .format_device = 1, + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + NULL + }, + .bufs = (struct tst_buffers []) { + {&st_mount, .size = sizeof(struct statmount)}, + {} + } +}; From patchwork Wed May 15 11:33:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=zyuWINxX; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=pumk3lDK; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=sG0Mm3Ef; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=McowCMS/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWNC1Ny0z1yfq for ; Wed, 15 May 2024 21:34:35 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D3E373CF782 for ; Wed, 15 May 2024 13:34:32 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 0A8D33CF75A for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Authentication-Results: in-7.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 4E360208E1A for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E2653205E1; Wed, 15 May 2024 11:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dgu2rRXne7PpTs+AecDO4WyzAOKC9C5BPD8jMjXz7vc=; b=zyuWINxX/du8bZoSevy4enjFnf9hwQYYbZc5Se3fMUVT8adqmQ9LCyS2ZaLPOEQMGkdK2K AyLJUo2QvFBy+/zzIgItx2SH2ZrkgQq0WdimuEZiVeH3VRa9J59T+hNd098R96qljtBtjf FPDW12uz0j8j5Qe5fyJ/81Sh4kiftkY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dgu2rRXne7PpTs+AecDO4WyzAOKC9C5BPD8jMjXz7vc=; b=pumk3lDKJPqV4gYYD/prLc1ay4el34N4zg+IV3Hg9phRii4Ll8wspKKUF6bC2xiZeWapys A1Xdk9gnHtdJvmDQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=sG0Mm3Ef; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="McowCMS/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dgu2rRXne7PpTs+AecDO4WyzAOKC9C5BPD8jMjXz7vc=; b=sG0Mm3Ef+Tvtej6asrQvc1W4gSeIHxSMaRTnmjFKocjyK2Eb7LYLRcbMHX2faJpz/BI+VQ f4LeQQy49UrJq5ufxcME8aUKc0L8svCn/6ZJea8L1d07VRG3FD17K04I/xbeNWh2pdpVnA 9jTDjK7znMv2O6fuqdF+PTmSba/ObDQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dgu2rRXne7PpTs+AecDO4WyzAOKC9C5BPD8jMjXz7vc=; b=McowCMS/hbMRkKuMCdYZnNLJlW6/Qvab75X19x7L2KFJ89nzpt5k/OEWKEK8cB8d1ON06G sCHuh9ntCTYrE9AA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BB5A41372E; Wed, 15 May 2024 11:33:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 2HjYK52dRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:49 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:36 +0200 Message-Id: <20240515113338.554-9-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: E2653205E1 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, suse.de:dkim, suse.com:email] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-7.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-7.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 08/10] Add statmount04 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies that statmount() is correctly reading propagation from what mount in current namespace using STATMOUNT_PROPAGATE_FROM. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + .../kernel/syscalls/statmount/.gitignore | 1 + .../kernel/syscalls/statmount/statmount04.c | 133 ++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 testcases/kernel/syscalls/statmount/statmount04.c diff --git a/runtest/syscalls b/runtest/syscalls index 116106521..3c262ca3e 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1540,6 +1540,7 @@ stat04_64 symlink01 -T stat04_64 statmount01 statmount01 statmount02 statmount02 statmount03 statmount03 +statmount04 statmount04 statfs01 statfs01 statfs01_64 statfs01_64 diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore index 2a02bf721..e720050b5 100644 --- a/testcases/kernel/syscalls/statmount/.gitignore +++ b/testcases/kernel/syscalls/statmount/.gitignore @@ -1,3 +1,4 @@ statmount01 statmount02 statmount03 +statmount04 diff --git a/testcases/kernel/syscalls/statmount/statmount04.c b/testcases/kernel/syscalls/statmount/statmount04.c new file mode 100644 index 000000000..cfb0e9962 --- /dev/null +++ b/testcases/kernel/syscalls/statmount/statmount04.c @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/** + * [Description] + * + * This test verifies that statmount() is correctly reading propagation from + * what mount in current namespace using STATMOUNT_PROPAGATE_FROM. + * + * [Algorithm] + * + * * create a mount point + * * propagate a mounted folder inside the mount point + * * run statmount() on the mount point using STATMOUNT_PROPAGATE_FROM + * * read results and check propagated_from parameter contains the propagated + * folder ID + */ + +#include "statmount.h" +#include "lapi/stat.h" +#include "lapi/sched.h" +#include "tst_safe_stdio.h" + +#define MNTPOINT "mntpoint" +#define DIR_A MNTPOINT "/LTP_DIR_A" +#define DIR_C_SUBFOLDER "/LTP_DIR_A/propagated" +#define DIR_C (MNTPOINT DIR_C_SUBFOLDER) +#define DIR_B MNTPOINT "/LTP_DIR_B" +#define DIR_D MNTPOINT "/LTP_DIR_B/propagated" + +static uint64_t peer_group_id; +static uint64_t dird_id; +static struct statmount *st_mount; + +static int read_peer_group(void) +{ + FILE *file; + char line[PATH_MAX]; + char mroot[PATH_MAX]; + int group = -1; + + file = SAFE_FOPEN("/proc/self/mountinfo", "r"); + + while (fgets(line, sizeof(line), file)) { + if (sscanf(line, "%*d %*d %*d:%*d %s %*s %*s shared:%d", mroot, &group) != 2) + continue; + + if (strcmp(mroot, DIR_C_SUBFOLDER) == 0) + break; + } + + if (group == -1) + tst_brk(TBROK, "Can't reed peer group ID for %s", DIR_C_SUBFOLDER); + + return group; +} + +static void run(void) +{ + memset(st_mount, 0, sizeof(struct statmount)); + + TST_EXP_PASS(statmount( + dird_id, + STATMOUNT_PROPAGATE_FROM, + st_mount, + sizeof(struct statmount), + 0)); + + if (TST_RET == -1) + return; + + TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_PROPAGATE_FROM); + TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount)); + TST_EXP_EQ_LI(st_mount->propagate_from, peer_group_id); +} + +static void setup(void) +{ + struct statx sx; + + /* create DIR_A / DIR_C structure with DIR_C mounted */ + SAFE_MKDIR(DIR_A, 0700); + SAFE_MOUNT(DIR_A, DIR_A, "none", MS_BIND, NULL); + SAFE_MOUNT("none", DIR_A, "none", MS_SHARED, NULL); + + SAFE_MKDIR(DIR_C, 0700); + SAFE_MOUNT(DIR_C, DIR_C, "none", MS_BIND, NULL); + SAFE_MOUNT("none", DIR_C, "none", MS_SHARED, NULL); + + /* DIR_A mounts into DIR_B. DIR_D is propagated */ + SAFE_MKDIR(DIR_B, 0700); + SAFE_MOUNT(DIR_A, DIR_B, "none", MS_BIND, NULL); + SAFE_MOUNT("none", DIR_B, "none", MS_SLAVE, NULL); + + SAFE_STATX(AT_FDCWD, DIR_D, 0, STATX_MNT_ID_UNIQUE, &sx); + dird_id = sx.stx_mnt_id; + + peer_group_id = read_peer_group(); +} + +static void cleanup(void) +{ + if (tst_is_mounted(DIR_C)) + SAFE_UMOUNT(DIR_C); + + if (tst_is_mounted(DIR_B)) + SAFE_UMOUNT(DIR_B); + + if (tst_is_mounted(DIR_A)) + SAFE_UMOUNT(DIR_A); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .min_kver = "6.8", + .needs_tmpdir = 1, + .format_device = 1, + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + NULL + }, + .bufs = (struct tst_buffers []) { + {&st_mount, .size = sizeof(struct statmount)}, + {} + } +}; From patchwork Wed May 15 11:33:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=WMKKp4gN; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TrMm7kkP; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=WMKKp4gN; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TrMm7kkP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWPs3sHKz1ymw for ; Wed, 15 May 2024 21:36:01 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3D18E3CF804 for ; Wed, 15 May 2024 13:35:59 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 6E7803CF7E8 for ; Wed, 15 May 2024 13:33:51 +0200 (CEST) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 3D4D96008C4 for ; Wed, 15 May 2024 13:33:51 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2C13A205E2; Wed, 15 May 2024 11:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sn0di5rzGd5SNhnR2+1IKOwEvEyw0VZYX9AkcXoGUO8=; b=WMKKp4gNfnyUqwV3GcPNTLqLPYew/uhUrPx5FeciiA0YIJANVd+VinmfG0xocAypQ+liip rFWnphQUV6Yq5nEGeTHuk695/4UEsSt0D3lXqEYTeiJYez23wXMQzA944Q2+vQDzVywl5g cRRMZA4brQkFxjzFrREDXYoYpM0YPqQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sn0di5rzGd5SNhnR2+1IKOwEvEyw0VZYX9AkcXoGUO8=; b=TrMm7kkPjB5pFVI3ahfDkGdHrdhL1dzxkLU3zAx/jNwLe4HsPACeOqDZ/MbEJ2sffUhK3V bCn+qysCPlb4/WAw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=WMKKp4gN; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=TrMm7kkP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sn0di5rzGd5SNhnR2+1IKOwEvEyw0VZYX9AkcXoGUO8=; b=WMKKp4gNfnyUqwV3GcPNTLqLPYew/uhUrPx5FeciiA0YIJANVd+VinmfG0xocAypQ+liip rFWnphQUV6Yq5nEGeTHuk695/4UEsSt0D3lXqEYTeiJYez23wXMQzA944Q2+vQDzVywl5g cRRMZA4brQkFxjzFrREDXYoYpM0YPqQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sn0di5rzGd5SNhnR2+1IKOwEvEyw0VZYX9AkcXoGUO8=; b=TrMm7kkPjB5pFVI3ahfDkGdHrdhL1dzxkLU3zAx/jNwLe4HsPACeOqDZ/MbEJ2sffUhK3V bCn+qysCPlb4/WAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id ED18513A62; Wed, 15 May 2024 11:33:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IOX5N52dRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:49 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:37 +0200 Message-Id: <20240515113338.554-10-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 2C13A205E2 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, suse.de:dkim, suse.com:email] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 09/10] Add statmount05 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies STATMOUNT_MNT_ROOT and STATMOUNT_MNT_POINT functionalities of statmount(). Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + .../kernel/syscalls/statmount/.gitignore | 1 + .../kernel/syscalls/statmount/statmount05.c | 138 ++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 testcases/kernel/syscalls/statmount/statmount05.c diff --git a/runtest/syscalls b/runtest/syscalls index 3c262ca3e..2984117e6 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1541,6 +1541,7 @@ statmount01 statmount01 statmount02 statmount02 statmount03 statmount03 statmount04 statmount04 +statmount05 statmount05 statfs01 statfs01 statfs01_64 statfs01_64 diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore index e720050b5..f64763242 100644 --- a/testcases/kernel/syscalls/statmount/.gitignore +++ b/testcases/kernel/syscalls/statmount/.gitignore @@ -2,3 +2,4 @@ statmount01 statmount02 statmount03 statmount04 +statmount05 diff --git a/testcases/kernel/syscalls/statmount/statmount05.c b/testcases/kernel/syscalls/statmount/statmount05.c new file mode 100644 index 000000000..9882719f5 --- /dev/null +++ b/testcases/kernel/syscalls/statmount/statmount05.c @@ -0,0 +1,138 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/** + * [Description] + * + * This test verifies STATMOUNT_MNT_ROOT and STATMOUNT_MNT_POINT functionalities + * of statmount(). In particular, STATMOUNT_MNT_ROOT will give the mount root + * (i.e. mount --bind /mnt /bla -> /mnt) and STATMOUNT_MNT_POINT will + * give the mount point (i.e. mount --bind /mnt /bla -> /bla). + * + * [Algorithm] + * + * * create a mount point + * * mount a folder inside the mount point + * * run statmount() on the mounted folder using STATMOUNT_MNT_ROOT + * * read results and check if contain the mount root path + * * run statmount() on the mounted folder using STATMOUNT_MNT_POINT + * * read results and check if contain the mount point path + */ + +#include "statmount.h" +#include "lapi/stat.h" +#include "lapi/sched.h" + +#define MNTPOINT "mntpoint" +#define DIRA MNTPOINT "/LTP_DIR_A" +#define DIRB MNTPOINT "/LTP_DIR_B" +#define SM_SIZE (1 << 10) + +static uint64_t root_id; +static struct statmount *st_mount; +static char mnt_root[PATH_MAX]; +static char mnt_point[PATH_MAX]; + +static void test_mount_root(void) +{ + tst_res(TINFO, "Testing STATMOUNT_MNT_ROOT"); + + char *last_root; + + memset(st_mount, 0, SM_SIZE); + + TST_EXP_PASS(statmount( + root_id, + STATMOUNT_MNT_ROOT, + st_mount, + SM_SIZE, + 0)); + + if (TST_RET == -1) + return; + + last_root = strrchr(mnt_root, '/'); + + TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_MNT_ROOT); + TST_EXP_EXPR(strcmp(st_mount->str + st_mount->mnt_root, last_root) == 0, + "statmount() read '%s', expected '%s'", + st_mount->str + st_mount->mnt_root, + last_root); +} + +static void test_mount_point(void) +{ + tst_res(TINFO, "Testing STATMOUNT_MNT_POINT"); + + memset(st_mount, 0, SM_SIZE); + + TST_EXP_POSITIVE(statmount( + root_id, + STATMOUNT_MNT_POINT, + st_mount, + SM_SIZE, + 0)); + + if (TST_RET == -1) + return; + + TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_MNT_POINT); + TST_EXP_EXPR(strcmp(st_mount->str + st_mount->mnt_point, mnt_point) == 0, + "mount point is '%s'", + st_mount->str + st_mount->mnt_point); +} + +static void run(void) +{ + test_mount_root(); + test_mount_point(); +} + +static void setup(void) +{ + char *tmpdir; + struct statx sx; + + tmpdir = tst_get_tmpdir(); + snprintf(mnt_root, PATH_MAX, "%s/%s", tmpdir, DIRA); + snprintf(mnt_point, PATH_MAX, "%s/%s", tmpdir, DIRB); + free(tmpdir); + + SAFE_MKDIR(mnt_root, 0700); + SAFE_MKDIR(mnt_point, 0700); + SAFE_MOUNT(mnt_root, mnt_point, "none", MS_BIND, NULL); + + SAFE_STATX(AT_FDCWD, mnt_point, 0, STATX_MNT_ID_UNIQUE, &sx); + root_id = sx.stx_mnt_id; +} + +static void cleanup(void) +{ + if (tst_is_mounted(DIRB)) + SAFE_UMOUNT(DIRB); + + if (tst_is_mounted(DIRA)) + SAFE_UMOUNT(DIRA); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .min_kver = "6.8", + .needs_tmpdir = 1, + .format_device = 1, + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + NULL + }, + .bufs = (struct tst_buffers []) { + {&st_mount, .size = SM_SIZE}, + {} + } +}; From patchwork Wed May 15 11:33:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Y23ALpoV; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=cLZcyI/1; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Y23ALpoV; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=cLZcyI/1; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfWP75V5Cz1ymw for ; Wed, 15 May 2024 21:35:23 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4F3B53CF782 for ; Wed, 15 May 2024 13:35:21 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id DF1FA3CF7A1 for ; Wed, 15 May 2024 13:33:51 +0200 (CEST) Authentication-Results: in-6.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.130; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id B834814060FB for ; Wed, 15 May 2024 13:33:50 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 51D3733AE4; Wed, 15 May 2024 11:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ViHSx8QjhJNj5eZ77Q/fbB6cgsOvS03qTHjZ4BxfxBM=; b=Y23ALpoVY6oXkuAJrhhFiPpjL4VR0p5IIMW3xBZsP7Mj6ryVk+8VEM0bH4/hKH2bSizdto 22Q9ZEmkVgRcEj5vBm1+PoIlnJLkzbqZX8r1OSEJ2fHQpEQGjUS9tL1To8Xc04BEmLs0Ii eSzbB/N+JZOTs2ZgbpDiUwNRMuXVTig= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ViHSx8QjhJNj5eZ77Q/fbB6cgsOvS03qTHjZ4BxfxBM=; b=cLZcyI/1DMe7y7WCgLEH0TUZxcYQlpCnVuLF4NVFZ8WPpYRBigBJDhPFZRGxgH7tVFoJdP u5y1LbhitXBSORBA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ViHSx8QjhJNj5eZ77Q/fbB6cgsOvS03qTHjZ4BxfxBM=; b=Y23ALpoVY6oXkuAJrhhFiPpjL4VR0p5IIMW3xBZsP7Mj6ryVk+8VEM0bH4/hKH2bSizdto 22Q9ZEmkVgRcEj5vBm1+PoIlnJLkzbqZX8r1OSEJ2fHQpEQGjUS9tL1To8Xc04BEmLs0Ii eSzbB/N+JZOTs2ZgbpDiUwNRMuXVTig= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715772830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ViHSx8QjhJNj5eZ77Q/fbB6cgsOvS03qTHjZ4BxfxBM=; b=cLZcyI/1DMe7y7WCgLEH0TUZxcYQlpCnVuLF4NVFZ8WPpYRBigBJDhPFZRGxgH7tVFoJdP u5y1LbhitXBSORBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2C2F41372E; Wed, 15 May 2024 11:33:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iDbZCJ6dRGbwNAAAD6G6ig (envelope-from ); Wed, 15 May 2024 11:33:50 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 15 May 2024 13:33:38 +0200 Message-Id: <20240515113338.554-11-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240515113338.554-1-andrea.cervesato@suse.de> References: <20240515113338.554-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-6.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-6.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 10/10] Add statmount06 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies that statmount() is correctly reading name of the filesystem type using STATMOUNT_FS_TYPE. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + .../kernel/syscalls/statmount/.gitignore | 1 + .../kernel/syscalls/statmount/statmount06.c | 73 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 testcases/kernel/syscalls/statmount/statmount06.c diff --git a/runtest/syscalls b/runtest/syscalls index 2984117e6..86e253f77 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1542,6 +1542,7 @@ statmount02 statmount02 statmount03 statmount03 statmount04 statmount04 statmount05 statmount05 +statmount06 statmount06 statfs01 statfs01 statfs01_64 statfs01_64 diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore index f64763242..03a75bd40 100644 --- a/testcases/kernel/syscalls/statmount/.gitignore +++ b/testcases/kernel/syscalls/statmount/.gitignore @@ -3,3 +3,4 @@ statmount02 statmount03 statmount04 statmount05 +statmount06 diff --git a/testcases/kernel/syscalls/statmount/statmount06.c b/testcases/kernel/syscalls/statmount/statmount06.c new file mode 100644 index 000000000..5c9be9be9 --- /dev/null +++ b/testcases/kernel/syscalls/statmount/statmount06.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/** + * [Description] + * + * This test verifies that statmount() is correctly reading name of the + * filesystem type using STATMOUNT_FS_TYPE. + * + * [Algorithm] + * + * * create a mount point + * * run statmount() on the mount point using STATMOUNT_FS_TYPE + * * read results and check if contain the name of the filesystem + */ + +#include "statmount.h" +#include "lapi/stat.h" +#include "lapi/sched.h" + +#define MNTPOINT "mntpoint" +#define SM_SIZE (1 << 10) + +static uint64_t root_id; +static struct statmount *st_mount; + +static void run(void) +{ + memset(st_mount, 0, SM_SIZE); + + TST_EXP_PASS(statmount( + root_id, + STATMOUNT_FS_TYPE, + st_mount, + SM_SIZE, + 0)); + + if (TST_RET == -1) + return; + + TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_FS_TYPE); + TST_EXP_EXPR(strcmp(st_mount->str + st_mount->fs_type, tst_device->fs_type) == 0, + "statmount() read '%s', expected '%s'", + st_mount->str + st_mount->fs_type, tst_device->fs_type); +} + +static void setup(void) +{ + struct statx sx; + + SAFE_STATX(AT_FDCWD, MNTPOINT, 0, STATX_MNT_ID_UNIQUE, &sx); + root_id = sx.stx_mnt_id; +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .min_kver = "6.8", + .format_device = 1, + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + NULL + }, + .bufs = (struct tst_buffers []) { + {&st_mount, .size = SM_SIZE}, + {} + } +};