diff mbox series

[1/5] Move preadv()/pwritev() backup definitions to LAPI

Message ID 20241101141111.104803-2-mdoucha@suse.cz
State Accepted
Headers show
Series Add LVM and NFS tests for file data integrity | expand

Commit Message

Martin Doucha Nov. 1, 2024, 2:11 p.m. UTC
Merge existing LAPI definitions of preadv2()/pwritev2() to lapi/uio.h
and add preadv()/pwritev() definitions from test code. Also fix minor
bugs in return value type and offset handling.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 include/lapi/pwritev2.h                       | 26 -----------------
 include/lapi/{preadv2.h => uio.h}             | 29 ++++++++++++++++++-
 testcases/kernel/syscalls/preadv/preadv.h     | 22 --------------
 testcases/kernel/syscalls/preadv/preadv01.c   |  2 +-
 testcases/kernel/syscalls/preadv/preadv02.c   |  2 +-
 testcases/kernel/syscalls/preadv/preadv03.c   |  2 +-
 testcases/kernel/syscalls/preadv2/preadv201.c |  2 +-
 testcases/kernel/syscalls/preadv2/preadv202.c |  2 +-
 testcases/kernel/syscalls/preadv2/preadv203.c |  2 +-
 testcases/kernel/syscalls/pwritev/pwritev.h   | 22 --------------
 testcases/kernel/syscalls/pwritev/pwritev01.c |  2 +-
 testcases/kernel/syscalls/pwritev/pwritev02.c |  2 +-
 testcases/kernel/syscalls/pwritev/pwritev03.c |  2 +-
 .../kernel/syscalls/pwritev2/pwritev201.c     |  2 +-
 .../kernel/syscalls/pwritev2/pwritev202.c     |  2 +-
 15 files changed, 39 insertions(+), 82 deletions(-)
 delete mode 100644 include/lapi/pwritev2.h
 rename include/lapi/{preadv2.h => uio.h} (51%)
 delete mode 100644 testcases/kernel/syscalls/preadv/preadv.h
 delete mode 100644 testcases/kernel/syscalls/pwritev/pwritev.h

Comments

Petr Vorel Nov. 1, 2024, 10:40 p.m. UTC | #1
Hi Martin,

> Merge existing LAPI definitions of preadv2()/pwritev2() to lapi/uio.h
> and add preadv()/pwritev() definitions from test code. Also fix minor
> bugs in return value type and offset handling.

Good catch int => ssize_t.

Obviously correct, merged with second commit.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/include/lapi/pwritev2.h b/include/lapi/pwritev2.h
deleted file mode 100644
index 48b53f463..000000000
--- a/include/lapi/pwritev2.h
+++ /dev/null
@@ -1,26 +0,0 @@ 
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
- * Author: Jinhui Huang <huangjh.jy@cn.fujitsu.com>
- */
-
-#ifndef LAPI_PWRITEV2_H__
-#define LAPI_PWRITEV2_H__
-
-#include "config.h"
-#include "lapi/syscalls.h"
-
-#if !defined(HAVE_PWRITEV2)
-
-/* LO_HI_LONG taken from glibc */
-# define LO_HI_LONG(val) (long) (val), (long) (((uint64_t) (val)) >> 32)
-
-static inline ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt,
-                               off_t offset, int flags)
-{
-	return tst_syscall(__NR_pwritev2, fd, iov, iovcnt,
-			   LO_HI_LONG(offset), flags);
-}
-#endif
-
-#endif /* LAPI_PWRITEV2_H__ */
diff --git a/include/lapi/preadv2.h b/include/lapi/uio.h
similarity index 51%
rename from include/lapi/preadv2.h
rename to include/lapi/uio.h
index db89547e2..a78103d99 100644
--- a/include/lapi/preadv2.h
+++ b/include/lapi/uio.h
@@ -14,11 +14,27 @@ 
 # define RWF_NOWAIT 0x00000008
 #endif
 
-#if !defined(HAVE_PREADV2)
 
 /* LO_HI_LONG taken from glibc */
 # define LO_HI_LONG(val) (long) (val), (long) (((uint64_t) (val)) >> 32)
 
+#if !defined(HAVE_PREADV)
+static inline ssize_t preadv(int fd, const struct iovec *iov, int iovcnt,
+	off_t offset)
+{
+	return tst_syscall(__NR_preadv, fd, iov, iovcnt, LO_HI_LONG(offset));
+}
+#endif
+
+#if !defined(HAVE_PWRITEV)
+static inline ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt,
+	off_t offset)
+{
+	return tst_syscall(__NR_pwritev, fd, iov, iovcnt, LO_HI_LONG(offset));
+}
+#endif
+
+#if !defined(HAVE_PREADV2)
 static inline ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt,
                               off_t offset, int flags)
 {
@@ -27,4 +43,15 @@  static inline ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt,
 }
 #endif
 
