summaryrefslogtreecommitdiff
path: root/tests/file_ioctl.c
blob: 0fe17b15ddf037cd88dfba2c9a599820c271984b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "tests.h"

#ifdef HAVE_LINUX_FIEMAP_H

# include <stdio.h>
# include <sys/ioctl.h>
# include <linux/fiemap.h>
# include <linux/fs.h>
# include "xlat.h"
# include "xlat/fiemap_flags.h"

static void
test_fiemap(void)
{
	(void) tail_alloc(1);
	struct fiemap *const args = tail_alloc(sizeof(*args));

	printf("ioctl(-1, FS_IOC_FIEMAP, {fm_start=%" PRI__u64
	       ", fm_length=%" PRI__u64", fm_flags=",
	       args->fm_start, args->fm_length);
	printflags(fiemap_flags, args->fm_flags, "FIEMAP_FLAG_???");
	printf(", fm_extent_count=%u})", args->fm_extent_count);
	ioctl(-1, FS_IOC_FIEMAP, args);
	printf(" = -1 EBADF (%m)\n");

	/* The live version of this test is in btrfs.c */
}

/* clone and dedupe ioctls are in btrfs.c since they originated there */

int
main(int argc, char *argv[])
{
	test_fiemap();

	puts("+++ exited with 0 +++");

	return 0;
}

#else

SKIP_MAIN_UNDEFINED("HAVE_LINUX_FIEMAP_H")

#endif