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