include_directories : includes)
exes += exe
+exe = executable(
+ 'test_enosys',
+ 'tests/helpers/test_enosys.c',
+ include_directories : includes)
+exes += exe
+
############################################################
# XXX: HAVE_OPENAT
{ "move_mount", __NR_move_mount },
{ "open_tree", __NR_open_tree },
{ "fsopen", __NR_fsopen },
+ { "fallocate", __NR_fallocate },
};
int main(int argc, char **argv)
TS_HELPER_BYTESWAP="${ts_helpersdir}test_byteswap"
TS_HELPER_CPUSET="${ts_helpersdir}test_cpuset"
TS_HELPER_DMESG="${ts_helpersdir}test_dmesg"
+TS_HELPER_ENOSYS="${ts_helpersdir}test_enosys"
TS_HELPER_ISLOCAL="${ts_helpersdir}test_islocal"
TS_HELPER_ISMOUNTED="${ts_helpersdir}test_ismounted"
TS_HELPER_LIBFDISK_GPT="${ts_helpersdir}test_fdisk_gpt"
--- /dev/null
+test_enosys: fallocate r=-1 errno=Bad file descriptor
+test_enosys: fallocate r=-1 errno=Function not implemented
+test_enosys: fallocate r=-1 errno=Function not implemented
+test_enosys: fallocate r=-1 errno=Function not implemented
if LINUX
check_PROGRAMS += test_mkfds
test_mkfds_SOURCES = tests/helpers/test_mkfds.c
+
+check_PROGRAMS += test_enosys
+test_enosys_SOURCES = tests/helpers/test_enosys.c
endif
--- /dev/null
+/*
+ * Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+ int r;
+
+ if (argc != 2) {
+ fprintf(stderr, "invalid options\n");
+ return EXIT_FAILURE;
+ }
+
+ if (strcmp(argv[1], "fallocate") == 0) {
+ errno = 0;
+ r = fallocate(-1, 0, 0, 0);
+ errx(EXIT_SUCCESS, "fallocate r=%d errno=%s", r, strerror(errno));
+ }
+
+ errx(EXIT_FAILURE, "invalid mode %s", argv[1]);
+}
--- /dev/null
+#!/bin/bash
+
+# Copyright (C) 2022 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="enosys"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_ENOSYS"
+ts_check_test_command "$TS_HELPER_ENOSYS"
+
+"$TS_CMD_ENOSYS" true 2> /dev/null
+[ "$?" -eq "$TS_EXIT_NOTSUPP" ] && ts_skip "enosys does not work"
+
+ts_init_subtest basic
+
+FALLOCATE_TEST="$TS_HELPER_ENOSYS fallocate"
+
+$FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -s fallocate -- $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -s fsopen -s fallocate -- $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -s fallocate -s fsopen -- $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+
+ts_finalize_subtest
+
+ts_finalize