[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 08/23: trans/crash: convert to trivfs dynamic classes and buckets
From: |
Samuel Thibault |
Subject: |
[hurd] 08/23: trans/crash: 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 2656f79608c8db735514bafe8026211c92d06aa1
Author: Justus Winter <address@hidden>
Date: Sun Sep 27 17:07:18 2015 +0200
trans/crash: 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.
* trans/crash.c: Convert to dynamic classes and buckets.
---
trans/crash.c | 50 ++++++++++++++++++++++++++++----------------------
1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/trans/crash.c b/trans/crash.c
index c424b16..23f2a2d 100644
--- a/trans/crash.c
+++ b/trans/crash.c
@@ -44,6 +44,10 @@ process_t procserver; /* Our proc port, for
easy access. */
/* Port bucket we service requests on. */
struct port_bucket *port_bucket;
+/* Our port classes. */
+struct port_class *trivfs_control_class;
+struct port_class *trivfs_protid_class;
+
/* Trivfs hooks. */
int trivfs_fstype = FSTYPE_MISC;
int trivfs_fsid = 0;
@@ -52,11 +56,6 @@ int trivfs_support_write = 0;
int trivfs_support_exec = 0;
int trivfs_allow_open = O_READ|O_WRITE|O_EXEC;
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
-
struct trivfs_control *fsys;
enum crash_action
@@ -156,7 +155,7 @@ S_crash_dump_task (mach_port_t port,
mach_port_t user_proc = MACH_PORT_NULL;
enum crash_action how;
- cred = ports_lookup_port (port_bucket, port, trivfs_protid_portclasses[0]);
+ cred = ports_lookup_port (port_bucket, port, trivfs_protid_class);
if (! cred)
return EOPNOTSUPP;
@@ -415,11 +414,11 @@ dead_crasher (void *ptr)
/* The port data structures are cleaned up when we return. */
/* 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. Maybe we have no crashers still
around either. */
@@ -428,9 +427,9 @@ dead_crasher (void *ptr)
exit (0);
ports_enable_class (crasher_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);
}
@@ -563,20 +562,27 @@ main (int argc, char **argv)
/* Fetch our proc server port for easy use. */
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);
crasher_portclass = ports_create_class (dead_crasher, 0);
+ 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");
+
/* Reply to our parent. */
err = trivfs_startup (bootstrap, 0,
- trivfs_cntl_portclasses[0], port_bucket,
- trivfs_protid_portclasses[0], port_bucket,
- &fsys);
+ trivfs_control_class, NULL,
+ trivfs_protid_class, NULL, &fsys);
+
mach_port_deallocate (mach_task_self (), bootstrap);
if (err)
error (3, err, "Contacting parent");
+ port_bucket = fsys->pi.bucket;
+
/* Launch. */
do
ports_manage_port_operations_multithread (port_bucket, crash_demuxer,
@@ -602,11 +608,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/crash 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. */
@@ -629,9 +635,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] 12/23: trans/passwd: convert to trivfs dynamic classes and buckets, (continued)
- [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, 2015/10/15
- [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 <=