aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schlemmer <azarah@gentoo.org>2006-07-10 07:16:56 +0000
committerMartin Schlemmer <azarah@gentoo.org>2006-07-10 07:16:56 +0000
commitf4dec3394bce65a32a5c26987950d63849d6f3a6 (patch)
tree259d369321a6f823545ebbf6e1baa2f8f167200e /libsbutil/sbutil.h
parentAdd forgotten libsandbox.h. (diff)
downloadsandbox-f4dec3394bce65a32a5c26987950d63849d6f3a6.tar.gz
sandbox-f4dec3394bce65a32a5c26987950d63849d6f3a6.tar.bz2
sandbox-f4dec3394bce65a32a5c26987950d63849d6f3a6.zip
Move wrappers out of libsandbox.c. Move IO functions to
libsbutil. Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
Diffstat (limited to 'libsbutil/sbutil.h')
-rw-r--r--libsbutil/sbutil.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h
index efd9eab..09a12a3 100644
--- a/libsbutil/sbutil.h
+++ b/libsbutil/sbutil.h
@@ -29,6 +29,8 @@
#ifndef __SBUTIL_H__
#define __SBUTIL_H__
+#include <limits.h>
+
#include "config.h"
#include "localdecls.h"
#include "include/rcscripts/rcutil.h"
@@ -125,4 +127,21 @@ int get_tmp_dir(char *path);
bool is_env_on (const char *);
bool is_env_off (const char *);
+/* libsandbox need to use a wrapper for open */
+void sb_set_open(void *new_open);
+/* Convenience functions to reliably open, read and write to a file */
+int sb_open(const char *path, int flags, mode_t mode);
+size_t sb_read(int fd, void *buf, size_t count);
+size_t sb_write(int fd, const void *buf, size_t count);
+int sb_close(int fd);
+
+/* Macro for sb_read() to goto an label on error */
+#define SB_WRITE(_fd, _buf, _count, _error) \
+ do { \
+ size_t _n; \
+ _n = sb_write(_fd, _buf, _count); \
+ if (-1 == _n) \
+ goto _error; \
+ } while (0)
+
#endif /* __SBUTIL_H__ */