xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/mknod/mknod09.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker 
3*49cdfc7eSAndroid Build Coastguard Worker /*
4*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (C) Bull S.A. 2001
5*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (c) International Business Machines  Corp., 2001
6*49cdfc7eSAndroid Build Coastguard Worker  * 05/2002 Ported by André Merlier
7*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (C) 2024 SUSE LLC Andrea Manzini <[email protected]>
8*49cdfc7eSAndroid Build Coastguard Worker  */
9*49cdfc7eSAndroid Build Coastguard Worker 
10*49cdfc7eSAndroid Build Coastguard Worker /*\
11*49cdfc7eSAndroid Build Coastguard Worker  * [Description]
12*49cdfc7eSAndroid Build Coastguard Worker  *
13*49cdfc7eSAndroid Build Coastguard Worker  * Verify that mknod() fails with -1 and sets errno to EINVAL if the mode is
14*49cdfc7eSAndroid Build Coastguard Worker  * different than a normal file, device special file or FIFO.
15*49cdfc7eSAndroid Build Coastguard Worker  */
16*49cdfc7eSAndroid Build Coastguard Worker 
17*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
18*49cdfc7eSAndroid Build Coastguard Worker 
check_mknod(void)19*49cdfc7eSAndroid Build Coastguard Worker static void check_mknod(void)
20*49cdfc7eSAndroid Build Coastguard Worker {
21*49cdfc7eSAndroid Build Coastguard Worker 	TST_EXP_FAIL(mknod("tnode", S_IFMT, 0), EINVAL);
22*49cdfc7eSAndroid Build Coastguard Worker }
23*49cdfc7eSAndroid Build Coastguard Worker 
24*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
25*49cdfc7eSAndroid Build Coastguard Worker 	.test_all = check_mknod,
26*49cdfc7eSAndroid Build Coastguard Worker 	.needs_tmpdir = 1,
27*49cdfc7eSAndroid Build Coastguard Worker 	.needs_root = 1
28*49cdfc7eSAndroid Build Coastguard Worker };
29