Signed-off-by: Xing Gu <gux.f...@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