[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 05/23: exec: convert to trivfs dynamic classes and buckets
From: |
Samuel Thibault |
Subject: |
[hurd] 05/23: exec: convert to trivfs dynamic classes and buckets |
Date: |
Tue, 13 Oct 2015 00:09:55 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit a5d384c333dbbe863c1515d6167d956b0c5b4852
Author: Justus Winter <address@hidden>
Date: Sun Sep 27 18:54:31 2015 +0200
exec: convert to trivfs dynamic classes and buckets
libtrivfs contains two ways of managing more than one port class and
bucket. There is the old way of using a statically allocated array
with explicit length, and the new way with dynamically allocated
vectors.
Converting all users to the new way of handling multiple classes
and/or buckets, we can simplify the code in libtrivfs. In many cases,
the code will be simpler and more expressive for the user.
This also fixes a mild bug. The classes and buckets given to
`trivfs_startup' end up in the dynamic vectors too, making the object
lookup code use the more complicated code path.
* exec/main.c: Convert to dynamic classes and buckets.
---
exec/main.c | 51 ++++++++++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 19 deletions(-)
diff --git a/exec/main.c b/exec/main.c
index 6553c42..beb6f61 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -38,10 +38,9 @@ int trivfs_support_read = 0;
int trivfs_support_write = 0;
int trivfs_allow_open = 0;
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
+/* Our port classes. */
+struct port_class *trivfs_protid_class;
+struct port_class *trivfs_control_class;
struct trivfs_control *fsys;
@@ -88,11 +87,11 @@ deadboot (void *p)
munmap (boot->intarray, boot->nints * sizeof (int));
/* See if we are going away and this was the last thing keeping us up. */
- if (ports_count_class (trivfs_cntl_portclasses[0]) == 0)
+ if (ports_count_class (trivfs_control_class) == 0)
{
/* We have no fsys control port, so we are detached from the
parent filesystem. Maybe we have no users left either. */
- if (ports_count_class (trivfs_protid_portclasses[0]) == 0)
+ if (ports_count_class (trivfs_protid_class) == 0)
{
/* We have no user ports left. Are we still listening for
exec_startup RPCs from any tasks we already started? */
@@ -101,9 +100,9 @@ deadboot (void *p)
exit (0);
ports_enable_class (execboot_portclass);
}
- ports_enable_class (trivfs_protid_portclasses[0]);
+ ports_enable_class (trivfs_protid_class);
}
- ports_enable_class (trivfs_cntl_portclasses[0]);
+ ports_enable_class (trivfs_control_class);
}
#define OPT_DEVICE_MASTER_PORT (-1)
@@ -215,15 +214,29 @@ main (int argc, char **argv)
S_exec_init (below). */
procserver = getproc ();
- port_bucket = ports_create_bucket ();
- trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
- trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
+ err = trivfs_add_port_bucket (&port_bucket);
+ if (err)
+ error (1, 0, "error creating port bucket");
+
+ err = trivfs_add_control_port_class (&trivfs_control_class);
+ if (err)
+ error (1, 0, "error creating control port class");
+
+ err = trivfs_add_protid_port_class (&trivfs_protid_class);
+ if (err)
+ error (1, 0, "error creating protid port class");
+
execboot_portclass = ports_create_class (deadboot, NULL);
/* Reply to our parent. */
err = trivfs_startup (bootstrap, 0,
- trivfs_cntl_portclasses[0], port_bucket,
- trivfs_protid_portclasses[0], port_bucket,
+ trivfs_control_class, port_bucket,
+ trivfs_protid_class, port_bucket, &fsys);
+
+ /* Reply to our parent. */
+ err = trivfs_startup (bootstrap, 0,
+ trivfs_control_class, port_bucket,
+ trivfs_protid_class, port_bucket,
&fsys);
mach_port_deallocate (mach_task_self (), bootstrap);
if (err)
@@ -249,11 +262,11 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
int count;
/* Stop new requests. */
- ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]);
- ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]);
+ ports_inhibit_class_rpcs (trivfs_control_class);
+ ports_inhibit_class_rpcs (trivfs_protid_class);
/* Are there any extant user ports for the /servers/exec file? */
- count = ports_count_class (trivfs_protid_portclasses[0]);
+ count = ports_count_class (trivfs_protid_class);
if (count == 0 || (flags & FSYS_GOAWAY_FORCE))
{
/* No users. Disconnect from the filesystem. */
@@ -276,9 +289,9 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
else
{
/* We won't go away, so start things going again... */
- ports_enable_class (trivfs_protid_portclasses[0]);
- ports_resume_class_rpcs (trivfs_cntl_portclasses[0]);
- ports_resume_class_rpcs (trivfs_protid_portclasses[0]);
+ ports_enable_class (trivfs_protid_class);
+ ports_resume_class_rpcs (trivfs_control_class);
+ ports_resume_class_rpcs (trivfs_protid_class);
return EBUSY;
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 11/23: trans/new-fifo: convert to trivfs dynamic classes and buckets, (continued)
- [hurd] 11/23: trans/new-fifo: convert to trivfs dynamic classes and buckets, Samuel Thibault, 2015/10/12
- [hurd] 07/23: pflocal: convert to trivfs dynamic classes and buckets, Samuel Thibault, 2015/10/12
- [hurd] 09/23: trans/ifsock: convert to trivfs dynamic classes and buckets, Samuel Thibault, 2015/10/12
- [hurd] 12/23: trans/passwd: convert to trivfs dynamic classes and buckets, Samuel Thibault, 2015/10/12
- [hurd] 13/23: trans/proxy-defpager: convert to trivfs dynamic classes and buckets, Samuel Thibault, 2015/10/15
- [hurd] 17/23: libdiskfs: fflush stdout when pausing, Samuel Thibault, 2015/10/15
- [hurd] 22/23: Make dir_lookup create files with user permissions enabled, Samuel Thibault, 2015/10/15
- [hurd] 16/23: Minor documentation changes, Samuel Thibault, 2015/10/15
- [hurd] 03/23: libdiskfs: improve error handling, Samuel Thibault, 2015/10/15
- [hurd] 02/23: exec: add missing include, Samuel Thibault, 2015/10/15
- [hurd] 05/23: exec: convert to trivfs dynamic classes and buckets,
Samuel Thibault <=
- [hurd] 01/23: libports: remove unused variables, Samuel Thibault, 2015/10/15
- [hurd] 06/23: pfinet: convert to trivfs dynamic classes and buckets, Samuel Thibault, 2015/10/15
- [hurd] 08/23: trans/crash: convert to trivfs dynamic classes and buckets, Samuel Thibault, 2015/10/15