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) 2022 SUSE LLC Avinesh Kumar <avinesh.kumar@suse.com>
6f08c3bdfSopenharmony_ci */
7f08c3bdfSopenharmony_ci
8f08c3bdfSopenharmony_ci/*\
9f08c3bdfSopenharmony_ci * [Description]
10f08c3bdfSopenharmony_ci *
11f08c3bdfSopenharmony_ci * Verify that statfs() syscall executes successfully on all
12f08c3bdfSopenharmony_ci * available filesystems.
13f08c3bdfSopenharmony_ci */
14f08c3bdfSopenharmony_ci
15f08c3bdfSopenharmony_ci#include "tst_test.h"
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_ci#define MNT_POINT "mntpoint"
18f08c3bdfSopenharmony_ci#define TEMP_FILE MNT_POINT"/testfile"
19f08c3bdfSopenharmony_ci#define TEXT "dummy text"
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_cistatic void setup(void)
22f08c3bdfSopenharmony_ci{
23f08c3bdfSopenharmony_ci	int fd = SAFE_OPEN(TEMP_FILE, O_RDWR | O_CREAT, 0700);
24f08c3bdfSopenharmony_ci
25f08c3bdfSopenharmony_ci	SAFE_WRITE(SAFE_WRITE_ALL, fd, TEXT, strlen(TEXT));
26f08c3bdfSopenharmony_ci	SAFE_CLOSE(fd);
27f08c3bdfSopenharmony_ci}
28f08c3bdfSopenharmony_ci
29f08c3bdfSopenharmony_cistatic void run(void)
30f08c3bdfSopenharmony_ci{
31f08c3bdfSopenharmony_ci	struct statfs buf;
32f08c3bdfSopenharmony_ci
33f08c3bdfSopenharmony_ci	TST_EXP_PASS(statfs(TEMP_FILE, &buf));
34f08c3bdfSopenharmony_ci}
35f08c3bdfSopenharmony_ci
36f08c3bdfSopenharmony_cistatic struct tst_test test = {
37f08c3bdfSopenharmony_ci	.setup = setup,
38f08c3bdfSopenharmony_ci	.test_all = run,
39f08c3bdfSopenharmony_ci	.needs_root = 1,
40f08c3bdfSopenharmony_ci	.mount_device = 1,
41f08c3bdfSopenharmony_ci	.mntpoint = MNT_POINT,
42f08c3bdfSopenharmony_ci	.all_filesystems = 1
43f08c3bdfSopenharmony_ci};
44