summaryrefslogtreecommitdiff
path: root/libtrivfs
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-04-09 04:38:32 +0000
committerMiles Bader <miles@gnu.org>1995-04-09 04:38:32 +0000
commitf7afb09ef15d388a9ad90ffaed1a7b9699f30c7a (patch)
tree9a012fa1db405b728aeae1e19a989033af42c17c /libtrivfs
parentc5f556c7f4c66f4253184286ee92a4e96d5f0611 (diff)
Initial revision
Diffstat (limited to 'libtrivfs')
-rw-r--r--libtrivfs/startup.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/libtrivfs/startup.c b/libtrivfs/startup.c
new file mode 100644
index 00000000..31312f9f
--- /dev/null
+++ b/libtrivfs/startup.c
@@ -0,0 +1,62 @@
+/* Contact parent filesystem and establish ourselves as the translator.
+
+ Copyright (C) 1995 Free Software Foundation, Inc.
+
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+
+ This program 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.
+
+ This program 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 <hurd.h>
+#include <hurd/fsys.h>
+#include <assert.h>
+
+#include "priv.h"
+
+/* Creates a control port for this filesystem and sends it to BOOTSTRAP with
+ fsys_startup. CONTROL_TYPE is the ports library type for the control
+ port, and PROTID_TYPE is the type for 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. */
+error_t
+trivfs_startup(mach_port_t bootstrap,
+ int control_type, int protid_type,
+ struct trivfs_control **control)
+{
+ error_t err;
+ mach_port_t realnode;
+ struct trivfs_control *tcntl;
+ mach_port_t mcntl =
+ trivfs_handle_port (MACH_PORT_NULL, control_type, protid_type);
+
+ assert(mcntl != MACH_PORT_NULL);
+
+ /* Contact whoever started us. */
+ err = fsys_startup (bootstrap, mcntl, MACH_MSG_TYPE_MAKE_SEND, &realnode);
+
+ /* Install the returned realnode for trivfs's use */
+ tcntl = ports_check_port_type (mcntl, control_type);
+ assert (tcntl);
+
+ ports_change_hardsoft (tcntl, 1);
+ if (!err)
+ tcntl->underlying = realnode;
+
+ ports_done_with_port (tcntl);
+
+ if (control)
+ *control = tcntl;
+
+ return err;
+}