From patchwork Thu Jul 11 07:43:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1959117 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=gShl566K; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=O02afHmS; 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=gShl566K; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=O02afHmS; 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 4WKRb60Kp9z1xpd for ; Thu, 11 Jul 2024 17:45:06 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id BE3F53CEEF4 for ; Thu, 11 Jul 2024 09:45:03 +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 408763C0746 for ; Thu, 11 Jul 2024 09:44:13 +0200 (CEST) Authentication-Results: in-7.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-7.smtp.seeweb.it (Postfix) with ESMTPS id CBF92200B8A for ; Thu, 11 Jul 2024 09:44:11 +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 3DB4F218FC; Thu, 11 Jul 2024 07:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PFBMhviU1s9E+148oaI3B5T8XXeDf6iADu55xc4GtrM=; b=gShl566KkgiJhCWuhMTXXEHB0Ihmw7TsO/rZkTYT6Mh7bdNTx3lam07zqIsW8GE65bNJMj +niVzHRyVJlMxhw8utOHc8BGx3kiJe7/xJ8XeDlQeHNcfY0QXVe1+mNVmmt/HG1o3558PJ E+phP/Wdl9KiVRoSAlq4wpRGEdzRK/8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PFBMhviU1s9E+148oaI3B5T8XXeDf6iADu55xc4GtrM=; b=O02afHmSA3F1RRrsAGTw4+YgLcNrlOlYR0hb+C+GxyS13k0CbaEsBvFj20RvuR0yGEnAqo 15WvjtH/qumAYrCQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=gShl566K; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=O02afHmS DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PFBMhviU1s9E+148oaI3B5T8XXeDf6iADu55xc4GtrM=; b=gShl566KkgiJhCWuhMTXXEHB0Ihmw7TsO/rZkTYT6Mh7bdNTx3lam07zqIsW8GE65bNJMj +niVzHRyVJlMxhw8utOHc8BGx3kiJe7/xJ8XeDlQeHNcfY0QXVe1+mNVmmt/HG1o3558PJ E+phP/Wdl9KiVRoSAlq4wpRGEdzRK/8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PFBMhviU1s9E+148oaI3B5T8XXeDf6iADu55xc4GtrM=; b=O02afHmSA3F1RRrsAGTw4+YgLcNrlOlYR0hb+C+GxyS13k0CbaEsBvFj20RvuR0yGEnAqo 15WvjtH/qumAYrCQ== 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 17984139E7; Thu, 11 Jul 2024 07:44:11 +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 aNx1BEuNj2a3FQAAD6G6ig (envelope-from ); Thu, 11 Jul 2024 07:44:11 +0000 From: Andrea Cervesato Date: Thu, 11 Jul 2024 09:43:53 +0200 MIME-Version: 1.0 Message-Id: <20240711-stat04-v4-1-d30c26fdaf5a@suse.com> References: <20240711-stat04-v4-0-d30c26fdaf5a@suse.com> In-Reply-To: <20240711-stat04-v4-0-d30c26fdaf5a@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4892; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=z92ZDQMOnsC6dbHBC11am3yMmgFThX6vi8MGuxCxSGA=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmj40+484Yb+/CGDcmoGQEEVtH2RRBx5NLnLqoz /eYvFMggOiJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZo+NPgAKCRDLzBqyILPm RgknDACp7S7T7gOcnlTmq4mhrF0PjMNvZ75/d5RHUZtnJWARKoij0IsMBkRGcU8YGuModfJvDql L75yn2oJMCa5wt3C6biVR4NQ+V8k24WN0u+N1pYj4Ynpjao8vu1mXkslJ9suhAs1XiPsYA6YXVx INg3DDPA5KNAdbcA2ougDws04VeKz8V+tsdbWPeGE5DpOPhCEhr6eVFJQcAdc8QOhmyoYlIbA2B H5rUh5STxtrWFMh6GcbwBuyHeFV+Fw9OOfjfE+82R5Ea0CVJhhQRYu1YRAdWrnH9u3FcEpIFAg6 ONQMCo1YKcNP6Pf/l1plm3Q5s+en2umjB8dmKANeP7yn9smaIb1hf1irM5P2PRjxc2UMhk2kgWS OOgP09B1xlYlD7vzp3NhRRmYhWaq17YkeBjtiTuLyFkS2YmnrK7eOkw1PhPWe7w/zUJm9eDwQaC nSu7IvWtU/NsixHbvhdchx2KIx5qtivqQ0BnJiho0a0rjw6sX9KdFogb9/5QzparrLxVQ= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; 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)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; TO_DN_SOME(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:email,suse.cz:email,suse.de:dkim]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.51 X-Spam-Level: X-Rspamd-Queue-Id: 3DB4F218FC 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 v4 1/4] Add stat04 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 has been extracted from symlink01 test and it checks that stat() executed on file provide the same information of symlink linking to it. Reviewed-by: Li Wang Reviewed-by: Petr Vorel Reviewed-by: Cyril Hrubis Signed-off-by: Andrea Cervesato --- runtest/smoketest | 4 +- runtest/syscalls | 4 +- testcases/kernel/syscalls/stat/.gitignore | 2 + testcases/kernel/syscalls/stat/stat04.c | 109 ++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 5 deletions(-) diff --git a/runtest/smoketest b/runtest/smoketest index f6f14fd2b..aeb74c9ee 100644 --- a/runtest/smoketest +++ b/runtest/smoketest @@ -8,9 +8,7 @@ time01 time01 wait02 wait02 write01 write01 symlink01 symlink01 -stat04 symlink01 -T stat04 -utime07 utime07 -rename01A symlink01 -T rename01 +stat04 stat04 splice02 splice02 -s 20 df01_sh df01.sh shell_test01 echo "SUCCESS" | shell_pipe01.sh diff --git a/runtest/syscalls b/runtest/syscalls index b6cadb2df..1e1203503 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1535,8 +1535,8 @@ stat02 stat02 stat02_64 stat02_64 stat03 stat03 stat03_64 stat03_64 -stat04 symlink01 -T stat04 -stat04_64 symlink01 -T stat04_64 +stat04 stat04 +stat04_64 stat04_64 statfs01 statfs01 statfs01_64 statfs01_64 diff --git a/testcases/kernel/syscalls/stat/.gitignore b/testcases/kernel/syscalls/stat/.gitignore index fa0a4ce9f..0a62dc6ee 100644 --- a/testcases/kernel/syscalls/stat/.gitignore +++ b/testcases/kernel/syscalls/stat/.gitignore @@ -4,3 +4,5 @@ /stat02_64 /stat03 /stat03_64 +/stat04 +/stat04_64 diff --git a/testcases/kernel/syscalls/stat/stat04.c b/testcases/kernel/syscalls/stat/stat04.c new file mode 100644 index 000000000..8dbf58a1d --- /dev/null +++ b/testcases/kernel/syscalls/stat/stat04.c @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * Author: David Fenner, Jon Hendrickson + * Copyright (C) 2024 Andrea Cervesato + */ + +/*\ + * [Description] + * + * This test checks that stat() executed on file provide the same information + * of symlink linking to it. + */ + +#include +#include "tst_test.h" +#include "tst_safe_stdio.h" + +#define FILENAME "file.txt" +#define MNTPOINT "mntpoint" +#define SYMBNAME MNTPOINT"/file_symlink" + +static char *symb_path; +static char *file_path; +static struct stat *file_stat; +static struct stat *symb_stat; + +static void run(void) +{ + SAFE_STAT(file_path, file_stat); + SAFE_STAT(symb_path, symb_stat); + + TST_EXP_EQ_LI(file_stat->st_dev, symb_stat->st_dev); + TST_EXP_EQ_LI(file_stat->st_mode, symb_stat->st_mode); + TST_EXP_EQ_LI(file_stat->st_nlink, symb_stat->st_nlink); + TST_EXP_EQ_LI(file_stat->st_uid, symb_stat->st_uid); + TST_EXP_EQ_LI(file_stat->st_gid, symb_stat->st_gid); + TST_EXP_EQ_LI(file_stat->st_size, symb_stat->st_size); + TST_EXP_EQ_LI(file_stat->st_atime, symb_stat->st_atime); + TST_EXP_EQ_LI(file_stat->st_mtime, symb_stat->st_mtime); + TST_EXP_EQ_LI(file_stat->st_ctime, symb_stat->st_ctime); +} + +static void setup(void) +{ + char opt_bsize[32]; + char *tmpdir; + const char *const fs_opts[] = {opt_bsize, NULL}; + struct stat sb; + int pagesize; + int fd; + + tmpdir = tst_get_tmpdir(); + SAFE_ASPRINTF(&file_path, "%s/%s", tmpdir, FILENAME); + SAFE_ASPRINTF(&symb_path, "%s/%s", tmpdir, SYMBNAME); + free(tmpdir); + + /* change st_blksize / st_dev */ + SAFE_STAT(".", &sb); + pagesize = sb.st_blksize == 4096 ? 1024 : 4096; + + snprintf(opt_bsize, sizeof(opt_bsize), "-b %i", pagesize); + SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL); + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, 0); + + SAFE_TOUCH(FILENAME, 0777, NULL); + + /* change st_nlink */ + SAFE_LINK(FILENAME, "linked_file"); + + /* change st_uid and st_gid */ + SAFE_CHOWN(FILENAME, 1000, 1000); + + /* change st_size */ + fd = SAFE_OPEN(FILENAME, O_WRONLY, 0777); + tst_fill_fd(fd, 'a', TST_KB, 500); + SAFE_CLOSE(fd); + + /* change st_atime / st_mtime / st_ctime */ + usleep(1001000); + + SAFE_SYMLINK(file_path, symb_path); +} + +static void cleanup(void) +{ + if (file_path) + free(file_path); + + if (symb_path) + free(symb_path); + + if (tst_is_mounted(MNTPOINT)) + SAFE_UMOUNT(MNTPOINT); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .needs_root = 1, + .needs_device = 1, + .mntpoint = MNTPOINT, + .bufs = (struct tst_buffers []) { + {&file_stat, .size = sizeof(struct stat)}, + {&symb_stat, .size = sizeof(struct stat)}, + {} + } +}; From patchwork Thu Jul 11 07:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1959114 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=vHAH9tl1; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=PKVSgK+K; 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=vHAH9tl1; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=PKVSgK+K; 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 4WKRZD656cz1xpd for ; Thu, 11 Jul 2024 17:44:20 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id DC35E3CC2E8 for ; Thu, 11 Jul 2024 09:44:17 +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 094943C0746 for ; Thu, 11 Jul 2024 09:44:13 +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 E7050100860F for ; Thu, 11 Jul 2024 09:44:12 +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 6512221905; Thu, 11 Jul 2024 07:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vqc4BHtiIG3McuX+4GCn18M71UTRHGBr9ByVAeicCdc=; b=vHAH9tl11JD3iH4YhP6u3/D2IUia+oDXXbOawmWpc0wYQ6WN6dA2J9XlruvLHWNHYnpH31 XzfgK/P39Zc17K4vYw2T1G48OP5T8RB+T4uiqk4zs2Yis8oVyBQwYUedmwAcdRejaPT3DR SosCWMs+jBO9UqD7djmikIMRLfHmOZs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vqc4BHtiIG3McuX+4GCn18M71UTRHGBr9ByVAeicCdc=; b=PKVSgK+K7ax9c0QOecb6MQU85rxN8kGqcCN+lQj1PAo3Bkw8+bX1aVsQ1UMJGLIt/V7zr4 edpaBgctU94pTuAg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=vHAH9tl1; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=PKVSgK+K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vqc4BHtiIG3McuX+4GCn18M71UTRHGBr9ByVAeicCdc=; b=vHAH9tl11JD3iH4YhP6u3/D2IUia+oDXXbOawmWpc0wYQ6WN6dA2J9XlruvLHWNHYnpH31 XzfgK/P39Zc17K4vYw2T1G48OP5T8RB+T4uiqk4zs2Yis8oVyBQwYUedmwAcdRejaPT3DR SosCWMs+jBO9UqD7djmikIMRLfHmOZs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vqc4BHtiIG3McuX+4GCn18M71UTRHGBr9ByVAeicCdc=; b=PKVSgK+K7ax9c0QOecb6MQU85rxN8kGqcCN+lQj1PAo3Bkw8+bX1aVsQ1UMJGLIt/V7zr4 edpaBgctU94pTuAg== 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 43CEF13A63; Thu, 11 Jul 2024 07:44:11 +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 AIdLD0uNj2a3FQAAD6G6ig (envelope-from ); Thu, 11 Jul 2024 07:44:11 +0000 From: Andrea Cervesato Date: Thu, 11 Jul 2024 09:43:54 +0200 MIME-Version: 1.0 Message-Id: <20240711-stat04-v4-2-d30c26fdaf5a@suse.com> References: <20240711-stat04-v4-0-d30c26fdaf5a@suse.com> In-Reply-To: <20240711-stat04-v4-0-d30c26fdaf5a@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4492; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=EFqEa6yCm1AtPI+u1+HFqpRqYuB3hSsHI6DdTyVdJD4=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmj40+EFwVhbiHRNTIKNH20s0i8s8xpMVvloNir ymp/fwsBbeJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZo+NPgAKCRDLzBqyILPm RuBuDACROlFMclckMqRWQ7hPnauSNGZYtzhAmX3J6WvEO6I3jpFHMAtUtVqTOXSZ5+qSWvf7RAh Zu0t+iwZR5RB/Bwdku4UrDDXcSn/pHliCCAvLIOqWHmIXyxJFk5FP3x3mLX4D9BKbiFLq6WbmW1 CItVKPpAWfnFRLnNi1Xoc5mpm00oae/x4GyiWRiLRbuS0y/lQ10x9/Bu4rb6RLHtWVQ0hceWLvw /N6HMoa21mrPh6HJk9NzjQpoexTKPyDUqKJpcChcA7A9/XldguSsKpzH+lK783D6rZRKs2Tlu0B 3qqjPUZvGMd5X12f1JWE0uwmaY7nw6SP52JTffMZ+yJSc8DLUrARgFH1srdx8pKplu2I1Guu6ab jWPUE8O7x6z3QW0ZE8o+fMWxUd/vwCwB9+E186DJNgXEHULtrO/5mbzYLD62+Se9nTvnd01IFsu JxnUlpPEmT4J0smgW7q2RTHif5Po/7kjAokC255cqW8DN8LrdpZ58GWdhKjOhFptlat3U= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Rspamd-Queue-Id: 6512221905 X-Spam-Score: -0.51 X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-0.51 / 50.00]; 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)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; TO_DN_SOME(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.cz:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Level: X-Spamd-Bar: / 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 v4 2/4] Add lstat03 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 has been extracted from symlink01 test and it checks that lstat() provides the right information, according with device, access time, block size, ownership, etc. Reviewed-by: Li Wang Reviewed-by: Petr Vorel Signed-off-by: Andrea Cervesato Reviewed-by: Cyril Hrubis --- runtest/syscalls | 4 +- testcases/kernel/syscalls/lstat/.gitignore | 2 + testcases/kernel/syscalls/lstat/lstat03.c | 99 ++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 2 deletions(-) diff --git a/runtest/syscalls b/runtest/syscalls index 1e1203503..160725893 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -725,12 +725,12 @@ lseek02 lseek02 lseek07 lseek07 lseek11 lseek11 -lstat01A symlink01 -T lstat01 -lstat01A_64 symlink01 -T lstat01_64 lstat01 lstat01 lstat01_64 lstat01_64 lstat02 lstat02 lstat02_64 lstat02_64 +lstat03 lstat03 +lstat03_64 lstat03_64 mallinfo02 mallinfo02 diff --git a/testcases/kernel/syscalls/lstat/.gitignore b/testcases/kernel/syscalls/lstat/.gitignore index a497a445f..72cba871f 100644 --- a/testcases/kernel/syscalls/lstat/.gitignore +++ b/testcases/kernel/syscalls/lstat/.gitignore @@ -2,3 +2,5 @@ /lstat01_64 /lstat02 /lstat02_64 +/lstat03 +/lstat03_64 diff --git a/testcases/kernel/syscalls/lstat/lstat03.c b/testcases/kernel/syscalls/lstat/lstat03.c new file mode 100644 index 000000000..4edabba7b --- /dev/null +++ b/testcases/kernel/syscalls/lstat/lstat03.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * Author: David Fenner, Jon Hendrickson + * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com + */ + +/*\ + * [Description] + * + * This test verifies that lstat() provides correct information according + * with device, access time, block size, ownership, etc. + * The implementation provides a set of tests which are specific for each one + * of the `struct stat` used to read file and symlink information. + */ + +#include "tst_test.h" + +#define FILENAME "file.txt" +#define MNTPOINT "mntpoint" +#define SYMBNAME MNTPOINT"/file_symlink" + +static struct stat *file_stat; +static struct stat *symb_stat; + +static void run(void) +{ + SAFE_LSTAT(FILENAME, file_stat); + SAFE_LSTAT(SYMBNAME, symb_stat); + + TST_EXP_EXPR(file_stat->st_dev != symb_stat->st_dev); + TST_EXP_EXPR(file_stat->st_mode != symb_stat->st_mode); + TST_EXP_EXPR(file_stat->st_nlink != symb_stat->st_nlink); + TST_EXP_EXPR(file_stat->st_ino != symb_stat->st_ino); + TST_EXP_EXPR(file_stat->st_uid != symb_stat->st_uid); + TST_EXP_EXPR(file_stat->st_gid != symb_stat->st_gid); + TST_EXP_EXPR(file_stat->st_size != symb_stat->st_size); + TST_EXP_EXPR(file_stat->st_blocks != symb_stat->st_blocks); + TST_EXP_EXPR(file_stat->st_blksize != symb_stat->st_blksize); + TST_EXP_EXPR(file_stat->st_atime != symb_stat->st_atime); + TST_EXP_EXPR(file_stat->st_mtime != symb_stat->st_mtime); + TST_EXP_EXPR(file_stat->st_ctime != symb_stat->st_ctime); +} + +static void setup(void) +{ + char opt_bsize[32]; + const char *const fs_opts[] = {opt_bsize, NULL}; + struct stat sb; + int pagesize; + int fd; + + /* change st_blksize / st_dev */ + SAFE_STAT(".", &sb); + pagesize = sb.st_blksize == 4096 ? 1024 : 4096; + + snprintf(opt_bsize, sizeof(opt_bsize), "-b %i", pagesize); + SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL); + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, 0); + + SAFE_TOUCH(FILENAME, 0777, NULL); + + /* change st_nlink */ + SAFE_LINK(FILENAME, "linked_file"); + + /* change st_uid and st_gid */ + SAFE_CHOWN(FILENAME, 1000, 1000); + + /* change st_size */ + fd = SAFE_OPEN(FILENAME, O_WRONLY, 0777); + tst_fill_fd(fd, 'a', TST_KB, 500); + SAFE_CLOSE(fd); + + /* change st_atime / st_mtime / st_ctime */ + usleep(1001000); + + SAFE_SYMLINK(FILENAME, SYMBNAME); +} + +static void cleanup(void) +{ + if (tst_is_mounted(MNTPOINT)) + SAFE_UMOUNT(MNTPOINT); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .needs_root = 1, + .needs_tmpdir = 1, + .needs_device = 1, + .mntpoint = MNTPOINT, + .bufs = (struct tst_buffers []) { + {&file_stat, .size = sizeof(struct stat)}, + {&symb_stat, .size = sizeof(struct stat)}, + {} + } +}; From patchwork Thu Jul 11 07:43:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1959116 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=ivc7wtfi; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Ndjnzuaq; 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=ivc7wtfi; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Ndjnzuaq; 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 4WKRZq0MQvz1xpd for ; Thu, 11 Jul 2024 17:44:50 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A7C733C6987 for ; Thu, 11 Jul 2024 09:44:48 +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 18F583C221F for ; Thu, 11 Jul 2024 09:44:13 +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 CBC36140610E for ; Thu, 11 Jul 2024 09:44:12 +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 8A3A02190B; Thu, 11 Jul 2024 07:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D5YxRoCvgj1itv/h9mll34jVFUeuw0E2VrsPPw825Ag=; b=ivc7wtfiQMBEqnmVgqj11CVpgcMw9R69VPSQ1fBcEVjH0cI5MrtlDHuX+XOTJ11HOeZ1si fHBNN+jkuLR1GHbxnfBtHXvaybp9D14aH0DfDqH0EXAFSItUa6zz3JTXSmF0/UUPMvNBa5 HtxY+niogpSUgRFJydhvn2XELS5YAeE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D5YxRoCvgj1itv/h9mll34jVFUeuw0E2VrsPPw825Ag=; b=NdjnzuaqyvMe5Fwx9TWOjKa/rtYovnN8W1V3sZM49KVe64LW3bHDqZ9ENApEKlnpjOv1LR m5TViZdX8QEPE7Ag== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ivc7wtfi; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Ndjnzuaq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D5YxRoCvgj1itv/h9mll34jVFUeuw0E2VrsPPw825Ag=; b=ivc7wtfiQMBEqnmVgqj11CVpgcMw9R69VPSQ1fBcEVjH0cI5MrtlDHuX+XOTJ11HOeZ1si fHBNN+jkuLR1GHbxnfBtHXvaybp9D14aH0DfDqH0EXAFSItUa6zz3JTXSmF0/UUPMvNBa5 HtxY+niogpSUgRFJydhvn2XELS5YAeE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D5YxRoCvgj1itv/h9mll34jVFUeuw0E2VrsPPw825Ag=; b=NdjnzuaqyvMe5Fwx9TWOjKa/rtYovnN8W1V3sZM49KVe64LW3bHDqZ9ENApEKlnpjOv1LR m5TViZdX8QEPE7Ag== 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 6989C139E0; Thu, 11 Jul 2024 07:44:11 +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 mGl3GEuNj2a3FQAAD6G6ig (envelope-from ); Thu, 11 Jul 2024 07:44:11 +0000 From: Andrea Cervesato Date: Thu, 11 Jul 2024 09:43:55 +0200 MIME-Version: 1.0 Message-Id: <20240711-stat04-v4-3-d30c26fdaf5a@suse.com> References: <20240711-stat04-v4-0-d30c26fdaf5a@suse.com> In-Reply-To: <20240711-stat04-v4-0-d30c26fdaf5a@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2408; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=61a8VpA41AFE8E7cIRE2qFgCHuvhT1AXYfAxlfqwkpI=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmj40+/0PBTP1SjnAJoVDJbG+AKNPv6lqf+mtPi Xau9AM/eg2JAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZo+NPgAKCRDLzBqyILPm RmJOC/4xIGa5fDem+ePF7CCmu5NrO8akfoMo1Ds8GGdi5jrFDCVPcEJkP4eoefMMXktVvVlanmN 5RlwmaVX0zG9NfgLQUnMRvNdYSdg7CK++1UuqehsW4NWXG/BXyOqtb591jT97IL3Ukj+uCBTqru Nf7ToNy+WUZni2JSfgLWwI9bPbacyqwMThc+R3syFLRw+AjkSi2MlY8k2RwhzNofvNvWuwaKBQy /N4G9LnT5YskI98mMPKJrqD5lgh9HnvCCQ8Fm1b7UikncxgikmzN6L3MqHV7KKXfsYA6xRduXNI gz0WXDgtQ+6vMmlCqMXvpLLfF8sVarMex7iQS4A2yN/t/iun6pjB2uNhrtBNbvYrKHhwVQQ5plk hEe9x2EIjVIAtddZbuvFch4ouuUdOYsitxdf0zLbQsJtQgOhsbgrxw7MY4E9Ew3iM3aklZyh1mK /dm5CdYAEK1U80gFIYAfumobWEqDqy0Q0eBUOcRB4lzvyRo83jXqPMYk5tvUnGebyxyAw= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; 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)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; TO_DN_SOME(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; 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,imap1.dmz-prg2.suse.org:rdns,suse.cz:email,suse.de:dkim]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.51 X-Spam-Level: X-Rspamd-Queue-Id: 8A3A02190B 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 v4 3/4] Add chmod08 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 has been extracted from symlink01 and it verifies that chmod() is working correctly on symlink() generated files. Reviewed-by: Li Wang Reviewed-by: Petr Vorel Signed-off-by: Andrea Cervesato Reviewed-by: Cyril Hrubis --- runtest/syscalls | 1 + testcases/kernel/syscalls/chmod/.gitignore | 1 + testcases/kernel/syscalls/chmod/chmod08.c | 45 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/runtest/syscalls b/runtest/syscalls index 160725893..40c0dd070 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -72,6 +72,7 @@ chmod03 chmod03 chmod05 chmod05 chmod06 chmod06 chmod07 chmod07 +chmod08 chmod08 chown01 chown01 chown01_16 chown01_16 diff --git a/testcases/kernel/syscalls/chmod/.gitignore b/testcases/kernel/syscalls/chmod/.gitignore index 27ddfce16..f295f4dcb 100644 --- a/testcases/kernel/syscalls/chmod/.gitignore +++ b/testcases/kernel/syscalls/chmod/.gitignore @@ -3,3 +3,4 @@ /chmod05 /chmod06 /chmod07 +/chmod08 diff --git a/testcases/kernel/syscalls/chmod/chmod08.c b/testcases/kernel/syscalls/chmod/chmod08.c new file mode 100644 index 000000000..87519dbe8 --- /dev/null +++ b/testcases/kernel/syscalls/chmod/chmod08.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * Author: David Fenner + * Copilot: Jon Hendrickson + * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com + */ + +/*\ + * [Description] + * + * This test verifies that chmod() is working correctly on symlink() + * generated files. + */ + +#include "tst_test.h" + +#define PERMS 01777 +#define TESTFILE "myobject" +#define SYMBNAME "my_symlink0" + +static void run(void) +{ + struct stat oldsym_stat; + struct stat newsym_stat; + + SAFE_TOUCH(TESTFILE, 0644, NULL); + SAFE_SYMLINK(TESTFILE, SYMBNAME); + SAFE_STAT(SYMBNAME, &oldsym_stat); + + TST_EXP_PASS(chmod(SYMBNAME, PERMS)); + SAFE_STAT(SYMBNAME, &newsym_stat); + + TST_EXP_EQ_LI(newsym_stat.st_mode & PERMS, PERMS); + TST_EXP_EXPR(oldsym_stat.st_mode != newsym_stat.st_mode, + "file mode has changed"); + + SAFE_UNLINK(SYMBNAME); + SAFE_UNLINK(TESTFILE); +} + +static struct tst_test test = { + .test_all = run, + .needs_tmpdir = 1, +}; From patchwork Thu Jul 11 07:43:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1959115 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=X7AmTxee; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=jlv8HCQW; 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=X7AmTxee; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=jlv8HCQW; 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 4WKRZW69MWz1xpd for ; Thu, 11 Jul 2024 17:44:35 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 9751E3CDE69 for ; Thu, 11 Jul 2024 09:44:33 +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 [217.194.8.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 10F313C21FF for ; Thu, 11 Jul 2024 09:44:13 +0200 (CEST) Authentication-Results: in-7.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-7.smtp.seeweb.it (Postfix) with ESMTPS id E6D40203C64 for ; Thu, 11 Jul 2024 09:44:12 +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 B0A341F8AF; Thu, 11 Jul 2024 07:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cHdYU70H2MF+MtMy0oo4tBY0eIRjHnaQJZoS7oMt0bs=; b=X7AmTxeenQ6hgLxZ+WpaddrDIdv1G0yrp3z3q/FKlq9Dkp2qYJixzkIF+ZhX618IniUOUL 4pAE4LZ5vkJKT/aGkC+ctpUNoNROQHJDSnR5QHJ9Kfz/es3o+LvrW31D3Zl8xpZhqnbv58 pfT5DtUeXqW9V0s0n4Sr7KaT7Ygypu0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cHdYU70H2MF+MtMy0oo4tBY0eIRjHnaQJZoS7oMt0bs=; b=jlv8HCQWLHtO25NORHYZpGaFMGsWVT0qcorGeBOk6V20DhPbbXffcCPNfObIqOH41xut+U 0XWH/3drYlfNd+AA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cHdYU70H2MF+MtMy0oo4tBY0eIRjHnaQJZoS7oMt0bs=; b=X7AmTxeenQ6hgLxZ+WpaddrDIdv1G0yrp3z3q/FKlq9Dkp2qYJixzkIF+ZhX618IniUOUL 4pAE4LZ5vkJKT/aGkC+ctpUNoNROQHJDSnR5QHJ9Kfz/es3o+LvrW31D3Zl8xpZhqnbv58 pfT5DtUeXqW9V0s0n4Sr7KaT7Ygypu0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720683851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cHdYU70H2MF+MtMy0oo4tBY0eIRjHnaQJZoS7oMt0bs=; b=jlv8HCQWLHtO25NORHYZpGaFMGsWVT0qcorGeBOk6V20DhPbbXffcCPNfObIqOH41xut+U 0XWH/3drYlfNd+AA== 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 91018139E7; Thu, 11 Jul 2024 07:44:11 +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 4HcNIkuNj2a3FQAAD6G6ig (envelope-from ); Thu, 11 Jul 2024 07:44:11 +0000 From: Andrea Cervesato Date: Thu, 11 Jul 2024 09:43:56 +0200 MIME-Version: 1.0 Message-Id: <20240711-stat04-v4-4-d30c26fdaf5a@suse.com> References: <20240711-stat04-v4-0-d30c26fdaf5a@suse.com> In-Reply-To: <20240711-stat04-v4-0-d30c26fdaf5a@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3515; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=qKxlTw/3Fz5zskB+y7yq10MEZGpWcR4KTS2z2I0ea1A=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmj40+bmi5IOoRBv+pKyoOoJ8TocszP5ltVepyK 2ib8Vk+3byJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZo+NPgAKCRDLzBqyILPm RiBZC/9nvZ5D+5NxCJKRFF8qgc5E+wemjO5Eg1jSS4ygil9z6FmVnowu++LGb+3Z9CjYeLAMuyJ 87R/HQe4+hzPdDZIhnJ4+VEr91C8ZjFGtUwJktfmGwRD3UjRF8EDG9Z73TEFXX+TfcncWT46xjJ fbrBH3k4K/vsEP4Tb1fvEoix4D6xs7QF8Nr8w9HwlFquYsD01/fm+QDDaGz40QaUOmOmyGlwg1V /VPFAt/gbJa01IOM83oOdFk591w2Lk5GRdJcXTPk/UnGUdvwyy2lejJKbvOflJxKfu54nfUekqV YNprnrrRWr/24ppQXaGbrGlIPJOSNykcDrZHO+lzkCtLPukKmYV8dTKICVf3HYZJGDYIvrSflf4 UVYrcOoK0t28enXpDML+w0DPxNfvNYugcWVnm+jIoLQVGdk2JkcFzf9FlhctyKILHCBQFDPJoQ3 JHhzXq/l2WnOo5MOaxuXP6cgFBsSJj6MIuhkpw6fCTwsOUqkS9sW2bep6bcp2+gDAm5pw= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spam-Score: -0.30 X-Spamd-Result: default: False [-0.30 / 50.00]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email, suse.com:email, imap1.dmz-prg2.suse.org:helo] X-Spam-Level: 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 v4 4/4] Add open15 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 has been extracted from symlink01 and it verifies that open() is working correctly on symlink() generated files. Reviewed-by: Li Wang Reviewed-by: Petr Vorel Signed-off-by: Andrea Cervesato Reviewed-by: Cyril Hrubis --- runtest/syscalls | 2 +- testcases/kernel/syscalls/open/.gitignore | 1 + testcases/kernel/syscalls/open/open15.c | 75 +++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/runtest/syscalls b/runtest/syscalls index 40c0dd070..4dfdf3782 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -923,7 +923,6 @@ nice04 nice04 nice05 nice05 open01 open01 -open01A symlink01 -T open01 open02 open02 open03 open03 open04 open04 @@ -936,6 +935,7 @@ open11 open11 open12 open12 open13 open13 open14 open14 +open15 open15 openat01 openat01 openat02 openat02 diff --git a/testcases/kernel/syscalls/open/.gitignore b/testcases/kernel/syscalls/open/.gitignore index 001d874d6..af5997572 100644 --- a/testcases/kernel/syscalls/open/.gitignore +++ b/testcases/kernel/syscalls/open/.gitignore @@ -12,3 +12,4 @@ /open12_child /open13 /open14 +/open15 diff --git a/testcases/kernel/syscalls/open/open15.c b/testcases/kernel/syscalls/open/open15.c new file mode 100644 index 000000000..09d7a1f3b --- /dev/null +++ b/testcases/kernel/syscalls/open/open15.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * Author: David Fenner + * Copilot: Jon Hendrickson + * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com + */ + +/*\ + * [Description] + * + * This test verifies that open() is working correctly on symlink() + * generated files. We generate a file via symlink, then we read both from file + * and symlink, comparing that data has been correctly written. + */ + +#include "tst_test.h" + +#define FILENAME "myfile.txt" +#define SYMBNAME "myfile_symlink" +#define BIG_STRING "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" + +static char buff_file[128]; +static char buff_symb[128]; +static int str_size; + +static void run(void) +{ + int fd_file, fd_symb; + + memset(buff_file, 0, sizeof(buff_file)); + memset(buff_symb, 0, sizeof(buff_symb)); + + tst_res(TINFO, "Create symlink"); + SAFE_TOUCH(FILENAME, 0777, NULL); + SAFE_SYMLINK(FILENAME, SYMBNAME); + + fd_file = SAFE_OPEN(FILENAME, O_RDONLY, 0777); + fd_symb = SAFE_OPEN(SYMBNAME, O_RDWR, 0777); + + tst_res(TINFO, "Write data via symlink"); + SAFE_WRITE(SAFE_WRITE_ALL, fd_symb, BIG_STRING, str_size); + SAFE_LSEEK(fd_symb, 0, 0); + + tst_res(TINFO, "Read data via file"); + SAFE_READ(1, fd_file, buff_file, str_size); + SAFE_LSEEK(fd_file, 0, 0); + + tst_res(TINFO, "Read data via symlink"); + SAFE_READ(1, fd_symb, buff_symb, str_size); + SAFE_LSEEK(fd_symb, 0, 0); + + TST_EXP_EXPR(!strncmp(buff_file, BIG_STRING, str_size), + "file data has been correctly written"); + + TST_EXP_EXPR(!strncmp(buff_file, buff_symb, str_size), + "file data is the equivalent to symlink generated file data"); + + SAFE_CLOSE(fd_file); + SAFE_CLOSE(fd_symb); + + SAFE_UNLINK(SYMBNAME); + SAFE_UNLINK(FILENAME); +} + +static void setup(void) +{ + str_size = strlen(BIG_STRING); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .needs_tmpdir = 1, +};