1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 4f08c3bdfSopenharmony_ci * AUTHOR: William Roske, CO-PILOT: Dave Fenner 5f08c3bdfSopenharmony_ci * Copyright (c) 2023 SUSE LLC Avinesh Kumar <avinesh.kumar@suse.com> 6f08c3bdfSopenharmony_ci */ 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ci/*\ 9f08c3bdfSopenharmony_ci * [Description] 10f08c3bdfSopenharmony_ci * 11f08c3bdfSopenharmony_ci * Verify that mknod(2) successfully creates a filesystem node with 12f08c3bdfSopenharmony_ci * various modes. 13f08c3bdfSopenharmony_ci */ 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_ci#include <sys/sysmacros.h> 16f08c3bdfSopenharmony_ci#include "tst_test.h" 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_ci#define PATH "test_node" 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_cistatic int tcases[] = { 21f08c3bdfSopenharmony_ci S_IFREG | 0777, 22f08c3bdfSopenharmony_ci S_IFIFO | 0777, 23f08c3bdfSopenharmony_ci S_IFCHR | 0777, 24f08c3bdfSopenharmony_ci S_IFBLK | 0777, 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci S_IFREG | 04700, 27f08c3bdfSopenharmony_ci S_IFREG | 02700, 28f08c3bdfSopenharmony_ci S_IFREG | 06700, 29f08c3bdfSopenharmony_ci}; 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_ci 32f08c3bdfSopenharmony_cistatic void run(unsigned int i) 33f08c3bdfSopenharmony_ci{ 34f08c3bdfSopenharmony_ci dev_t dev = 0; 35f08c3bdfSopenharmony_ci 36f08c3bdfSopenharmony_ci if (S_ISCHR(tcases[i]) || S_ISBLK(tcases[i])) 37f08c3bdfSopenharmony_ci dev = makedev(1, 3); 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ci TST_EXP_PASS(mknod(PATH, tcases[i], dev), 40f08c3bdfSopenharmony_ci "mknod(PATH, %o, %ld)", 41f08c3bdfSopenharmony_ci tcases[i], dev); 42f08c3bdfSopenharmony_ci SAFE_UNLINK(PATH); 43f08c3bdfSopenharmony_ci} 44f08c3bdfSopenharmony_ci 45f08c3bdfSopenharmony_cistatic struct tst_test test = { 46f08c3bdfSopenharmony_ci .test = run, 47f08c3bdfSopenharmony_ci .tcnt = ARRAY_SIZE(tcases), 48f08c3bdfSopenharmony_ci .needs_root = 1, 49f08c3bdfSopenharmony_ci .needs_tmpdir = 1 50f08c3bdfSopenharmony_ci}; 51