aboutsummaryrefslogtreecommitdiff
path: root/libfshelp/fshelp.h
diff options
context:
space:
mode:
Diffstat (limited to 'libfshelp/fshelp.h')
-rw-r--r--libfshelp/fshelp.h110
1 files changed, 71 insertions, 39 deletions
diff --git a/libfshelp/fshelp.h b/libfshelp/fshelp.h
index 9461ae50..9f4fa677 100644
--- a/libfshelp/fshelp.h
+++ b/libfshelp/fshelp.h
@@ -1,5 +1,5 @@
/* FS helper library definitions
- Copyright (C) 1994, 1995, 1996 Free Software Foundation
+ Copyright (C) 1994,95,96,97,98,99,2000,01,02 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -19,7 +19,7 @@
#define _HURD_FSHELP_
/* This library implements various things that are generic to
- all or most implementors of the filesystem protocol. It
+ all or most implementors of the filesystem protocol. It
presumes that you are using the iohelp library as well. It
is divided into separate facilities which may be used independently. */
@@ -27,6 +27,9 @@
#include <mach.h>
#include <hurd/hurd_types.h>
#include <cthreads.h>
+#include <hurd/iohelp.h>
+#include <sys/stat.h>
+#include <maptime.h>
/* Passive translator linkage */
@@ -35,11 +38,12 @@
or the ports library. */
/* A callback used by the translator starting functions, which should be a
- function that given some open flags, opens the appropiate file, and
+ function that given some open flags, opens the appropriate file, and
returns the node port. */
typedef error_t (*fshelp_open_fn_t) (int flags,
file_t *node,
- mach_msg_type_name_t *node_type);
+ mach_msg_type_name_t *node_type,
+ task_t, void *cookie);
/* Start a passive translator NAME with arguments ARGZ (length
ARGZ_LEN). Initialize the initports to PORTS (length PORTS_LEN),
@@ -47,15 +51,18 @@ typedef error_t (*fshelp_open_fn_t) (int flags,
table to FDS (length FDS_LEN). Return the control port in
*CONTROL. If the translator doesn't respond or die in TIMEOUT
milliseconds (if TIMEOUT > 0), return an appropriate error. If the
- translator dies before responding, return EDIED. */
+ translator dies before responding, return EDIED. Set the new
+ task's owner to OWNER_UID (or, if OWNER_UID is -1, then clear the
+ new task's owner. */
error_t
-fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn,
+fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn, void *cookie,
char *name, char *argz, int argz_len,
- mach_port_t *fds,
+ mach_port_t *fds,
mach_msg_type_name_t fds_type, int fds_len,
- mach_port_t *ports,
+ mach_port_t *ports,
mach_msg_type_name_t ports_type, int ports_len,
int *ints, int ints_len,
+ uid_t owner_uid,
int timeout, fsys_t *control);
@@ -63,7 +70,7 @@ fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn,
are copied from our own state, fd[2] is copied from our own stderr,
and the other fds are cleared. */
error_t
-fshelp_start_translator (fshelp_open_fn_t underlying_open_fn,
+fshelp_start_translator (fshelp_open_fn_t underlying_open_fn, void *cookie,
char *name, char *argz, int argz_len,
int timeout, fsys_t *control);
@@ -75,7 +82,7 @@ fshelp_start_translator (fshelp_open_fn_t underlying_open_fn,
use the passive translator routines above, but they don't require
the ports library at all. */
-struct transbox
+struct transbox
{
fsys_t active;
struct mutex *lock;
@@ -98,8 +105,8 @@ struct transbox
then return ENOENT. COOKIE1 is the cookie passed in fshelp_transbox_init.
COOKIE2 is the cookie passed in the call to fshelp_fetch_root. */
typedef error_t (*fshelp_fetch_root_callback1_t) (void *cookie1, void *cookie2,
- uid_t *uid, gid_t *gid,
- char **argz, int *argz_len);
+ uid_t *uid, gid_t *gid,
+ char **argz, size_t *argz_len);
/* This routine is called by fshelp_fetch_root to fetch more information.
Return an unauthenticated node for the file itself in *UNDERLYING and
@@ -113,18 +120,16 @@ typedef error_t (*fshelp_fetch_root_callback2_t) (void *cookie1, void *cookie2,
*underlying_type);
/* Fetch the root from TRANSBOX. DOTDOT is an unauthenticated port
- for the directory in which we are looking; UIDS (length UIDS_LEN)
- and GIDS (length GIDS_LEN) are the ids of the user responsible for
- the call. FLAGS are as for dir_pathtrans (but O_CREAT and O_EXCL
- are not meaningful and are ignored). The trasnbox lock (as
- set by fshelp_transbox_init) must be held before the call, and will
- be held upon return, but may be released during the operation of
- the call. */
+ for the directory in which we are looking; USER specifies the ids
+ of the user responsible for the call. FLAGS are as for dir_lookup
+ (but O_CREAT and O_EXCL are not meaningful and are ignored). The
+ transbox lock (as set by fshelp_transbox_init) must be held before
+ the call, and will be held upon return, but may be released during
+ the operation of the call. */
error_t
fshelp_fetch_root (struct transbox *transbox, void *cookie,
- file_t dotdot,
- uid_t *uids, int uids_len,
- uid_t *gids, int gids_len,
+ file_t dotdot,
+ struct iouser *user,
int flags,
fshelp_fetch_root_callback1_t callback1,
fshelp_fetch_root_callback2_t callback2,
@@ -136,11 +141,7 @@ fshelp_transbox_init (struct transbox *transbox,
void *cookie);
/* Return true iff there is an active translator on this box */
-extern inline int
-fshelp_translated (struct transbox *box)
-{
- return (box->active != MACH_PORT_NULL);
-}
+int fshelp_translated (struct transbox *box);
/* Atomically replace the existing active translator port for this box
with NEWACTIVE. If EXCL is non-zero then don't frob an existing
@@ -171,11 +172,11 @@ struct lock_box
There should be one lock box per object and one int per open; these
are passed as arguments BOX and USER respectively. FLAGS are as
per file_lock. MUT is a mutex which will be held whenever this
- routine is called, to lock BOX->wait. */
-error_t fshelp_acquire_lock (struct lock_box *box, int *user,
+ routine is called, to lock BOX->wait. */
+error_t fshelp_acquire_lock (struct lock_box *box, int *user,
struct mutex *mut, int flags);
-
+
/* Initialize lock_box BOX. (The user int passed to fshelp_acquire_lock
should be initialized with LOCK_UN.). */
void fshelp_lock_init (struct lock_box *box);
@@ -193,7 +194,7 @@ struct port_bucket; /* shut up C compiler */
notifications) are used.
*/
error_t fshelp_get_identity (struct port_bucket *bucket,
- ino_t fileno, mach_port_t *pt);
+ ino64_t fileno, mach_port_t *pt);
@@ -201,7 +202,7 @@ error_t fshelp_get_identity (struct port_bucket *bucket,
the node SERVER_NAME. REQUESTOR is the translator's bootstrap port, and
ARGV is the command line. If SERVER_NAME is NULL, then a name is
concocted by appending ARGV[0] to _SERVERS. */
-error_t fshelp_delegate_translation (char *server_name,
+error_t fshelp_delegate_translation (const char *server_name,
mach_port_t requestor, char **argv);
struct idvec; /* Include <idvec.h> to get the real thing. */
@@ -227,13 +228,44 @@ struct argp; /* Include <argp.h> to get the real thing. */
/* Invoke ARGP with data from DATA & LEN, in the standard way. */
error_t fshelp_set_options (struct argp *argp, int flags,
- char *argz, size_t argz_len, void *input);
+ const char *argz, size_t argz_len, void *input);
+
-/* Puts data from the malloced buffer BUF, LEN bytes long, into RBUF & RLEN,
- suitable for returning from a mach rpc. If LEN > 0, BUF is freed,
- regardless of whether an error is returned or not. */
-error_t fshelp_return_malloced_buffer (char *buf, size_t len,
- char **rbuf,
- mach_msg_type_number_t *rlen);
+/* Standardized filesystem permission checking */
+/* Check to see whether USER should be considered the owner of the
+ file identified by ST. If so, return zero; otherwise return an
+ appropriate error code. */
+error_t fshelp_isowner (io_statbuf_t *st, struct iouser *user);
+
+/* Check to see whether USER should be considered a controller of the
+ filesystem. Which is to say, check to see if we should give USER the
+ control port. ST is the stat of the root node. USER is the user
+ asking for a send right to the control port. */
+error_t
+fshelp_iscontroller (io_statbuf_t *st, struct iouser *user);
+
+/* Check to see whether the user USER can operate on a file identified
+ by ST. OP is one of S_IREAD, S_IWRITE, and S_IEXEC. If the access
+ is permitted, return zero; otherwise return an appropriate error
+ code. */
+error_t fshelp_access (io_statbuf_t *st, int op, struct iouser *user);
+
+/* Check to see whether USER is allowed to modify DIR with respect to
+ existing file ST. (If there is no existing file, pass 0 for ST.)
+ If the access is permissible return 0; otherwise return an
+ appropriate error code. */
+error_t fshelp_checkdirmod (io_statbuf_t *dir, io_statbuf_t *st,
+ struct iouser *user);
+
+
+/* Timestamps to change. */
+#define TOUCH_ATIME 0x1
+#define TOUCH_MTIME 0x2
+#define TOUCH_CTIME 0x4
+
+/* Change the stat times of NODE as indicated by WHAT (from the set TOUCH_*)
+ to the current time. */
+void fshelp_touch (io_statbuf_t *st, unsigned what,
+ volatile struct mapped_time_value *maptime);
#endif