On Thu, 2015-05-07 at 16:51 +0200, Samuel Thibault wrote:
> Svante Signell, le Thu 07 May 2015 10:14:23 +0200, a écrit :
> > I think I understand most of your writing above :)
> >
> > Should the netfs_set_translator stub be implemented in trans/fakeroot.c
> > or in libnetfs/set-get-trans.c?
>
> The former.
>
> > Still confusing is which functions are called: The ones in libnetfs vs
> > the ones in fakeroot?
>
> The ones in libnetfs, and they call stubs from fakeroot.
Attached is a patch that solves the test case for sockets.
An attempt to explain:
libnetfs/file-set-translator.c:netfs_S_file_set_translator() hits the
default case in the newmode switch statement which in
netfs_attempt_chmod() returns an error of EOPNOTSUPP and hits the
fallback case calling the stub in
libnetfs/set-get-trans.c:netfs_set_translator() returning EOPNOTSUPP.
Implementing netfs_S_file_set_translator() calling file_set_translator()
in trans/fakeroot.c overrides this call and solves the problem.
Some questions:
- Are the checks in the beginning really needed doesn't
file_set_translator() take care of that?
- Is the explanation really OK?
- AOB?
Index: hurd-0.6/trans/fakeroot.c
===================================================================
--- hurd-0.6.orig/trans/fakeroot.c
+++ hurd-0.6/trans/fakeroot.c
@@ -450,6 +450,39 @@ netfs_S_dir_lookup (struct protid *dirus
return err;
}
+/* The user must define this function. Attempt to turn locked node NP
+ (user USER) into a socket with target NAME. */
+error_t
+netfs_S_file_set_translator (struct protid *user,
+ int passive_flags, int active_flags,
+ int killtrans_flags, char *passive,
+ mach_msg_type_number_t passivelen,
+ mach_port_t active)
+{
+ struct node *np;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ if (!(passive_flags & FS_TRANS_SET) && !(active_flags & FS_TRANS_SET))
+ return 0;
+
+ if (passivelen && passive[passivelen - 1])
+ return EINVAL;
+
+ np = user->po->np;
+
+ char trans[sizeof _HURD_IFSOCK + passivelen];
+ memcpy (trans, _HURD_IFSOCK, sizeof _HURD_IFSOCK);
+ memcpy (&trans[sizeof _HURD_IFSOCK], passive, passivelen);
+ return file_set_translator (netfs_node_netnode (np)->file,
+ FS_TRANS_EXCL|FS_TRANS_SET,
+ FS_TRANS_EXCL|FS_TRANS_SET, 0,
+ trans, sizeof trans,
+ MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND);
+}
+
+
/* These callbacks are used only by the standard netfs_S_dir_lookup,
which we do not use. But the shared library requires us to define them. */
error_t