public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/3] lib: Add SAFE_CHOWN()
@ 2014-06-13  2:53 Xing Gu
  2014-06-13  2:53 ` [LTP] [PATCH 2/3] utimes/utimes01.c: cleanup Xing Gu
  2014-06-13  2:53 ` [LTP] [PATCH 3/3] utimes/utimes01.c: add EPERM and EROFS error value tests Xing Gu
  0 siblings, 2 replies; 4+ messages in thread
From: Xing Gu @ 2014-06-13  2:53 UTC (permalink / raw)
  To: ltp-list

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 include/safe_macros.h |  5 +++++
 lib/safe_macros.c     | 15 +++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/safe_macros.h b/include/safe_macros.h
index ea1e976..f521347 100644
--- a/include/safe_macros.h
+++ b/include/safe_macros.h
@@ -231,6 +231,11 @@ int safe_fchmod(const char *file, const int lineno, void (cleanup_fn)(void),
 #define SAFE_FCHMOD(cleanup_fn, fd, mode) \
 	safe_fchmod(__FILE__, __LINE__, (cleanup_fn), (fd), (mode))
 
+int safe_chown(const char *file, const int lineno, void (cleanup_fn)(void),
+			const char *path, uid_t owner, gid_t group);
+#define SAFE_CHOWN(cleanup_fn, path, owner, group) \
+	safe_chown(__FILE__, __LINE__, (cleanup_fn), (path), (owner), (group))
+
 int safe_fchown(const char *file, const int lineno, void (cleanup_fn)(void),
                 int fd, uid_t owner, gid_t group);
 #define SAFE_FCHOWN(cleanup_fn, fd, owner, group) \
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index 13cc08e..a07cffa 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -662,6 +662,21 @@ int safe_fchmod(const char *file, const int lineno,
 	return rval;
 }
 
+int safe_chown(const char *file, const int lineno, void (cleanup_fn)(void),
+			const char *path, uid_t owner, gid_t group)
+{
+	int rval;
+
+	rval = chown(path, owner, group);
+
+	if (rval == -1) {
+		tst_brkm(TBROK | TERRNO, cleanup_fn,
+			"%s:%d: chown(%s,%d,%d) failed",
+			file, lineno, path, owner, group);
+	}
+
+	return rval;
+}
 
 int safe_fchown(const char *file, const int lineno, void (cleanup_fn)(void),
                 int fd, uid_t owner, gid_t group)
-- 
1.9.3


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-06-17 14:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-13  2:53 [LTP] [PATCH 1/3] lib: Add SAFE_CHOWN() Xing Gu
2014-06-13  2:53 ` [LTP] [PATCH 2/3] utimes/utimes01.c: cleanup Xing Gu
2014-06-17 14:12   ` chrubis
2014-06-13  2:53 ` [LTP] [PATCH 3/3] utimes/utimes01.c: add EPERM and EROFS error value tests Xing Gu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox