Testing statx syscall
PATCH v7 1/4 Testing statx syscall
From: vaishnavid <[email protected]>
* statx01.c: This file will check metadata of files like uid, gid, size, blocks, mode for normal file(1) and rdev_major, rdev_minor number for device file(2)
--- configure.ac | 1 + include/lapi/fs.h | 51 ++++++ include/lapi/stat.h | 270 +++++++++++++++++++++++++++++ include/lapi/syscalls/arm.in | 1 + include/lapi/syscalls/i386.in | 1 + include/lapi/syscalls/powerpc.in | 1 + include/lapi/syscalls/powerpc64.in | 1 + include/lapi/syscalls/s390.in | 1 + include/lapi/syscalls/sparc.in | 1 + include/lapi/syscalls/sparc64.in | 1 + include/lapi/syscalls/x86_64.in | 1 + m4/ltp-statx.m4 | 30 ++++ runtest/syscalls | 2 + testcases/kernel/syscalls/statx/.gitignore | 1 + testcases/kernel/syscalls/statx/Makefile | 26 +++ testcases/kernel/syscalls/statx/statx01.c | 199 +++++++++++++++++++++ 16 files changed, 588 insertions(+) create mode 100644 include/lapi/fs.h create mode 100644 include/lapi/stat.h create mode 100644 m4/ltp-statx.m4 create mode 100644 testcases/kernel/syscalls/statx/.gitignore create mode 100644 testcases/kernel/syscalls/statx/Makefile create mode 100644 testcases/kernel/syscalls/statx/statx01.c
configure.ac +1 -0
@@ -200,6 +200,7 @@ LTP_CHECK_OPENAT LTP_CHECK_EXECVEAT LTP_CHECK_RENAMEAT LTP_CHECK_RENAMEAT2 +LTP_CHECK_STATX LTP_CHECK_FALLOCATE LTP_CHECK_SYSCALL_FCNTL LTP_CHECK_SYSCALL_PERF_EVENT_OPEN
include/lapi/fs.h new file +51 -0
51 lines not on this page · raw message
include/lapi/stat.h new file +270 -0
270 lines not on this page · raw message
include/lapi/syscalls/arm.in +1 -0
@@ -342,3 +342,4 @@ getrandom (__NR_SYSCALL_BASE+384) memfd_create (__NR_SYSCALL_BASE+385) execveat (__NR_SYSCALL_BASE+387) copy_file_range (__NR_SYSCALL_BASE+391) +statx (__NR_SYSCALL+397)
include/lapi/syscalls/i386.in +1 -0
@@ -342,3 +342,4 @@ getrandom 355 memfd_create 356 execveat 358 copy_file_range 377 +statx 383
include/lapi/syscalls/powerpc.in +1 -0
@@ -348,3 +348,4 @@ renameat2 357 getrandom 359 memfd_create 360 copy_file_range 379 +statx 383
include/lapi/syscalls/powerpc64.in +1 -0
@@ -348,3 +348,4 @@ renameat2 357 getrandom 359 memfd_create 360 copy_file_range 379 +statx 383
include/lapi/syscalls/s390.in +1 -0
@@ -333,3 +333,4 @@ getrandom 349 memfd_create 350 execveat 354 copy_file_range 375 +statx 379
include/lapi/syscalls/sparc.in +1 -0
@@ -337,3 +337,4 @@ renameat2 345 getrandom 347 memfd_create 348 copy_file_range 357 +statx 360
include/lapi/syscalls/sparc64.in +1 -0
@@ -313,3 +313,4 @@ renameat2 345 getrandom 347 memfd_create 348 copy_file_range 357 +statx 360
include/lapi/syscalls/x86_64.in +1 -0
@@ -309,3 +309,4 @@ getrandom 318 memfd_create 319 execveat 322 copy_file_range 326 +statx 332
m4/ltp-statx.m4 new file +30 -0
@@ -0,0 +1,30 @@ +dnl +dnl Copyright (c) Zilogic Systems Pvt. Ltd., 2018 +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +dnl the GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +dnl + +dnl +dnl LTP_CHECK_STATX +dnl ---------------------------- +dnl +AC_DEFUN([LTP_CHECK_STATX],[ +AC_CHECK_FUNCS(statx,,) +AC_CHECK_HEADER(linux/fs.h,,,) +AC_MSG_CHECKING([for struct statx]) +AC_CHECK_MEMBERS([struct statx.stx_blksize, struct statx.stx_attributes, struct statx.stx_nlink, struct statx.stx_uid, struct statx.stx_gid, struct statx.stx_ino, struct statx.stx_size,struct statx.stx_mtime, struct statx.stx_atime, struct statx.stx_btime, struct statx.stx_ctime], AC_DEFINE(HAVE_STRUCT_STATX,1,[Define to 1 when struct statx is available]),,[[#include <linux/stat.h>]]) +AC_MSG_CHECKING([for struct statx_timestamp]) +AC_CHECK_MEMBERS([struct statx_timestamp.tv_sec, struct statx_timestamp.tv_nsec], AC_DEFINE(HAVE_STRUCT_STATX_TIMESTAMP,1,[Define to 1 when struct statx_timestamp is available]),,[[#include <linux/stat.h>]]) +])
runtest/syscalls +2 -0
@@ -1495,3 +1495,5 @@ memfd_create03 memfd_create03 memfd_create04 memfd_create04 copy_file_range01 copy_file_range01 + +statx01 statx01
testcases/kernel/syscalls/statx/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/statx01
testcases/kernel/syscalls/statx/Makefile new file +26 -0
@@ -0,0 +1,26 @@ +# +# Copyright (c) Zilogic Systems Pvt. Ltd., 2018 +# Email: [email protected] +# +# 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 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. +# +# 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 St, Fifth Floor, Boston, MA 02110-1301 USA +# + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64 + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/statx/statx01.c new file +199 -0
199 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v7 1/4 Testing statx syscall
Hi!
I've further split this patch into one that adds the configure checks and fallback headers and another that adds the first test.
And also did following adjustements:
* The right configure check for structure existence is AC_CHECK_TYPES()
Also things break badly if you check for the structure in the linux/stat.h but include sys/stat.h in the lapi fallback header, so we have to check for the sys/stat.h in the configure check as well.
* The statx() wrapper has to use tst_syscall() so that you get correct response when the syscall number is not defined on the system or in the fallback file
* Removed the full GPLv2 from the lapi headers, it's not needed when the SPDX identifier has been added, also since that is a machine readable string it has to be exactly SPDX-License-Identifier: GPL-2.0-or-later
And for the statx01:
* Added the newly added .needs_defs flag so that the test works fine on systems with /tmp mounted with nodev
* Changed the test to close the fd in the test setup, there is no reason to keep it open until cleanup
* Changed the SAFE_WRITE(0, ...) to SAFE_WRITE(1, ...) since we need to make sure the whole buffer has been written prior the test
* Remove the word "obtained" from the test messages as it was only making the messages unnecessarily longer
* The check for stx_block was bogus, after thinking about it we create file that contains 256 bytes so the number of blocks has to be reasonably small number. Btrfs tends to allocate page_size blocks, which means that the reported size there would be 128 which I suppose is good enough upper bound. So we now check that the reported number of blocks is > 0 and <= 128, which I guess is the best without dwelling into filesystem details.
* Removed the full GPLv2 from the lapi headers, it's not needed when the SPDX identifier has been added, also since that is a machine readable string it has to be exactly SPDX-License-Identifier: GPL-2.0-or-later
And pushed the resulting two patches, thanks!
Signature · 2 lines
Cyril Hrubis [email protected]