diff options
author | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
commit | dbb41ce2b7f309d394054a6bd1e33afd578798a5 (patch) | |
tree | 6a31092063d9f2fb5ac5720ec6759040e793c3d5 /src/kernel/tests/lib/tst_ioctl.c | |
parent | Set Linux kernel version to unknown if it is not detectable (diff) | |
download | xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.gz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.xz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.zip |
Move the source code of all xloop components to the common 'src' directory
Diffstat (limited to 'src/kernel/tests/lib/tst_ioctl.c')
-rw-r--r-- | src/kernel/tests/lib/tst_ioctl.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/kernel/tests/lib/tst_ioctl.c b/src/kernel/tests/lib/tst_ioctl.c new file mode 100644 index 0000000..364220b --- /dev/null +++ b/src/kernel/tests/lib/tst_ioctl.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <linux/fs.h> + +#define TST_NO_DEFAULT_MAIN + +#include "tst_test.h" + +int tst_fibmap(const char *filename) +{ + /* test if FIBMAP ioctl is supported */ + int fd, block = 0; + + fd = open(filename, O_RDWR | O_CREAT, 0666); + if (fd < 0) { + tst_res(TWARN | TERRNO, + "open(%s, O_RDWR | O_CREAT, 0666) failed", filename); + return -1; + } + + if (ioctl(fd, FIBMAP, &block)) { + tst_res(TINFO | TERRNO, "FIBMAP ioctl is NOT supported"); + close(fd); + return 1; + } + tst_res(TINFO, "FIBMAP ioctl is supported"); + + if (close(fd)) { + tst_res(TWARN | TERRNO, "close(fd) failed"); + return -1; + } + return 0; +} |