[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 23/31: startup: implement bits of the fs and io protocols
From: |
Samuel Thibault |
Subject: |
[hurd] 23/31: startup: implement bits of the fs and io protocols |
Date: |
Mon, 02 May 2016 23:48:33 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 10218526abf4c7537642cf5c3d8955578d599402
Author: Justus Winter <address@hidden>
Date: Sat Apr 23 17:52:33 2016 +0200
startup: implement bits of the fs and io protocols
* startup/Makefile: Build fs and io server with default
implementations.
(mung_msg_S.h): Tune regexp only to match the include guard.
* startup/startup.c (mig_reply_setup): New function.
(demuxer): Add new protocols. Nicer implementation.
(S_file_check_access): New function.
(S_io_restrict_auth): Likewise.
---
startup/Makefile | 6 ++--
startup/startup.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 101 insertions(+), 11 deletions(-)
diff --git a/startup/Makefile b/startup/Makefile
index ee2ecdd5..db062ad 100644
--- a/startup/Makefile
+++ b/startup/Makefile
@@ -21,15 +21,17 @@ makemode := server
SRCS = startup.c
OBJS = $(SRCS:.c=.o) \
startupServer.o notifyServer.o startup_replyUser.o msgServer.o \
- startup_notifyUser.o fsysServer.o
+ startup_notifyUser.o fsysServer.o fsServer.o ioServer.o
target = startup
HURDLIBS = shouldbeinlibc
# startup does not use libports. Disable the default payload to port
# conversion.
MIGSFLAGS="-DHURD_DEFAULT_PAYLOAD_TO_PORT=1"
+fsServer-CFLAGS="-DMIG_EOPNOTSUPP=EOPNOTSUPP"
+ioServer-CFLAGS="-DMIG_EOPNOTSUPP=EOPNOTSUPP"
include ../Makeconf
mung_msg_S.h: msg_S.h
- sed 's/msg_server/mung_msg_server/' < $< > $@
+ sed 's/_msg_server/_mung_msg_server/' < $< > $@
diff --git a/startup/startup.c b/startup/startup.c
index 9c45f4b..97a1bab 100644
--- a/startup/startup.c
+++ b/startup/startup.c
@@ -51,12 +51,16 @@
#include <version.h>
#include <argp.h>
#include <pids.h>
+#include <idvec.h>
#include "startup_notify_U.h"
#include "startup_reply_U.h"
#include "startup_S.h"
#include "notify_S.h"
#include "mung_msg_S.h"
+#include "fsys_S.h"
+#include "fs_S.h"
+#include "io_S.h"
/* host_reboot flags for when we crash. */
static int crash_flags = RB_AUTOBOOT;
@@ -498,19 +502,57 @@ run_for_real (char *filename, char *args, int arglen,
mach_port_t ctty,
/** Main program and setup **/
+/* XXX: The libc should provide this function. */
+static void
+mig_reply_setup (
+ const mach_msg_header_t *in,
+ mach_msg_header_t *out)
+{
+ static const mach_msg_type_t RetCodeType = {
+ /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32,
+ /* msgt_size = */ 32,
+ /* msgt_number = */ 1,
+ /* msgt_inline = */ TRUE,
+ /* msgt_longform = */ FALSE,
+ /* msgt_deallocate = */ FALSE,
+ /* msgt_unused = */ 0
+ };
+
+#define InP (in)
+#define OutP ((mig_reply_header_t *) out)
+ OutP->Head.msgh_bits =
+ MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(InP->msgh_bits), 0);
+ OutP->Head.msgh_size = sizeof *OutP;
+ OutP->Head.msgh_remote_port = InP->msgh_remote_port;
+ OutP->Head.msgh_local_port = MACH_PORT_NULL;
+ OutP->Head.msgh_seqno = 0;
+ OutP->Head.msgh_id = InP->msgh_id + 100;
+ OutP->RetCodeType = RetCodeType;
+ OutP->RetCode = MIG_BAD_ID;
+#undef InP
+#undef OutP
+}
+
static int
demuxer (mach_msg_header_t *inp,
mach_msg_header_t *outp)
{
- extern int notify_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int startup_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int msg_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int fsys_server (mach_msg_header_t *, mach_msg_header_t *);
-
- return (notify_server (inp, outp) ||
- msg_server (inp, outp) ||
- fsys_server (inp, outp) ||
- startup_server (inp, outp));
+ mig_routine_t routine;
+
+ mig_reply_setup (inp, outp);
+
+ if ((routine = notify_server_routine (inp)) ||
+ (routine = msg_server_routine (inp)) ||
+ (routine = fsys_server_routine (inp)) ||
+ (routine = fs_server_routine (inp)) ||
+ (routine = io_server_routine (inp)) ||
+ (routine = startup_server_routine (inp)))
+ {
+ (*routine) (inp, outp);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
error_t
@@ -1703,3 +1745,49 @@ S_fsys_forward (mach_port_t server, mach_port_t
requestor,
{
return EOPNOTSUPP;
}
+
+error_t
+S_file_check_access (mach_port_t server,
+ int *allowed)
+{
+ if (server != startup)
+ return EOPNOTSUPP;
+ *allowed = 0;
+ return 0;
+}
+
+error_t
+S_io_stat (mach_port_t server,
+ struct stat *st)
+{
+ if (server != startup)
+ return EOPNOTSUPP;
+
+ memset (st, 0, sizeof *st);
+
+ st->st_fstype = FSTYPE_MISC;
+ st->st_fsid = getpid ();
+ st->st_mode = S_IFCHR | S_IROOT;
+
+ return 0;
+}
+
+error_t
+S_io_restrict_auth (mach_port_t server,
+ mach_port_t *newport,
+ mach_msg_type_name_t *newporttype,
+ uid_t *uids, size_t nuids,
+ uid_t *gids, size_t ngids)
+{
+ struct idvec user = { uids, (unsigned) nuids, (unsigned) nuids };
+
+ if (server != startup)
+ return EOPNOTSUPP;
+
+ if (! idvec_contains (&user, 0))
+ return EPERM;
+
+ *newport = server;
+ *newporttype = MACH_MSG_TYPE_COPY_SEND;
+ return 0;
+}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 14/31: libdiskfs: improve error handling, (continued)
- [hurd] 14/31: libdiskfs: improve error handling, Samuel Thibault, 2016/05/02
- [hurd] 15/31: libtrivfs: fix error handling, Samuel Thibault, 2016/05/02
- [hurd] 17/31: Fix supporting >4GiB files in ext2fs, Samuel Thibault, 2016/05/02
- [hurd] 18/31: libdiskfs: Reject LFS seeks and read/writes, Samuel Thibault, 2016/05/02
- [hurd] 22/31: Unify and document the way fsids are handled in trivfs translators, Samuel Thibault, 2016/05/02
- [hurd] 21/31: libshouldbeinlibc: use the new assert in the refcount primitives, Samuel Thibault, 2016/05/02
- [hurd] 12/31: Fix access mode of temporary files, Samuel Thibault, 2016/05/02
- [hurd] 02/31: Fix swap information numbers, Samuel Thibault, 2016/05/02
- [hurd] 19/31: libpager: add missing include, Samuel Thibault, 2016/05/02
- [hurd] 09/31: Make make install idempotent, Samuel Thibault, 2016/05/02
- [hurd] 23/31: startup: implement bits of the fs and io protocols,
Samuel Thibault <=
- [hurd] 11/31: libfshelp: pass cookie to the callback function, Samuel Thibault, 2016/05/02
- [hurd] 13/31: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, Samuel Thibault, 2016/05/02
- [hurd] 20/31: libshouldbeinlibc: add assert(3) variant that prints backtraces, Samuel Thibault, 2016/05/02
- [hurd] 07/31: utils/settrans: get an authenticated root node in chroot mode, Samuel Thibault, 2016/05/02
- [hurd] 06/31: isofs: make superblock detection more robust, Samuel Thibault, 2016/05/02
- [hurd] 08/31: utils/settrans: add option to specify the underlying node, Samuel Thibault, 2016/05/02
- [hurd] 31/31: Fix build, Samuel Thibault, 2016/05/02
- [hurd] 29/31: libihash: keep track of free slots, Samuel Thibault, 2016/05/02
- [hurd] 10/31: mach-defpager: fix error handling, Samuel Thibault, 2016/05/02
- [hurd] 30/31: libihash: rehash if effective load exceeds the threshold, Samuel Thibault, 2016/05/02