[PATCH 3/3] lapi: Move renameat2.h into lapi/stdio.h

Petr Vorel <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
Fallback definition for renameat2() is currently needed at least for
Musl < v1.2.6 (in current Alpine in CI) and openSUSE Leap 42.2
(still being supported due the same SLES version being tested).

testcases/kernel/syscalls/renameat2/renameat2.h was a test specific
header which contains only fallback for renameat2(). Move it into
include/lapi/stdio.h with minor cleanup. That will help to use it in
other tests.

Signed-off-by: Petr Vorel <[email protected]>
---
Originally triggered by fanotify13.c fix, see the cover letter.

 include/lapi/stdio.h                          | 25 +++++++++++++
 .../kernel/syscalls/renameat2/renameat2.h     | 35 -------------------
 .../kernel/syscalls/renameat2/renameat201.c   |  4 +--
 .../kernel/syscalls/renameat2/renameat202.c   |  2 +-
 .../kernel/syscalls/renameat2/renameat203.c   |  4 +--
 5 files changed, 30 insertions(+), 40 deletions(-)
 create mode 100644 include/lapi/stdio.h
 delete mode 100644 testcases/kernel/syscalls/renameat2/renameat2.h

diff --git a/include/lapi/stdio.h b/include/lapi/stdio.h
new file mode 100644
index 0000000000..cdcb3e2062
--- /dev/null
+++ b/include/lapi/stdio.h
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2015 Cedric Hnyda <chnyda-IBi9RG/[email protected]>
+ * Copyright (c) 2026 Petr Vorel <[email protected]>
+ */
+
+#ifndef LAPI_STDIO_H__
+#define LAPI_STDIO_H__
+
+#include "config.h"
+#include "lapi/syscalls.h"
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+#ifndef HAVE_RENAMEAT2
+int renameat2(int olddirfd, const char *oldpath, int newdirfd,
+				const char *newpath, unsigned int flags)
+{
+	return tst_syscall(__NR_renameat2, olddirfd, oldpath, newdirfd,
+						newpath, flags);
+}
+#endif
+
+#endif /* LAPI_STDIO_H__ */
diff --git a/testcases/kernel/syscalls/renameat2/renameat2.h b/testcases/kernel/syscalls/renameat2/renameat2.h
deleted file mode 100644
index c4688ed535..0000000000
--- a/testcases/kernel/syscalls/renameat2/renameat2.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Cedric Hnyda <chnyda-IBi9RG/[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 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 the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef RENAMEAT2_H
-#define RENAMEAT2_H
-
-#include <sys/types.h>
-#include "config.h"
-#include "lapi/syscalls.h"
-
-#if !defined(HAVE_RENAMEAT2)
-int renameat2(int olddirfd, const char *oldpath, int newdirfd,
-				const char *newpath, unsigned int flags)
-{
-	return tst_syscall(__NR_renameat2, olddirfd, oldpath, newdirfd,
-						newpath, flags);
-}
-#endif
-
-#endif /* RENAMEAT2_H */
diff --git a/testcases/kernel/syscalls/renameat2/renameat201.c b/testcases/kernel/syscalls/renameat2/renameat201.c
index a7ec388ab4..0ffb147af1 100644
--- a/testcases/kernel/syscalls/renameat2/renameat201.c
+++ b/testcases/kernel/syscalls/renameat2/renameat201.c
@@ -15,9 +15,9 @@
 
 #define _GNU_SOURCE
 
-#include "lapi/fcntl.h"
 #include "tst_test.h"
-#include "renameat2.h"
+#include "lapi/fcntl.h"
+#include "lapi/stdio.h"
 
 #define TEST_DIR "test_dir/"
 #define TEST_DIR2 "test_dir2/"
diff --git a/testcases/kernel/syscalls/renameat2/renameat202.c b/testcases/kernel/syscalls/renameat2/renameat202.c
index 17acd7206e..79c2abaea9 100644
--- a/testcases/kernel/syscalls/renameat2/renameat202.c
+++ b/testcases/kernel/syscalls/renameat2/renameat202.c
@@ -12,7 +12,7 @@
 
 #include "lapi/fcntl.h"
 #include "tst_test.h"
-#include "renameat2.h"
+#include "lapi/stdio.h"
 
 #define TEST_DIR "test_dir/"
 #define TEST_DIR2 "test_dir2/"
diff --git a/testcases/kernel/syscalls/renameat2/renameat203.c b/testcases/kernel/syscalls/renameat2/renameat203.c
index dba12e48b3..262c871983 100644
--- a/testcases/kernel/syscalls/renameat2/renameat203.c
+++ b/testcases/kernel/syscalls/renameat2/renameat203.c
@@ -13,9 +13,9 @@
 
 #define _GNU_SOURCE
 
-#include "lapi/fcntl.h"
 #include "tst_test.h"
-#include "renameat2.h"
+#include "lapi/fcntl.h"
+#include "lapi/stdio.h"
 
 #define TEST_DIR "test_dir/"
 #define TEST_DIR2 "test_dir2/"
-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.