[LTP] [PATCH v5 4/8] syscalls/mknod04: Convert to new API
Ricardo B. Marlière
rbm@suse.com
Fri Jun 6 13:05:53 CEST 2025
On Thu Jun 5, 2025 at 9:52 AM -03, Ricardo B. Marlière wrote:
> From: Ricardo B. Marlière <rbm@suse.com>
>
> Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
> Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
> ---
> testcases/kernel/syscalls/mknod/mknod04.c | 319 ++++--------------------------
> 1 file changed, 40 insertions(+), 279 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/mknod/mknod04.c b/testcases/kernel/syscalls/mknod/mknod04.c
> index e0123ec07d95887a5fb8ab730103ba9531d4783d..ceb9565b4d2842b563637e882cedafb0e9731c01 100644
> --- a/testcases/kernel/syscalls/mknod/mknod04.c
> +++ b/testcases/kernel/syscalls/mknod/mknod04.c
> @@ -1,301 +1,62 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> /*
> - *
> - * Copyright (c) International Business Machines Corp., 2001
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
> - * the GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Copyright (c) International Business Machines Corp., 2001
> + * 07/2001 Ported by Wayne Boyer
> + * Copyright (c) 2025 SUSE LLC Ricardo B. Marlière <rbm@suse.com>
> */
>
> -/*
> - * Test Name: mknod04
> - *
> - * Test Description:
> - * Verify that mknod(2) succeeds when used to create a filesystem
> - * node on a directory with set group-ID bit set.
> - * The node created should not have group-ID bit set and its gid should be
> - * equal to the effective gid of the process.
> - *
> - * Expected Result:
> - * mknod() should return value 0 on success and node created should not
> - * have set group-ID bit set and its gid should be equal to the effective
> - * gid of the process.
> - *
> - * Algorithm:
> - * Setup:
> - * Setup signal handling.
> - * Create temporary directory.
> - * Pause for SIGUSR1 if option specified.
> - *
> - * Test:
> - * Loop if the proper options are given.
> - * Execute system call
> - * Check return code, if system call failed (return=-1)
> - * Log the errno and Issue a FAIL message.
> - * Otherwise,
> - * Verify the Functionality of system call
> - * if successful,
> - * Issue Functionality-Pass message.
> - * Otherwise,
> - * Issue Functionality-Fail message.
> - * Cleanup:
> - * Print errno log and/or timing stats if options given
> - * Delete the temporary directory created.
> - *
> - * Usage: <for command-line>
> - * mknod04 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
> - * where, -c n : Run n copies concurrently.
> - * -f : Turn off functionality Testing.
> - * -i n : Execute test n times.
> - * -I x : Execute test for x seconds.
> - * -P x : Pause for x seconds between iterations.
> - * -t : Turn on syscall timing.
> - *
> - * HISTORY
> - * 07/2001 Ported by Wayne Boyer
> - *
> - * RESTRICTIONS:
> - * This test should be run by 'super-user' (root) only.
> - *
> +/*\
> + * Verify that mknod(2) succeeds when used to create a filesystem node on a
> + * directory with set-group-ID bit set. The node created should not have
> + * set-group-ID bit set and its gid should be equal to the effective
> + * gid of the process.
> */
>
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <unistd.h>
> -#include <errno.h>
> -#include <string.h>
> -#include <signal.h>
> #include <pwd.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -
> -#include "test.h"
> -#include "safe_macros.h"
> -
> -#define LTPUSER "nobody"
> -#define MODE_RWX S_IFIFO | S_IRWXU | S_IRWXG | S_IRWXO
> -#define MODE_SGID S_IFIFO | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO
> -#define DIR_TEMP "testdir_4"
> -#define TNODE "tnode_%d"
> +#include "tst_uid.h"
> +#include "tst_test.h"
>
> -struct stat buf; /* struct. to hold stat(2) o/p contents */
> -struct passwd *user1; /* struct. to hold getpwnam(3) o/p contents */
> +#define MODE_RWX 0777
> +#define MODE_SGID (S_ISGID | 0777)
I just realized I dropped S_IFIFO here aswell.
More information about the ltp
mailing list