summaryrefslogtreecommitdiff
path: root/libnetfs
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-06-20 05:45:25 +0000
committerMiles Bader <miles@gnu.org>1997-06-20 05:45:25 +0000
commitaf4bbc207d34d2ff90b448a02cf55df315b4b1b4 (patch)
treecf368d605593f5f5aa34a8a77a9b4fb866243fa7 /libnetfs
parent44c8790bea3af9aa427c4aa7dd59b1543ca0db6d (diff)
Initial checkin
Diffstat (limited to 'libnetfs')
-rw-r--r--libnetfs/set-get-trans.c44
-rw-r--r--libnetfs/trans-callback.c79
2 files changed, 123 insertions, 0 deletions
diff --git a/libnetfs/set-get-trans.c b/libnetfs/set-get-trans.c
new file mode 100644
index 00000000..5d5d7729
--- /dev/null
+++ b/libnetfs/set-get-trans.c
@@ -0,0 +1,44 @@
+/* Default versions of netfs_set_translator & netfs_get_translator
+
+ Copyright (C) 1997 Free Software Foundation, Inc.
+
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+
+ 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"
+
+/* The user may define this function. Attempt to set the passive
+ translator record for FILE to ARGZ (of length ARGZLEN) for user
+ CRED. */
+error_t
+netfs_set_translator (struct iouser *cred, struct node *np,
+ char *argz, size_t argzlen)
+{
+ return EOPNOTSUPP;
+}
+
+/* The user may define this function (but should define it together with
+ netfs_set_translator). For locked node NODE with S_IPTRANS set in its
+ mode, look up the name of its translator. Store the name into newly
+ malloced storage, and return it in *ARGZ; set *ARGZ_LEN to the total
+ length. */
+error_t
+netfs_get_translator (struct node *node, char **argz, size_t *argz_len)
+{
+ return EOPNOTSUPP;
+}
diff --git a/libnetfs/trans-callback.c b/libnetfs/trans-callback.c
new file mode 100644
index 00000000..8452b005
--- /dev/null
+++ b/libnetfs/trans-callback.c
@@ -0,0 +1,79 @@
+/* Callback functions for starting translators
+
+ Copyright (C) 1995, 1996, 1997 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 "priv.h"
+#include <fcntl.h>
+
+/* Callback function needed for calls to fshelp_fetch_root. See
+ <hurd/fshelp.h> for the interface description. */
+static error_t
+_netfs_translator_callback1_fn (void *cookie1, void *cookie2,
+ uid_t *uid, gid_t *gid,
+ char **argz, size_t *argz_len)
+{
+ error_t err;
+ struct node *np = cookie1;
+
+ if (! (np->nn_stat.st_mode & S_IPTRANS))
+ return ENOENT;
+
+ err = netfs_get_translator (np, argz, argz_len);
+ if (err)
+ return err;
+
+ *uid = np->nn_stat.st_uid;
+ *gid = np->nn_stat.st_gid;
+
+ return 0;
+}
+
+/* Callback function needed for calls to fshelp_fetch_root. See
+ <hurd/fshelp.h> for the interface description. */
+static error_t
+_netfs_translator_callback2_fn (void *cookie1, void *cookie2, int flags,
+ mach_port_t *underlying,
+ mach_msg_type_name_t *underlying_type)
+{
+ struct protid *cred;
+ struct idvec *uids, *gids;
+ struct node *node = cookie1;
+
+ uids = make_idvec ();
+ gids = make_idvec ();
+ idvec_set_ids (uids, &node->nn_stat.st_uid, 1);
+ idvec_set_ids (gids, &node->nn_stat.st_gid, 1);
+
+ cred = netfs_make_protid (netfs_make_peropen (node, flags, cookie2),
+ iohelp_create_iouser (uids, gids));
+ if (cred)
+ {
+ *underlying = ports_get_right (cred);
+ *underlying_type = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (cred);
+ return 0;
+ }
+ else
+ return errno;
+}
+
+fshelp_fetch_root_callback1_t _netfs_translator_callback1 =
+ _netfs_translator_callback1_fn;
+fshelp_fetch_root_callback2_t _netfs_translator_callback2 =
+ _netfs_translator_callback2_fn;