Testing statx syscall
PATCH v6 1/1 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)
* statx02.c: This file will check flag like AT_EMPTY_PATH, AT_SYMLINK_NOFOLLOW
* AT_EMPTY_PATH: If pathname is an empty string, operate on the file referred to by dirfd.
* AT_SYMLINK_NOFOLLOW:If pathname is a symbolic link, do not dereference it: instead return information about the link itself.
* stat03.c: This file will check error code(errno) by providing required input in statx argument syscall. The following errno are
checked: EBADF, EBADF, ENAMETOOLONG, ENOENT, ENOTDIR, EFAULT.
* statx04.c: This file will check attribute flag by defining flag to that directory and checks another directory with no flags. Changes from V5 to V6:
* Made changes in the m4 file and LTP_CHECK_STATX added to configure.ac
* Replaced arch-specific printf format with general one.
* Added ifndef cases for structs in stat.h.
--- configure.ac | 1 + include/lapi/fs.h | 47 +++++ 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 | 55 ++++++ runtest/syscalls | 5 + testcases/kernel/syscalls/statx/.gitignore | 4 + testcases/kernel/syscalls/statx/Makefile | 26 +++ testcases/kernel/syscalls/statx/statx01.c | 199 +++++++++++++++++++++ testcases/kernel/syscalls/statx/statx02.c | 144 +++++++++++++++ testcases/kernel/syscalls/statx/statx03.c | 134 ++++++++++++++ testcases/kernel/syscalls/statx/statx04.c | 217 +++++++++++++++++++++++ 19 files changed, 1110 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 create mode 100644 testcases/kernel/syscalls/statx/statx02.c create mode 100644 testcases/kernel/syscalls/statx/statx03.c create mode 100644 testcases/kernel/syscalls/statx/statx04.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 +47 -0
47 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 +55 -0
55 lines not on this page · raw message
runtest/syscalls +5 -0
@@ -1285,6 +1285,11 @@ statfs03_64 statfs03_64 statvfs01 statvfs01 statvfs02 statvfs02 +statx01 statx01 +statx02 statx02 +statx03 statx03 +statx04 statx04 + stime01 stime01 stime02 stime02
testcases/kernel/syscalls/statx/.gitignore new file +4 -0
@@ -0,0 +1,4 @@ +/statx01 +/statx02 +/statx03 +/statx04
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
testcases/kernel/syscalls/statx/statx02.c new file +144 -0
144 lines not on this page · raw message
testcases/kernel/syscalls/statx/statx03.c new file +134 -0
134 lines not on this page · raw message
testcases/kernel/syscalls/statx/statx04.c new file +217 -0
217 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 1/1 Testing statx syscall
Hi Vaishnavi,
Quoted 23 lines
From: vaishnavid <[email protected]>
*
statx01.c: This file will check metadata of files like uid, gid, size, blocks, mode for normal file(1) andrdev_major,rdev_minornumber for device file(2)*
statx02.c: This file will check flag likeAT_EMPTY_PATH,AT_SYMLINK_NOFOLLOW
*AT_EMPTY_PATH: If pathname is an empty string, operate on the file referred to by dirfd.
* AT_SYMLINK_NOFOLLOW:If pathname is a symbolic link, do not dereference it: instead return information about the link itself.*
stat03.c: This file will check error code(errno) by providing required input in statx argument syscall. The following errno are
checked: EBADF, EBADF, ENAMETOOLONG, ENOENT, ENOTDIR, EFAULT.*
statx04.c: This file will check attribute flag by defining flag to that directory and checks another directory with no flags. Changes from V5 to V6:
* Made changes in the m4 file andLTP_CHECK_STATXadded to configure.ac
* Replaced arch-specific printf format with general one.
* Added ifndef cases for structs instat.h.
...
Quoted 1 line
19 files changed, 1110 insertions(+)
You know what prevents you patch to get better review: it's huge. Splitting it a bit would help the review process.
Quoted 1 line
+++
b/include/lapi/fs.h
...
include/lapi/fs.h line 5
Quoted 5 lines
include/lapi/fs.h new file +5
-0+// SPDX-License-Identifier: GPL-2.0 or later +/* +* Referred from linux kernel -github/torvalds/linux/include/uapi/linux/fs.h +* Copyright (c) Zilogic Systems Pvt. Ltd., 2018 +* Email: [email protected]
This GPL info should be omitted, as it's what SPDX-License-Identifier does. (+ preferred form is without spaces: SPDX-License-Identifier: GPL-2.0-or-later).
Quoted 6 lines
+ *
+ * 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.
+ *
Quoted 8 lines
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
I'd prefer first include <linux/fs.h> (or wherever these definitions origin) to have a chance to get these definitions.
#ifdef HAVE_LINUX_FS_H
# include <linux/fs.h> #endif
+ Add this header to AC_CHECK_HEADERS in configure.ac
include/lapi/fs.h line 21
Quoted 2 lines
include/lapi/fs.h new file +2
-0+#ifndef FS_H +#define FS_H
Also please use LAPI_FS_H (be consistent with include/lapi/stat.h).
Quoted 26 lines
include/lapi/fs.h new file +26
-0+ +#ifndef FS_IOC_GETFLAGS +#define FS_IOC_GETFLAGS _IOR('f', 1, long) +#endif + +#ifndef FS_IOC_SETFLAGS +#define FS_IOC_SETFLAGS _IOW('f', 2, long) +#endif + +#ifndef FS_COMPR_FL +#define FS_COMPR_FL 0x00000004/* Compress file */ +#endif + +#ifndef FS_IMMUTABLE_FL +#define FS_IMMUTABLE_FL 0x00000010/* Immutable file */ +#endif + +#ifndef FS_APPEND_FL +#define FS_APPEND_FL 0x00000020/* writes to file may only append */ +#endif + +#ifndef FS_NODUMP_FL +#define FS_NODUMP_FL 0x00000040/* do not dump file */ +#endif + +#endif
...
Quoted 1 line
+++ b/m4/ltp-statx.m4
...
m4/ltp-statx.m4 line 27
Quoted 5 lines
m4/ltp-statx.m4 new file +5
-0+AC_DEFUN([LTP_CHECK_STATX],[ +AC_CHECK_FUNCS(statx,,) +AC_MSG_CHECKING([for struct statx]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +#define _GNU_SOURCE
Why _GNU_SOURCE? IMHO not needed.
Quoted 1 line
+#include <
sys/stat.h>
struct statx is in <linux/stat.h>
Using <sys/stat.h> give wrong result (+ the same for statx_timestamp).
Quoted 17 lines
m4/ltp-statx.m4 new file +17
-0+int main(void) { + struct statx buff_obj; + return 0; +}])],[has_statx="yes"]) + +if test "x$has_statx" = xyes; then + AC_DEFINE(HAVE_STRUCT_STATX,1,[Define to 1 if you have struct statx]) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi +AC_MSG_CHECKING([for struct statx_timestamp]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +#define _GNU_SOURCE +#include <sys/stat.h> +int main(void) { + struct statx_timestamp time;
m4/ltp-statx.m4 line 55
Quoted 10 lines
m4/ltp-statx.m4 new file +10
-0+ return 0; +}])],[has_statx_timestamp="yes"]) + +if test "x$has_statx_timestamp" = xyes; then + AC_DEFINE(HAVE_STRUCT_STATX_TIMESTAMP,1,[Define to 1 if you have struct statx_timestamp]) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi +])
IMHO the previous version was simpler (testing just some members of statx – testing all takes too much time. Not sure which ones make sense to test):
dnl SPDX-License-Identifier: GPL-2.0-or-later
dnl Copyright (c) Zilogic Systems Pvt. Ltd., 2018
dnl Email: [email protected]
AC_DEFUN([LTP_CHECK_STATX],[AC_CHECK_FUNCS([statx])AC_CHECK_MEMBERS([struct statx.stx_mask, struct statx.stx_blksize],,, [[#include <linux/stat.h>]]) AC_CHECK_MEMBERS([struct statx_timestamp.tv_sec, struct statx_timestamp.tv_nsec],,, [[#include <linux/stat.h>]]) ])
Kind regards,
Petr