xref: /aosp_15_r20/external/ltp/lib/tst_ioctl.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) Linux Test Project, 2019-2023
4  */
5 
6 #include <sys/ioctl.h>
7 #include <linux/fs.h>
8 
9 #define TST_NO_DEFAULT_MAIN
10 
11 #include "tst_test.h"
12 #include "tst_fs.h"
13 
tst_fibmap(const char * filename)14 int tst_fibmap(const char *filename)
15 {
16 	int fd, block = 0;
17 
18 	fd = SAFE_OPEN(filename, O_RDWR | O_CREAT, 0666);
19 
20 	if (ioctl(fd, FIBMAP, &block)) {
21 		tst_res(TINFO | TERRNO, "FIBMAP ioctl is NOT supported");
22 		SAFE_CLOSE(fd);
23 		return 1;
24 	}
25 
26 	tst_res(TINFO, "FIBMAP ioctl is supported");
27 	SAFE_CLOSE(fd);
28 
29 	return 0;
30 }
31