aboutsummaryrefslogtreecommitdiffstats
path: root/pseudo_ipc.h
diff options
context:
space:
mode:
authorPeter Seebach <seebs@eee12.(none)>2010-03-26 14:48:36 -0500
committerPeter Seebach <seebs@eee12.(none)>2010-03-26 14:50:04 -0500
commit80259da816b82c5bdfbf9515935823a157f5d0e9 (patch)
treef5120633e788d0d36ea2133d436d52c563d08d98 /pseudo_ipc.h
parentcaeebc0dd6ff538629687b55a5ce72554a7c3f34 (diff)
downloadpseudo-80259da816b82c5bdfbf9515935823a157f5d0e9.tar.gz
pseudo-80259da816b82c5bdfbf9515935823a157f5d0e9.tar.bz2
pseudo-80259da816b82c5bdfbf9515935823a157f5d0e9.zip
Track file open flags
This patch adds support for checking whether a file was opened for reading, writing, or both, as well as tracking append flags. It is not very well tested. This is preparation for improved host contamination checking.
Diffstat (limited to 'pseudo_ipc.h')
-rw-r--r--pseudo_ipc.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/pseudo_ipc.h b/pseudo_ipc.h
index 50794a1..063a1ef 100644
--- a/pseudo_ipc.h
+++ b/pseudo_ipc.h
@@ -33,7 +33,7 @@ typedef struct {
pseudo_msg_type_t type;
op_id_t op;
res_id_t result;
- int xerrno;
+ int access;
int client;
int fd;
dev_t dev;
@@ -47,6 +47,22 @@ typedef struct {
char path[];
} pseudo_msg_t;
+enum {
+ PSA_EXEC = 1,
+ PSA_WRITE = (PSA_EXEC << 1),
+ PSA_READ = (PSA_WRITE << 1),
+ PSA_APPEND = (PSA_READ << 1),
+} pseudo_access_t;
+
+#define PSEUDO_ACCESS_MAP(mode, fcntl_access, pseudo_access) ((((mode) & O_ACCMODE) == (fcntl_access)) ? (pseudo_access) : (0))
+#define PSEUDO_ACCESS_FLAG(mode, fcntl_access, pseudo_access) (((mode) & (fcntl_access)) ? (pseudo_access) : (0))
+#define PSEUDO_ACCESS(mode) ( \
+ PSEUDO_ACCESS_MAP(mode, O_RDONLY, PSA_READ) | \
+ PSEUDO_ACCESS_MAP(mode, O_WRONLY, PSA_WRITE) | \
+ PSEUDO_ACCESS_MAP(mode, O_RDWR, PSA_READ | PSA_WRITE) | \
+ PSEUDO_ACCESS_FLAG(mode, O_APPEND, PSA_APPEND))
+extern int pseudo_access_fopen(const char *);
+
#define PSEUDO_HEADER_SIZE (offsetof(pseudo_msg_t, path))
extern pseudo_msg_t *pseudo_msg_receive(int fd);