diff options
-rw-r--r-- | libnetfs/file-get-fs-options.c | 61 | ||||
-rw-r--r-- | libnetfs/file-getcontrol.c | 60 | ||||
-rw-r--r-- | libnetfs/fsstubs.c | 103 | ||||
-rw-r--r-- | libnetfs/fsys-get-options.c | 66 | ||||
-rw-r--r-- | libnetfs/fsys-set-options.c | 96 | ||||
-rw-r--r-- | libnetfs/fsysstubs.c | 75 | ||||
-rw-r--r-- | libports/create-port.c | 107 |
7 files changed, 568 insertions, 0 deletions
diff --git a/libnetfs/file-get-fs-options.c b/libnetfs/file-get-fs-options.c new file mode 100644 index 00000000..358d76f4 --- /dev/null +++ b/libnetfs/file-get-fs-options.c @@ -0,0 +1,61 @@ +/* Unparse run-time options + + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <errno.h> +#include <argz.h> +#include <string.h> + +#include "netfs.h" +#include "fs_S.h" + +/* This code is originally from libdiskfs; things surrounded by `#if NOT_YET' + are pending libnetfs being fleshed out some more. */ + +/* Implement file_get_fs_options as described in <hurd/fs.defs>. */ +error_t +netfs_S_file_get_fs_options (struct protid *user, + char **data, mach_msg_type_number_t *data_len) +{ + error_t err; + char *argz = 0; + + if (! user) + return EOPNOTSUPP; + +#if NOT_YET + rwlock_reader_lock (&netfs_fsys_lock); +#endif + err = netfs_get_options (&argz, data_len); +#if NOT_YET + rwlock_reader_unlock (&netfs_fsys_lock); +#endif + + if (!err && *data_len > 0) + /* Move ARGZ from a malloced buffer into a vm_alloced one. */ + { + err = + vm_allocate (mach_task_self (), (vm_address_t *)data, *data_len, 1); + if (!err) + bcopy (argz, *data, *data_len); + free (argz); + } + + return err; +} diff --git a/libnetfs/file-getcontrol.c b/libnetfs/file-getcontrol.c new file mode 100644 index 00000000..7c4f1fee --- /dev/null +++ b/libnetfs/file-getcontrol.c @@ -0,0 +1,60 @@ +/* Return the filesystem corresponding to a file + + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include "netfs.h" +#include "fsys_S.h" + +error_t +netfs_S_file_getcontrol (struct protid *user, + mach_port_t *control, + mach_msg_type_name_t *controltype) +{ + struct port_info *pi; + uid_t *uids, *gids; + int nuids, ngids; + int i; + + if (!user) + return EOPNOTSUPP; + + mutex_lock (&user->po->np->lock); + netfs_interpret_credential (user->credential, &uids, &nuids, &gids, &ngids); + mutex_unlock (&user->po->np->lock); + free (gids); + + for (i = 0; i < nuids; i++) + if (uids[i] == 0) + { + /* They've got root; give it to them. */ + free (uids); + pi = ports_allocate_port (netfs_port_bucket, + sizeof (struct port_info), + netfs_control_class); + *control = ports_get_right (pi); + *controltype = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (pi); + return 0; + } + + /* Not got root. */ + free (uids); + return EPERM; +} diff --git a/libnetfs/fsstubs.c b/libnetfs/fsstubs.c new file mode 100644 index 00000000..081a2248 --- /dev/null +++ b/libnetfs/fsstubs.c @@ -0,0 +1,103 @@ +/* Unimplemented rpcs from <hurd/fs.defs> + + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include "netfs.h" +#include "fs_S.h" + +error_t +netfs_S_file_notice_changes (struct protid *user, + mach_port_t port) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_file_get_translator (struct protid *user, + char **translator, + mach_msg_type_number_t *translen) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_file_get_translator_cntl (struct protid *user, + mach_port_t *trans, + mach_msg_type_name_t *transtype) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_file_set_translator (struct protid *user, + int pflags, int aflags, + int gflags, char *passive, + mach_msg_type_number_t passivelen, + mach_port_t active) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_file_exec (struct protid *user, + task_t task, + int flags, + char *argv, mach_msg_type_number_t argvlen, + char *envp, mach_msg_type_number_t envplen, + mach_port_t *fds, mach_msg_type_number_t nfds, + mach_port_t *ports, mach_msg_type_number_t nports, + int *ints, mach_msg_type_number_t nints, + mach_port_t *dealports, mach_msg_type_number_t ndealports, + mach_port_t *destports, mach_msg_type_number_t ndestports) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_file_getfh (struct protid *user, + char **data, mach_msg_type_number_t *ndata) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_ifsock_getsockaddr (struct protid *user, + mach_port_t *address) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_io_pathconf (struct protid *user, + int name, + int *value) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_io_server_version (struct protid *user, + char *name, + int *major, + int *minor, + int *edit) +{ + return EOPNOTSUPP; +} diff --git a/libnetfs/fsys-get-options.c b/libnetfs/fsys-get-options.c new file mode 100644 index 00000000..787db595 --- /dev/null +++ b/libnetfs/fsys-get-options.c @@ -0,0 +1,66 @@ +/* Unparse run-time options + + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <errno.h> +#include <argz.h> +#include <hurd/fsys.h> +#include <string.h> + +#include "netfs.h" +#include "fsys_S.h" + +/* This code is originally from libdiskfs; things surrounded by `#if NOT_YET' + are pending libnetfs being fleshed out some more. */ + +/* Implement fsys_get_options as described in <hurd/fsys.defs>. */ +error_t +netfs_S_fsys_get_options (fsys_t fsys, + char **data, mach_msg_type_number_t *data_len) +{ + error_t err; + char *argz = 0; + struct port_info *port = + ports_lookup_port (netfs_port_bucket, fsys, netfs_control_class); + + if (!port) + return EOPNOTSUPP; + +#if NOT_YET + rwlock_reader_lock (&netfs_fsys_lock); +#endif + err = netfs_get_options (&argz, data_len); +#if NOT_YET + rwlock_reader_unlock (&netfs_fsys_lock); +#endif + + if (!err && *data_len > 0) + /* Move ARGZ from a malloced buffer into a vm_alloced one. */ + { + err = + vm_allocate (mach_task_self (), (vm_address_t *)data, *data_len, 1); + if (!err) + bcopy (argz, *data, *data_len); + free (argz); + } + + ports_port_deref (port); + + return err; +} diff --git a/libnetfs/fsys-set-options.c b/libnetfs/fsys-set-options.c new file mode 100644 index 00000000..465bbf32 --- /dev/null +++ b/libnetfs/fsys-set-options.c @@ -0,0 +1,96 @@ +/* Parse run-time options + + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <errno.h> +#include <argz.h> +#include <hurd/fsys.h> +#include <string.h> + +#include "netfs.h" +#include "fsys_S.h" + +/* This code is originally from libdiskfs; things surrounded by `#if NOT_YET' + are pending libnetfs being fleshed out some more. */ + +/* Implement fsys_set_options as described in <hurd/fsys.defs>. */ +error_t +netfs_S_fsys_set_options (fsys_t fsys, + char *data, mach_msg_type_number_t data_len, + int do_children) +{ + error_t err = 0; + struct port_info *pt = + ports_lookup_port (netfs_port_bucket, fsys, netfs_control_class); + + error_t + helper (struct node *np) + { + error_t error; + mach_port_t control; + + error = fshelp_fetch_control (&np->transbox, &control); + mutex_unlock (&np->lock); + if (!error && (control != MACH_PORT_NULL)) + { + error = fsys_set_options (control, data, data_len, do_children); + mach_port_deallocate (mach_task_self (), control); + } + else + error = 0; + mutex_lock (&np->lock); + + if ((error == MIG_SERVER_DIED) || (error == MACH_SEND_INVALID_DEST)) + error = 0; + + return error; + } + + if (!pt) + return EOPNOTSUPP; + +#if NOT_YET + if (do_children) + { + rwlock_writer_lock (&netfs_fsys_lock); + err = netfs_node_iterate (helper); + rwlock_writer_unlock (&netfs_fsys_lock); + } +#endif + + if (!err) + { + int argc = argz_count (data, data_len); + char **argv = alloca (sizeof (char *) * (argc + 1)); + + argz_extract (data, data_len, argv); + +#if NOT_YET + rwlock_writer_lock (&netfs_fsys_lock); +#endif + err = netfs_set_options (argc, argv); +#if NOT_YET + rwlock_writer_unlock (&netfs_fsys_lock); +#endif + } + + ports_port_deref (pt); + + return err; +} diff --git a/libnetfs/fsysstubs.c b/libnetfs/fsysstubs.c new file mode 100644 index 00000000..bed52b18 --- /dev/null +++ b/libnetfs/fsysstubs.c @@ -0,0 +1,75 @@ +/* Unimplemented rpcs from <hurd/fsys.defs> + + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include "netfs.h" +#include "fsys_S.h" + +error_t +netfs_S_fsys_getfile (fsys_t cntl, + uid_t *uids, mach_msg_type_number_t nuids, + gid_t *gids, mach_msg_type_number_t ngids, + char *handle, mach_msg_type_number_t handlelen, + mach_port_t *file, mach_msg_type_name_t *filetype) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_fsys_getpriv (fsys_t cntl, + mach_port_t *host, mach_msg_type_name_t *hosttp, + mach_port_t *dev, mach_msg_type_name_t *devtp, + mach_port_t *fs, mach_msg_type_name_t *fstp) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_fsys_init (fsys_t cntl, + mach_port_t reply, mach_msg_type_name_t replytp, + mach_port_t proc, auth_t auth) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_fsys_forward (fsys_t cntl, + mach_port_t request, + char *argv, mach_msg_type_number_t argvlen) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_fsys_startup (mach_port_t bootstrap, + int flags, + mach_port_t contrl, + mach_port_t *realnod, + mach_msg_type_name_t *realnodetype) +{ + return EOPNOTSUPP; +} + +error_t +netfs_S_fsys_goaway (mach_port_t cntl, + int flags) +{ + return EOPNOTSUPP; +} diff --git a/libports/create-port.c b/libports/create-port.c new file mode 100644 index 00000000..09ebae44 --- /dev/null +++ b/libports/create-port.c @@ -0,0 +1,107 @@ +/* Create a new port structure + + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "ports.h" +#include <assert.h> +#include <cthreads.h> +#include <hurd/ihash.h> + +/* Create and return in RESULT a new port in CLASS and BUCKET; SIZE bytes + will be allocated to hold the port structure and whatever private data the + user desires. */ +error_t +ports_create_port (struct port_class *class, struct port_bucket *bucket, + size_t size, void *result) +{ + mach_port_t port; + error_t err; + struct port_info *pi; + + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &port); + if (err) + return err; + + if (size < sizeof (struct port_info)) + size = sizeof (struct port_info); + + pi = malloc (size); + if (! pi) + { + mach_port_deallocate (mach_task_self (), port); + return ENOMEM; + } + + pi->class = class; + pi->refcnt = 1; + pi->weakrefcnt = 0; + pi->cancel_threshold = 0; + pi->mscount = 0; + pi->flags = 0; + pi->port_right = port; + pi->current_rpcs = 0; + pi->bucket = bucket; + + mutex_lock (&_ports_lock); + + loop: + if (class->flags & PORT_CLASS_NO_ALLOC) + { + class->flags |= PORT_CLASS_ALLOC_WAIT; + if (hurd_condition_wait (&_ports_block, &_ports_lock)) + goto cancelled; + goto loop; + } + if (bucket->flags & PORT_BUCKET_NO_ALLOC) + { + bucket->flags |= PORT_BUCKET_ALLOC_WAIT; + if (hurd_condition_wait (&_ports_block, &_ports_lock)) + goto cancelled; + goto loop; + } + + err = ihash_add (bucket->htable, port, pi, &pi->hentry); + if (err) + goto lose; + + pi->next = class->ports; + pi->prevp = &class->ports; + if (class->ports) + class->ports->prevp = &pi->next; + class->ports = pi; + bucket->count++; + class->count++; + mutex_unlock (&_ports_lock); + + mach_port_move_member (mach_task_self (), pi->port_right, bucket->portset); + + *(void **)result = pi; + return 0; + + cancelled: + err = EINTR; + lose: + mutex_unlock (&_ports_lock); + mach_port_mod_refs (mach_task_self (), port, MACH_PORT_RIGHT_RECEIVE, -1); + free (pi); + + return err; +} |