diff options
Diffstat (limited to 'libtrivfs/trivfs.h')
-rw-r--r-- | libtrivfs/trivfs.h | 143 |
1 files changed, 120 insertions, 23 deletions
diff --git a/libtrivfs/trivfs.h b/libtrivfs/trivfs.h index 4274226f..798e0b38 100644 --- a/libtrivfs/trivfs.h +++ b/libtrivfs/trivfs.h @@ -1,5 +1,5 @@ -/* - Copyright (C) 1994, 1995, 1996 Free Software Foundation +/* + Copyright (C) 1994,95,96,97,99,2002 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 @@ -23,12 +23,12 @@ #include <sys/types.h> /* for uid_t &c */ #include <mach/mach.h> #include <hurd/ports.h> +#include <hurd/iohelp.h> struct trivfs_protid { struct port_info pi; - uid_t *uids, *gids; - int nuids, ngids; + struct iouser *user; int isroot; /* REALNODE will be null if this protid wasn't fully created (currently only in the case where trivfs_protid_create_hook returns an error). */ @@ -72,7 +72,7 @@ void trivfs_end_using_control (struct trivfs_control *); extern int trivfs_fstype; extern int trivfs_fsid; -/* Set these if trivfs should allow read, write, +/* Set these if trivfs should allow read, write, or execute of file. */ extern int trivfs_support_read; extern int trivfs_support_write; @@ -84,27 +84,47 @@ extern int trivfs_support_exec; operations.) */ extern int trivfs_allow_open; +/* If the user defines these, they should be vectors (and the associated + sizes) of port classes that will be translated into control & protid + pointers for passing to rpcs, in addition to those passed to or created by + trivfs_create_control (or trivfs_startup) will automatically be + recognized. */ extern struct port_class *trivfs_protid_portclasses[]; extern int trivfs_protid_nportclasses; extern struct port_class *trivfs_cntl_portclasses[]; extern int trivfs_cntl_nportclasses; -/* The user must define this function. This should modify a struct +/* The user must define this function. This should modify a struct stat (as returned from the underlying node) for presentation to - callers of io_stat. It is permissable for this function to do + callers of io_stat. It is permissible for this function to do nothing. */ -void trivfs_modify_stat (struct trivfs_protid *cred, struct stat *); +void trivfs_modify_stat (struct trivfs_protid *cred, io_statbuf_t *); + +/* If this variable is set, it is called to find out what access this + file permits to USER instead of checking the underlying node. + REALNODE is the underlying node, and CNTL is the trivfs control + object. The access permissions are returned in ALLOWED. */ +error_t (*trivfs_check_access_hook) (struct trivfs_control *cntl, + struct iouser *user, + mach_port_t realnode, + int *allowed); /* If this variable is set, it is called every time an open happens. - UIDS, GIDS, and FLAGS are from the open; CNTL identifies the + USER and FLAGS are from the open; CNTL identifies the node being opened. This call need not check permissions on the underlying node. This call can block as necessary, unless O_NONBLOCK is set in FLAGS. Any desired error can be returned, which will be reflected to the user and prevent the open from succeeding. */ error_t (*trivfs_check_open_hook) (struct trivfs_control *cntl, - uid_t *uids, u_int nuids, - gid_t *gids, u_int ngids, - int flags); + struct iouser *user, int flags); + +/* If this variable is set, it is called in place of `trivfs_open' (below). */ +error_t (*trivfs_open_hook) (struct trivfs_control *fsys, + struct iouser *user, + mach_port_t dotdot, + int flags, + mach_port_t realnode, + struct trivfs_protid **cred); /* If this variable is set, it is called every time a new protid structure is created and initialized. */ @@ -122,13 +142,27 @@ void (*trivfs_protid_destroy_hook) (struct trivfs_protid *); is about to be destroyed. */ void (*trivfs_peropen_destroy_hook) (struct trivfs_peropen *); +/* If this variable is set, it is called by trivfs_S_fsys_getroot before any + other processing takes place; if the return value is EAGAIN, normal trivfs + getroot processing continues, otherwise the rpc returns with that return + value. */ +error_t (*trivfs_getroot_hook) (struct trivfs_control *cntl, + mach_port_t reply_port, + mach_msg_type_name_t reply_port_type, + mach_port_t dotdot, + uid_t *uids, u_int nuids, uid_t *gids, u_int ngids, + int flags, + retry_type *do_retry, char *retry_name, + mach_port_t *node, mach_msg_type_name_t *node_type); + /* Creates a control port for this filesystem and sends it to BOOTSTRAP with fsys_startup. CONTROL_CLASS & CONTROL_BUCKET are passed to the ports library to create the control port, and PROTID_CLASS & PROTID_BUCKET are - used when creating ports representing opens of this node. If CONTROL - isn't NULL, the trivfs control port is return in it. If any error occurs - sending fsys_startup, it is returned, otherwise 0. FLAGS specifies how to - open the underlying node (O_*). */ + used when creating ports representing opens of this node; any of these may + be zero, in which case an appropriate port class/bucket is created. If + CONTROL isn't NULL, the trivfs control port is return in it. If any error + occurs sending fsys_startup, it is returned, otherwise 0. FLAGS specifies + how to open the underlying node (O_*). */ error_t trivfs_startup (mach_port_t bootstrap, int flags, struct port_class *control_class, struct port_bucket *control_bucket, @@ -140,7 +174,8 @@ error_t trivfs_startup (mach_port_t bootstrap, int flags, return it in CONTROL. CONTROL_CLASS & CONTROL_BUCKET are passed to the ports library to create the control port, and PROTID_CLASS & PROTID_BUCKET are used when creating ports representing opens of this - node. */ + node; any of these may be zero, in which case an appropriate port + class/bucket is created. */ error_t trivfs_create_control (mach_port_t underlying, struct port_class *control_class, @@ -161,8 +196,7 @@ int trivfs_demuxer (mach_msg_header_t *, mach_msg_header_t *); the underlying node reference, with the given identity, and open flags in FLAGS. CNTL is the trivfs control object. */ error_t trivfs_open (struct trivfs_control *fsys, - uid_t *uids, unsigned num_uids, - gid_t *gids, unsigned num_gids, + struct iouser *user, unsigned flags, mach_port_t realnode, struct trivfs_protid **cred); @@ -194,10 +228,73 @@ extern struct argp *trivfs_runtime_argp; error_t trivfs_set_options (struct trivfs_control *fsys, char *argz, size_t argz_len); -/* Return runtime options for FSYS in ARGZ & ARGZ_LEN. ARGZ should be - allocated with malloc. The default definition for this routine returns - EOPNOTSUPP. */ -error_t trivfs_get_options (struct trivfs_control *fsys, +/* Append to the malloced string *ARGZ of length *ARGZ_LEN a NUL-separated + list of the arguments to this translator. The default definition of this + routine simply calls diskfs_append_std_options. */ +error_t trivfs_append_args (struct trivfs_control *fsys, char **argz, size_t *argz_len); + +/* Add the port class *CLASS to the list of control port classes recognized + by trivfs; if *CLASS is 0, an attempt is made to allocate a new port + class, which is stored in *CLASS. */ +error_t trivfs_add_control_port_class (struct port_class **class); + +/* Remove the previously added dynamic control port class CLASS, freeing it + if it was allocated by trivfs_add_control_port_class. */ +void trivfs_remove_control_port_class (struct port_class *class); + +/* Add the port class *CLASS to the list of protid port classes recognized by + trivfs; if *CLASS is 0, an attempt is made to allocate a new port class, + which is stored in *CLASS. */ +error_t trivfs_add_protid_port_class (struct port_class **class); + +/* Remove the previously added dynamic protid port class CLASS, freeing it + if it was allocated by trivfs_add_protid_port_class. */ +void trivfs_remove_protid_port_class (struct port_class *class); + +/* Add the port bucket *BUCKET to the list of dynamically allocated port + buckets; if *bucket is 0, an attempt is made to allocate a new port + bucket, which is then stored in *bucket. */ +error_t trivfs_add_port_bucket (struct port_bucket **bucket); + +/* Remove the previously added dynamic port bucket BUCKET, freeing it + if it was allocated by trivfs_add_port_bucket. */ +void trivfs_remove_port_bucket (struct port_bucket *bucket); + + +/* This stuff is for the sake of MiG stubs and could be in a private + header. But it might be handy for users that override parts of the + library. Moreover, since the stub headers will use all the imports we + need for the stubs, we couldn't make the stub headers public without + making this public too. */ + +typedef struct trivfs_protid *trivfs_protid_t; +typedef struct trivfs_control *trivfs_control_t; + +struct trivfs_protid *_trivfs_begin_using_protid (mach_port_t); +void _trivfs_end_using_protid (struct trivfs_protid *); +struct trivfs_control *_trivfs_begin_using_control (mach_port_t); +void _trivfs_end_using_control (struct trivfs_control *); + +/* Vectors of dynamically allocated port classes/buckets. */ + +/* Protid port classes. */ +extern struct port_class **trivfs_dynamic_protid_port_classes; +extern size_t trivfs_num_dynamic_protid_port_classes; + +/* Control port classes. */ +extern struct port_class **trivfs_dynamic_control_port_classes; +extern size_t trivfs_num_dynamic_control_port_classes; + +/* Port buckets. */ +extern struct port_bucket **trivfs_dynamic_port_buckets; +extern size_t trivfs_num_dynamic_port_buckets; + +/* These are the MiG-generated headers that declare prototypes + for the server functions. */ +#include <hurd/trivfs_fs_S.h> +#include <hurd/trivfs_io_S.h> +#include <hurd/trivfs_fsys_S.h> + #endif /* __TRIVFS_H__ */ |