+#if !defined(HAVE_PWRITEV2)
+static inline ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt,
+                               off_t offset, int flags)
+{
+	return tst_syscall(__NR_pwritev2, fd, iov, iovcnt,
+			   LO_HI_LONG(offset), flags);
+}
+#endif
+
+#undef LO_HI_LONG
+
 #endif /* LAPI_PREADV2_H__ */
diff --git a/testcases/kernel/syscalls/preadv/preadv.h b/testcases/kernel/syscalls/preadv/preadv.h
deleted file mode 100644
index c715715b1..000000000
--- a/testcases/kernel/syscalls/preadv/preadv.h
+++ /dev/null
@@ -1,22 +0,0 @@ 
-/* SPDX-License-Identifier: GPL-2.0-or-later
- *
- * Copyright (c) 2015 Fujitsu Ltd.
- * Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
- * Copyright (c) Linux Test Project, 2016-2023
- */
-
-#ifndef PREADV_H
-#define PREADV_H
-
-#include <sys/types.h>
-#include "config.h"
-#include "lapi/syscalls.h"
-
-#if !defined(HAVE_PREADV)
-int preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
-{
-	return tst_syscall(__NR_preadv, fd, iov, iovcnt, offset);
-}
-#endif
-
-#endif /* RREADV_H */
diff --git a/testcases/kernel/syscalls/preadv/preadv01.c b/testcases/kernel/syscalls/preadv/preadv01.c
index 871b3ab42..d5e5bd95f 100644
--- a/testcases/kernel/syscalls/preadv/preadv01.c
+++ b/testcases/kernel/syscalls/preadv/preadv01.c
@@ -20,7 +20,7 @@ 
 #include <sys/uio.h>
 
 #include "tst_test.h"
-#include "preadv.h"
+#include "lapi/uio.h"
 
 #define CHUNK           64
 
diff --git a/testcases/kernel/syscalls/preadv/preadv02.c b/testcases/kernel/syscalls/preadv/preadv02.c
index 9977a4f48..19b194314 100644
--- a/testcases/kernel/syscalls/preadv/preadv02.c
+++ b/testcases/kernel/syscalls/preadv/preadv02.c
@@ -23,7 +23,7 @@ 
 #include <sys/uio.h>
 #include <unistd.h>
 #include "tst_test.h"
-#include "preadv.h"
+#include "lapi/uio.h"
 
 #define CHUNK           64
 
diff --git a/testcases/kernel/syscalls/preadv/preadv03.c b/testcases/kernel/syscalls/preadv/preadv03.c
index 558d85050..997e7a07c 100644
--- a/testcases/kernel/syscalls/preadv/preadv03.c
+++ b/testcases/kernel/syscalls/preadv/preadv03.c
@@ -22,7 +22,7 @@ 
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include "tst_test.h"
-#include "preadv.h"
+#include "lapi/uio.h"
 
 #define MNTPOINT	"mntpoint"
 #define FNAME	MNTPOINT"/file"
diff --git a/testcases/kernel/syscalls/preadv2/preadv201.c b/testcases/kernel/syscalls/preadv2/preadv201.c
index 110977290..50f5a2e01 100644
--- a/testcases/kernel/syscalls/preadv2/preadv201.c
+++ b/testcases/kernel/syscalls/preadv2/preadv201.c
@@ -20,7 +20,7 @@ 
 #include <sys/uio.h>
 
 #include "tst_test.h"
-#include "lapi/preadv2.h"
+#include "lapi/uio.h"
 
 #define CHUNK           64
 
diff --git a/testcases/kernel/syscalls/preadv2/preadv202.c b/testcases/kernel/syscalls/preadv2/preadv202.c
index 4e1e82ebd..fd3b7c9d7 100644
--- a/testcases/kernel/syscalls/preadv2/preadv202.c
+++ b/testcases/kernel/syscalls/preadv2/preadv202.c
@@ -25,7 +25,7 @@ 
 #include <unistd.h>
 
 #include "tst_test.h"
-#include "lapi/preadv2.h"
+#include "lapi/uio.h"
 
 #define CHUNK           64
 
