ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
* [LTP] [PATCH v1 1/3] tst_safe_file_at: Add SAFE_FCHOWNAT macro
@ 2022-08-03 10:19 Yang Xu
  2022-08-03 10:19 ` [LTP] [PATCH v1 2/3] tst_cgroup: Add safe_cg_open and safe_cg_fchown functions Yang Xu
  2022-08-03 10:19 ` [LTP] [PATCH v1 3/3] memcontrol05: " Yang Xu
  0 siblings, 2 replies; 24+ messages in thread
From: Yang Xu @ 2022-08-03 10:19 UTC (permalink / raw)
  To: ltp

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 include/tst_safe_file_at.h |  9 +++++++++
 lib/tst_safe_file_at.c     | 20 ++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/include/tst_safe_file_at.h b/include/tst_safe_file_at.h
index 8df34227f..e253198e6 100644
--- a/include/tst_safe_file_at.h
+++ b/include/tst_safe_file_at.h
@@ -25,6 +25,10 @@
 #define SAFE_UNLINKAT(dirfd, path, flags)				\
 	safe_unlinkat(__FILE__, __LINE__, (dirfd), (path), (flags))
 
+#define SAFE_FCHOWNAT(dirfd, path, owner, group, flags)			\
+	safe_fchownat(__FILE__, __LINE__,				\
+			(dirfd), (path), (owner), (group), (flags))
+
 const char *tst_decode_fd(const int fd)
 			  __attribute__((warn_unused_result));
 
@@ -58,4 +62,9 @@ int safe_unlinkat(const char *const file, const int lineno,
 		  const int dirfd, const char *const path, const int flags)
 		  __attribute__ ((nonnull));
 
+int safe_fchownat(const char *const file, const int lineno,
+		  const int dirfd, const char *const path, uid_t owner,
+		  gid_t group, int flags)
+		  __attribute__ ((nonnull));
+
 #endif
diff --git a/lib/tst_safe_file_at.c b/lib/tst_safe_file_at.c
index ca8ef2f68..6370a68e5 100644
--- a/lib/tst_safe_file_at.c
+++ b/lib/tst_safe_file_at.c
@@ -195,3 +195,23 @@ int safe_unlinkat(const char *const file, const int lineno,
 
 	return rval;
 }
+
+int safe_fchownat(const char *const file, const int lineno,
+		  const int dirfd, const char *const path, uid_t owner, gid_t group, int flags)
+{
+	int rval;
+
+	rval = fchownat(dirfd, path, owner, group, flags);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			 "fchownat(%d<%s>, '%s', %d, %d, %d) failed", dirfd,
+			 tst_decode_fd(dirfd), path, owner, group, flags);
+	} else if (rval) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			 "Invalid fchownat(%d<%s>, '%s', %d, %d, %d) return value %d",
+			 dirfd, tst_decode_fd(dirfd), path, owner, group, flags, rval);
+	}
+
+	return rval;
+}
-- 
2.27.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-08-26  6:33 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-03 10:19 [LTP] [PATCH v1 1/3] tst_safe_file_at: Add SAFE_FCHOWNAT macro Yang Xu
2022-08-03 10:19 ` [LTP] [PATCH v1 2/3] tst_cgroup: Add safe_cg_open and safe_cg_fchown functions Yang Xu
2022-08-04 10:24   ` Richard Palethorpe
2022-08-16  6:19     ` xuyang2018.jy
2022-08-16  8:18       ` Richard Palethorpe
2022-08-18  8:05         ` xuyang2018.jy
2022-08-18  9:03           ` Richard Palethorpe
2022-08-23  7:10             ` xuyang2018.jy
2022-08-23  9:55               ` xuyang2018.jy
2022-08-18  9:00         ` [LTP] [RFC v2 1/3] tst_safe_file_at: Add SAFE_FCHOWNAT macro Yang Xu
2022-08-18  9:00           ` [LTP] [RFC v2 2/3] tst_cgroup: Add safe_cg_open and safe_cg_fchown functions Yang Xu
2022-08-18  9:00           ` [LTP] [RFC v2 3/3] memcontrol05: copy from kernel selftest test_cgcore_lesser_euid_open Yang Xu
2022-08-23 11:01             ` [LTP] [PATCH v3 1/3] tst_safe_file_at: Add SAFE_FCHOWNAT macro Yang Xu
2022-08-23 11:01               ` [LTP] [PATCH v3 2/3] tst_cgroup: Add safe_cg_open and safe_cg_fchown functions Yang Xu
2022-08-25 14:57                 ` Richard Palethorpe
2022-08-25 16:08                   ` Richard Palethorpe
2022-08-26  2:04                     ` xuyang2018.jy
2022-08-26  3:59                     ` [LTP] [PATCH v4 1/3] tst_safe_file_at: Add SAFE_FCHOWNAT macro Yang Xu
2022-08-26  3:59                       ` [LTP] [PATCH v4 2/3] tst_cgroup: Add safe_cg_open and safe_cg_fchown functions Yang Xu
2022-08-26  5:54                         ` Richard Palethorpe
2022-08-26  6:33                           ` xuyang2018.jy
2022-08-26  3:59                       ` [LTP] [PATCH v4 3/3] cgroup_core01: copy from kernel selftest test_cgcore_lesser_euid_open Yang Xu
2022-08-23 11:01               ` [LTP] [PATCH v3 3/3] core01: " Yang Xu
2022-08-03 10:19 ` [LTP] [PATCH v1 3/3] memcontrol05: " Yang Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).