• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) Wipro Technologies Ltd, 2003.  All Rights Reserved.
4  *
5  * Check that ustat() succeeds given correct parameters.
6  */
7 
8 #include <unistd.h>
9 #include <errno.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 
13 #include "lapi/syscalls.h"
14 #include "lapi/ustat.h"
15 #include "tst_test.h"
16 
17 static dev_t dev_num;
18 
run(void)19 void run(void)
20 {
21 	struct ustat ubuf;
22 
23 	TEST(tst_syscall(__NR_ustat, dev_num, &ubuf));
24 
25 	if (TST_RET == -1)
26 		tst_res(TFAIL | TTERRNO, "ustat(2) failed");
27 	else
28 		tst_res(TPASS, "ustat(2) passed");
29 }
30 
setup(void)31 static void setup(void)
32 {
33 	struct stat buf;
34 
35 	/* Find a valid device number */
36 	SAFE_STAT("/", &buf);
37 
38 	dev_num = buf.st_dev;
39 }
40 
41 static struct tst_test test = {
42 	.test_all = run,
43 	.setup = setup,
44 };
45