diff --git a/testcases/kernel/syscalls/preadv2/preadv203.c b/testcases/kernel/syscalls/preadv2/preadv203.c
index c87deb674..42b265680 100644
--- a/testcases/kernel/syscalls/preadv2/preadv203.c
+++ b/testcases/kernel/syscalls/preadv2/preadv203.c
@@ -45,7 +45,7 @@ 
 
 #include "tst_test.h"
 #include "tst_safe_pthread.h"
-#include "lapi/preadv2.h"
+#include "lapi/uio.h"
 
 #define CHUNK_SZ 4123
 #define CHUNKS 60
diff --git a/testcases/kernel/syscalls/pwritev/pwritev.h b/testcases/kernel/syscalls/pwritev/pwritev.h
deleted file mode 100644
index e657dc7e6..000000000
--- a/testcases/kernel/syscalls/pwritev/pwritev.h
+++ /dev/null
@@ -1,22 +0,0 @@ 
-/* SPDX-License-Identifier: GPL-2.0-or-later
- *
- * Copyright (c) 2015 Fujitsu Ltd.
- * Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
- * Copyright (c) Linux Test Project, 2016-2023
- */
-
-#ifndef PWRITEV_H
-#define PWRITEV_H
-
-#include <sys/types.h>
-#include "config.h"
-#include "lapi/syscalls.h"
-
-#if !defined(HAVE_PWRITEV)
-int pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
-{
-	return tst_syscall(__NR_pwritev, fd, iov, iovcnt, offset);
-}
-#endif
-
-#endif /* PWRITEV_H */
diff --git a/testcases/kernel/syscalls/pwritev/pwritev01.c b/testcases/kernel/syscalls/pwritev/pwritev01.c
index f5fce81f2..1a4f672bf 100644
--- a/testcases/kernel/syscalls/pwritev/pwritev01.c
+++ b/testcases/kernel/syscalls/pwritev/pwritev01.c
@@ -18,7 +18,7 @@ 
 #include <string.h>
 #include <sys/uio.h>
 #include "tst_test.h"
-#include "pwritev.h"
+#include "lapi/uio.h"
 #include "tst_safe_prw.h"
 
 #define	CHUNK		64
diff --git a/testcases/kernel/syscalls/pwritev/pwritev02.c b/testcases/kernel/syscalls/pwritev/pwritev02.c
index 59a286847..25eb242f5 100644
--- a/testcases/kernel/syscalls/pwritev/pwritev02.c
+++ b/testcases/kernel/syscalls/pwritev/pwritev02.c
@@ -22,7 +22,7 @@ 
 #include <sys/uio.h>
 #include <unistd.h>
 #include "tst_test.h"
-#include "pwritev.h"
+#include "lapi/uio.h"
 
 #define CHUNK           64
 
diff --git a/testcases/kernel/syscalls/pwritev/pwritev03.c b/testcases/kernel/syscalls/pwritev/pwritev03.c
index 1bf9d5731..81ccee9be 100644
--- a/testcases/kernel/syscalls/pwritev/pwritev03.c
+++ b/testcases/kernel/syscalls/pwritev/pwritev03.c
@@ -22,7 +22,7 @@ 
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include "tst_test.h"
-#include "pwritev.h"
+#include "lapi/uio.h"
 #include "tst_safe_prw.h"
 
 #define MNTPOINT	"mntpoint"
diff --git a/testcases/kernel/syscalls/pwritev2/pwritev201.c b/testcases/kernel/syscalls/pwritev2/pwritev201.c
index 987412ba8..ae9047cdd 100644
--- a/testcases/kernel/syscalls/pwritev2/pwritev201.c
+++ b/testcases/kernel/syscalls/pwritev2/pwritev201.c
@@ -22,7 +22,7 @@ 
 #include <sys/uio.h>
 
 #include "tst_test.h"
-#include "lapi/pwritev2.h"
+#include "lapi/uio.h"
 #include "tst_safe_prw.h"
 
 #define CHUNK	64
diff --git a/testcases/kernel/syscalls/pwritev2/pwritev202.c b/testcases/kernel/syscalls/pwritev2/pwritev202.c
index 5a1c4c6b6..e4d80070d 100644
--- a/testcases/kernel/syscalls/pwritev2/pwritev202.c
+++ b/testcases/kernel/syscalls/pwritev2/pwritev202.c
@@ -26,7 +26,7 @@ 
 #include <unistd.h>
 
 #include "tst_test.h"
-#include "lapi/pwritev2.h"
+#include "lapi/uio.h"
 
 #define CHUNK	64