summaryrefslogtreecommitdiff
path: root/libtreefs/trans-start.c
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1996-07-18 04:35:29 +0000
committerMichael I. Bushnell <mib@gnu.org>1996-07-18 04:35:29 +0000
commit94cef36797600d11a50d09828fa80df8a73dfd1c (patch)
treeb7cba9afef95489eedef534d3e6946eb13f595ba /libtreefs/trans-start.c
parent88dbbbf9e48e24f1ac007c1e4eeffd9caf8e2fad (diff)
*** empty log message ***
Diffstat (limited to 'libtreefs/trans-start.c')
-rw-r--r--libtreefs/trans-start.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/libtreefs/trans-start.c b/libtreefs/trans-start.c
new file mode 100644
index 00000000..1b0156bf
--- /dev/null
+++ b/libtreefs/trans-start.c
@@ -0,0 +1,65 @@
+/* Starting a passive translator
+
+ Copyright (C) 1994, 1995 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
+ 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 "treefs.h"
+
+#include <fcntl.h>
+
+int fshelp_transboot_port_type = PT_TRANSBOOT;
+
+/* Start the translator TRANS (of length TRANS_LEN) on NODE, which should be
+ locked, and will be unlocked when this function returns. PARENT_PORT is
+ a send right to use as the parent port passed to the translator. */
+error_t
+_treefs_node_start_translator (struct treefs_node *node,
+ char *trans, unsigned trans_len,
+ file_t parent_port)
+{
+ error_t err;
+ int mode = O_READ | O_EXEC;
+ struct treefs_auth *auth;
+ file_t node_port;
+ uid_t uid, gid;
+
+ err = treefs_node_get_trans_auth (node, &auth);
+ if (err)
+ return err;
+
+ if (!node->fsys->readonly && treefs_node_type (node) == S_IFREG)
+ mode |= O_WRITE;
+
+ /* Create the REALNODE port for the new filesystem. */
+ node_port = treefs_node_make_right (node, mode, parent_port, auth);
+ mach_port_insert_right (mach_task_self (), node_port, node_port,
+ MACH_MSG_TYPE_MAKE_SEND);
+
+
+ mutex_unlock (&node->lock);
+
+ /* XXXX Change libfshelp so that it take more than 1 uid/gid? */
+ uid = auth->nuids > 0 ? auth->uids[0] : -1;
+ gid = auth->ngids > 0 ? auth->gids[0] : -1;
+
+ err =
+ fshelp_start_translator (&node->active_trans, trans, trans_len,
+ parent_port, node_port, uid, gid);
+
+ treefs_node_auth_unref (node, auth);
+
+ return err;
+}