summaryrefslogtreecommitdiff
path: root/lib.c
diff options
context:
space:
mode:
authorSergiu Ivanov <unlimitedscolobb@gmail.com>2008-09-07 22:36:45 +0300
committerSergiu Ivanov <unlimitedscolobb@gmail.com>2008-09-07 22:36:45 +0300
commitdd5f567d830707ca1530e8e3c2ef7b1c6b4b3862 (patch)
tree0b468f7df0a4aaba9a4c09762825932ac530a4f5 /lib.c
parent13fa6563250dcd4b2d1a54f15aba1bb7d8aace28 (diff)
Added proxy nodes, optimized node management policy
Now, when 'file,,x' is requested, nsmux will create a proxy node and will set the translator 'x' on this node, not on the real filesystem node. Also, nsmux will not create nodes for simple file looks, instead it will simply return the port to the required file, thus avoiding the necessity to handle IO operations inside itself.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index aa0ff0be8..c05e08eae 100644
--- a/lib.c
+++ b/lib.c
@@ -5,7 +5,7 @@
/*----------------------------------------------------------------------------*/
/*Based on the code of unionfs translator.*/
/*----------------------------------------------------------------------------*/
-/*Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+/*Copyright (C) 2001, 2002, 2005, 2008 Free Software Foundation, Inc.
Written by Sergiu Ivanov <unlimitedscolobb@gmail.com>.
This program is free software; you can redistribute it and/or
@@ -28,6 +28,8 @@
#define _GNU_SOURCE 1
/*----------------------------------------------------------------------------*/
#include <sys/mman.h>
+#include <fcntl.h>
+#include <hurd/fshelp.h>
/*----------------------------------------------------------------------------*/
#include "lib.h"
#include "debug.h"
@@ -191,3 +193,27 @@ file_lookup
return err;
}/*file_lookup*/
/*----------------------------------------------------------------------------*/
+/*Checks whether `user` has the right to open the node described by `stat` with
+ `flags`*/
+error_t
+check_open_permissions
+ (
+ struct iouser * user,
+ io_statbuf_t * stat,
+ int flags
+ )
+ {
+ error_t err = 0;
+
+ /*Cheks user's permissions*/
+ if(flags & O_READ)
+ err = fshelp_access(stat, S_IREAD, user);
+ if(!err && (flags & O_WRITE))
+ err = fshelp_access(stat, S_IWRITE, user);
+ if(!err && (flags & O_EXEC))
+ err = fshelp_access(stat, S_IEXEC, user);
+
+ /*Return the result of the check*/
+ return err;
+ }/*check_open_permissions*/
+/*----------------------------------------------------------------------------*/