diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-09-27 22:08:53 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-09-27 22:08:53 +0200 |
commit | 420b95fe7e0a4ed6b01d89aa3fbdfec45de8829d (patch) | |
tree | 5d3b206c2fd25744d87287678f64e52c8f53abbf /debian/patches | |
parent | 8faccce60ee5736e6e75c0f74620dfa68ab24b90 (diff) |
add patch series
Diffstat (limited to 'debian/patches')
11 files changed, 1051 insertions, 0 deletions
diff --git a/debian/patches/random-fixes0001-libdiskfs-improve-error-handling.patch b/debian/patches/random-fixes0001-libdiskfs-improve-error-handling.patch new file mode 100644 index 00000000..bb45e5fa --- /dev/null +++ b/debian/patches/random-fixes0001-libdiskfs-improve-error-handling.patch @@ -0,0 +1,39 @@ +From 9f179b1ab674355d5afbb6d664dee2d2ac6cb89c Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 16:20:17 +0200 +Subject: [PATCH hurd 01/10] libdiskfs: improve error handling + +* libdiskfs/boot-start.c (start_execserver): Improve error handling. +--- + libdiskfs/boot-start.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c +index d10d783..6b829f2 100644 +--- a/libdiskfs/boot-start.c ++++ b/libdiskfs/boot-start.c +@@ -637,15 +637,18 @@ start_execserver (void) + assert_perror (err); + right = ports_get_send_right (execboot_info); + ports_port_deref (execboot_info); +- task_set_special_port (diskfs_exec_server_task, TASK_BOOTSTRAP_PORT, right); +- mach_port_deallocate (mach_task_self (), right); ++ err = task_set_special_port (diskfs_exec_server_task, TASK_BOOTSTRAP_PORT, right); ++ assert_perror (err); ++ err = mach_port_deallocate (mach_task_self (), right); ++ assert_perror (err); + + if (_diskfs_boot_pause) + { + printf ("pausing for exec\n"); + getc (stdin); + } +- task_resume (diskfs_exec_server_task); ++ err = task_resume (diskfs_exec_server_task); ++ assert_perror (err); + + printf (" exec"); + fflush (stdout); +-- +2.1.4 + diff --git a/debian/patches/random-fixes0002-libdiskfs-fflush-stdout-when-pausing.patch b/debian/patches/random-fixes0002-libdiskfs-fflush-stdout-when-pausing.patch new file mode 100644 index 00000000..8e98d17d --- /dev/null +++ b/debian/patches/random-fixes0002-libdiskfs-fflush-stdout-when-pausing.patch @@ -0,0 +1,25 @@ +From 9e8cb4acfd8971f691b35657e1f63a903f638996 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 16:20:50 +0200 +Subject: [PATCH hurd 02/10] libdiskfs: fflush stdout when pausing + +* libdiskfs/boot-start.c (start_execserver): fflush stdout when pausing. +--- + libdiskfs/boot-start.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c +index 6b829f2..809e2c0 100644 +--- a/libdiskfs/boot-start.c ++++ b/libdiskfs/boot-start.c +@@ -645,6 +645,7 @@ start_execserver (void) + if (_diskfs_boot_pause) + { + printf ("pausing for exec\n"); ++ fflush (stdout); + getc (stdin); + } + err = task_resume (diskfs_exec_server_task); +-- +2.1.4 + diff --git a/debian/patches/random-fixes0003-exec-convert-to-trivfs-dynamic-classes-and-buckets.patch b/debian/patches/random-fixes0003-exec-convert-to-trivfs-dynamic-classes-and-buckets.patch new file mode 100644 index 00000000..dd43ec03 --- /dev/null +++ b/debian/patches/random-fixes0003-exec-convert-to-trivfs-dynamic-classes-and-buckets.patch @@ -0,0 +1,133 @@ +From 920b5d1a66bb4bdbc072e13480e552d8ba511e85 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 18:54:31 +0200 +Subject: [PATCH hurd 03/10] 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, 31 insertions(+), 20 deletions(-) + +diff --git a/exec/main.c b/exec/main.c +index 6553c42..9f8e53c 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,27 @@ 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); +- execboot_portclass = ports_create_class (deadboot, NULL); ++ 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"); ++ ++ /* Reply to our parent. */ ++ err = trivfs_startup (bootstrap, 0, ++ trivfs_control_class, port_bucket, ++ trivfs_protid_class, port_bucket, &fsys); + + /* 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); + mach_port_deallocate (mach_task_self (), bootstrap); + if (err) +@@ -249,11 +260,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 +287,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; + } +-- +2.1.4 + diff --git a/debian/patches/random-fixes0004-pfinet-convert-to-trivfs-dynamic-classes-and-buckets.patch b/debian/patches/random-fixes0004-pfinet-convert-to-trivfs-dynamic-classes-and-buckets.patch new file mode 100644 index 00000000..da99c745 --- /dev/null +++ b/debian/patches/random-fixes0004-pfinet-convert-to-trivfs-dynamic-classes-and-buckets.patch @@ -0,0 +1,228 @@ +From 004c432be995bf8c1fc74e2726a077a009792746 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 18:50:11 +0200 +Subject: [PATCH hurd 04/10] pfinet: 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. + +* pfinet/main.c: Convert to dynamic classes and buckets. +* pfinet/options.c: Likewise. +* pfinet/pfinet.h: Likewise. +* pfinet/socket-ops.c: Likewise. +--- + pfinet/main.c | 61 +++++++++++++++++++++++++++++------------------------ + pfinet/options.c | 8 +++---- + pfinet/pfinet.h | 7 ++---- + pfinet/socket-ops.c | 2 +- + 4 files changed, 41 insertions(+), 37 deletions(-) + +diff --git a/pfinet/main.c b/pfinet/main.c +index 8716fdb..46457a9 100644 +--- a/pfinet/main.c ++++ b/pfinet/main.c +@@ -56,11 +56,9 @@ int trivfs_support_write = 1; + int trivfs_support_exec = 0; + int trivfs_allow_open = O_READ | O_WRITE; + +-struct port_class *trivfs_protid_portclasses[2]; +-int trivfs_protid_nportclasses = 2; +- +-struct port_class *trivfs_cntl_portclasses[2]; +-int trivfs_cntl_nportclasses = 2; ++/* We have a class each per portclass. */ ++struct port_class *pfinet_protid_portclasses[2]; ++struct port_class *pfinet_cntl_portclasses[2]; + + /* Which portclass to install on the bootstrap port, default to IPv4. */ + int pfinet_bootstrap_portclass = PORTCLASS_INET; +@@ -334,7 +332,7 @@ main (int argc, + + if (bootstrap != MACH_PORT_NULL) { + /* Create portclass to install on the bootstrap port. */ +- if(trivfs_protid_portclasses[pfinet_bootstrap_portclass] ++ if(pfinet_protid_portclasses[pfinet_bootstrap_portclass] + != MACH_PORT_NULL) + error(1, 0, "No portclass left to assign to bootstrap port"); + +@@ -342,17 +340,23 @@ main (int argc, + if (pfinet_bootstrap_portclass == PORTCLASS_INET6) + pfinet_activate_ipv6 (); + #endif +- +- trivfs_protid_portclasses[pfinet_bootstrap_portclass] = +- ports_create_class (trivfs_clean_protid, 0); +- trivfs_cntl_portclasses[pfinet_bootstrap_portclass] = +- ports_create_class (trivfs_clean_cntl, 0); ++ ++ err = trivfs_add_protid_port_class ( ++ &pfinet_protid_portclasses[pfinet_bootstrap_portclass]); ++ if (err) ++ error (1, 0, "error creating control port class"); ++ ++ err = trivfs_add_control_port_class ( ++ &pfinet_cntl_portclasses[pfinet_bootstrap_portclass]); ++ if (err) ++ error (1, 0, "error creating control port class"); + + /* Talk to parent and link us in. */ + err = trivfs_startup (bootstrap, 0, +- trivfs_cntl_portclasses[pfinet_bootstrap_portclass], +- pfinet_bucket, trivfs_protid_portclasses +- [pfinet_bootstrap_portclass], pfinet_bucket, ++ pfinet_cntl_portclasses[pfinet_bootstrap_portclass], ++ pfinet_bucket, ++ pfinet_protid_portclasses[pfinet_bootstrap_portclass], ++ pfinet_bucket, + &pfinetctl); + + if (err) +@@ -371,7 +375,7 @@ main (int argc, + /* Check that at least one portclass has been bound, + error out otherwise. */ + for (i = 0; i < trivfs_protid_nportclasses; i ++) +- if (trivfs_protid_portclasses[i] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[i] != MACH_PORT_NULL) + break; + + if (i == trivfs_protid_nportclasses) +@@ -424,22 +428,25 @@ pfinet_bind (int portclass, const char *name) + err = errno; + + if (! err) { +- if (trivfs_protid_portclasses[portclass] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[portclass] != MACH_PORT_NULL) + error (1, 0, "Cannot bind one protocol to multiple nodes.\n"); + + #ifdef CONFIG_IPV6 + if (portclass == PORTCLASS_INET6) + pfinet_activate_ipv6 (); + #endif ++ //mark ++ err = trivfs_add_protid_port_class (&pfinet_protid_portclasses[portclass]); ++ if (err) ++ error (1, 0, "error creating control port class"); + +- trivfs_protid_portclasses[portclass] = +- ports_create_class (trivfs_clean_protid, 0); +- trivfs_cntl_portclasses[portclass] = +- ports_create_class (trivfs_clean_cntl, 0); ++ err = trivfs_add_control_port_class (&pfinet_cntl_portclasses[portclass]); ++ if (err) ++ error (1, 0, "error creating control port class"); + +- err = trivfs_create_control (file, trivfs_cntl_portclasses[portclass], +- pfinet_bucket, +- trivfs_protid_portclasses[portclass], ++ err = trivfs_create_control (file, pfinet_cntl_portclasses[portclass], ++ pfinet_bucket, ++ pfinet_protid_portclasses[portclass], + pfinet_bucket, &cntl); + } + +@@ -473,16 +480,16 @@ trivfs_goaway (struct trivfs_control *cntl, int flags) + else + { + /* Stop new requests. */ +- ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]); +- ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]); ++ ports_inhibit_class_rpcs (pfinet_cntl_portclasses[0]); ++ ports_inhibit_class_rpcs (pfinet_protid_portclasses[0]); + ports_inhibit_class_rpcs (socketport_class); + + if (ports_count_class (socketport_class) != 0) + { + /* We won't go away, so start things going again... */ + ports_enable_class (socketport_class); +- ports_resume_class_rpcs (trivfs_cntl_portclasses[0]); +- ports_resume_class_rpcs (trivfs_protid_portclasses[0]); ++ ports_resume_class_rpcs (pfinet_cntl_portclasses[0]); ++ ports_resume_class_rpcs (pfinet_protid_portclasses[0]); + + return EBUSY; + } +diff --git a/pfinet/options.c b/pfinet/options.c +index daffcd5..ae44759 100644 +--- a/pfinet/options.c ++++ b/pfinet/options.c +@@ -133,7 +133,7 @@ parse_interface_copy_device(struct device *src, + && FIB_RES_GW(res) != INADDR_ANY) + dst->gateway = FIB_RES_GW (res); + #ifdef CONFIG_IPV6 +- if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) + idev = ipv6_find_idev(src); + + if (idev) +@@ -452,7 +452,7 @@ parse_opt (int opt, char *arg, struct argp_state *state) + { + #ifdef CONFIG_IPV6 + struct inet6_dev *idev = NULL; +- if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL ++ if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL + && in->device) + idev = ipv6_find_idev(in->device); + #endif +@@ -570,7 +570,7 @@ parse_opt (int opt, char *arg, struct argp_state *state) + + /* Set IPv6 default router. */ + #ifdef CONFIG_IPV6 +- if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) + { + struct rt6_info *rt6i = ipv6_get_dflt_router (); + +@@ -710,7 +710,7 @@ trivfs_append_args (struct trivfs_control *fsys, char **argz, size_t *argz_len) + #ifdef CONFIG_IPV6 + struct inet6_dev *idev = NULL; + +- if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) + idev = ipv6_find_idev(dev); + + if (idev) +diff --git a/pfinet/pfinet.h b/pfinet/pfinet.h +index 46aa97b..6e59225 100644 +--- a/pfinet/pfinet.h ++++ b/pfinet/pfinet.h +@@ -92,11 +92,8 @@ enum { + PORTCLASS_INET6, + }; + +-extern struct port_class *trivfs_protid_portclasses[]; +-extern int trivfs_protid_nportclasses; +- +-extern struct port_class *trivfs_cntl_portclasses[2]; +-extern int trivfs_cntl_nportclasses; ++extern struct port_class *pfinet_protid_portclasses[2]; ++extern struct port_class *pfinet_cntl_portclasses[2]; + + /* Which portclass to install on the bootstrap port. */ + extern int pfinet_bootstrap_portclass; +diff --git a/pfinet/socket-ops.c b/pfinet/socket-ops.c +index 3f8b7fb..14b3120 100644 +--- a/pfinet/socket-ops.c ++++ b/pfinet/socket-ops.c +@@ -82,7 +82,7 @@ S_socket_create (struct trivfs_protid *master, + isroot = 1; + } + +- if (master->pi.class == trivfs_protid_portclasses[PORTCLASS_INET]) ++ if (master->pi.class == pfinet_protid_portclasses[PORTCLASS_INET]) + err = - (*net_families[PF_INET]->create) (sock, protocol); + else + err = - (*net_families[PF_INET6]->create) (sock, protocol); +-- +2.1.4 + diff --git a/debian/patches/random-fixes0005-pflocal-convert-to-trivfs-dynamic-classes-and-bucket.patch b/debian/patches/random-fixes0005-pflocal-convert-to-trivfs-dynamic-classes-and-bucket.patch new file mode 100644 index 00000000..d9cadbd3 --- /dev/null +++ b/debian/patches/random-fixes0005-pflocal-convert-to-trivfs-dynamic-classes-and-bucket.patch @@ -0,0 +1,81 @@ +From 346422b9d01e1be3e71d091dde81db848ef6ef99 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 17:01:37 +0200 +Subject: [PATCH hurd 05/10] pflocal: 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. + +* pflocal/pflocal.c: Convert to dynamic classes and buckets. +--- + pflocal/pflocal.c | 20 ++++---------------- + 1 file changed, 4 insertions(+), 16 deletions(-) + +diff --git a/pflocal/pflocal.c b/pflocal/pflocal.c +index fcb62d1..07d1a97 100644 +--- a/pflocal/pflocal.c ++++ b/pflocal/pflocal.c +@@ -38,12 +38,6 @@ int trivfs_support_read = 0; + int trivfs_support_write = 0; + int trivfs_support_exec = 0; + int trivfs_allow_open = 0; +- +-/* Trivfs noise. */ +-struct port_class *trivfs_protid_portclasses[1]; +-struct port_class *trivfs_cntl_portclasses[1]; +-int trivfs_protid_nportclasses = 1; +-int trivfs_cntl_nportclasses = 1; + + /* ---------------------------------------------------------------- */ + #include "socket_S.h" +@@ -70,6 +64,7 @@ main(int argc, char *argv[]) + { + error_t err; + mach_port_t bootstrap; ++ struct trivfs_control *fsys; + + if (argc > 1) + { +@@ -81,25 +76,18 @@ main(int argc, char *argv[]) + if (bootstrap == MACH_PORT_NULL) + error(2, 0, "Must be started as a translator"); + +- pf_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); +- + /* Prepare to create sockets. */ + err = sock_global_init (); + if (err) + error(3, err, "Initializing"); + + /* Reply to our parent */ +- err = +- trivfs_startup (bootstrap, 0, +- trivfs_cntl_portclasses[0], pf_port_bucket, +- trivfs_protid_portclasses[0], pf_port_bucket, +- NULL); ++ err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys); + if (err) + error(3, err, "Contacting parent"); + ++ pf_port_bucket = fsys->pi.bucket; ++ + /* Launch. */ + do + ports_manage_port_operations_multithread (pf_port_bucket, +-- +2.1.4 + diff --git a/debian/patches/random-fixes0006-trans-crash-convert-to-trivfs-dynamic-classes-and-bu.patch b/debian/patches/random-fixes0006-trans-crash-convert-to-trivfs-dynamic-classes-and-bu.patch new file mode 100644 index 00000000..6cf50112 --- /dev/null +++ b/debian/patches/random-fixes0006-trans-crash-convert-to-trivfs-dynamic-classes-and-bu.patch @@ -0,0 +1,151 @@ +From c1dd153d9602b855771b3f6d3adc853bf8c3c379 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 17:07:18 +0200 +Subject: [PATCH hurd 06/10] 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; + } +-- +2.1.4 + diff --git a/debian/patches/random-fixes0007-trans-passwd-convert-to-trivfs-dynamic-classes-and-b.patch b/debian/patches/random-fixes0007-trans-passwd-convert-to-trivfs-dynamic-classes-and-b.patch new file mode 100644 index 00000000..14ca1d01 --- /dev/null +++ b/debian/patches/random-fixes0007-trans-passwd-convert-to-trivfs-dynamic-classes-and-b.patch @@ -0,0 +1,128 @@ +From aace82ecbe4cd7841ed873c67d3788a8d169a16a Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 16:26:03 +0200 +Subject: [PATCH hurd 07/10] trans/passwd: 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/password.c: Convert to dynamic classes and buckets. +--- + trans/password.c | 48 +++++++++++++++++++++++++++--------------------- + 1 file changed, 27 insertions(+), 21 deletions(-) + +diff --git a/trans/password.c b/trans/password.c +index 344b78b..9ffcaa0 100644 +--- a/trans/password.c ++++ b/trans/password.c +@@ -39,6 +39,10 @@ const char *argp_program_version = STANDARD_HURD_VERSION (password); + /* 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; +@@ -46,12 +50,6 @@ int trivfs_support_read = 0; + int trivfs_support_write = 0; + int trivfs_support_exec = 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; +- + + static int + password_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) +@@ -75,15 +73,23 @@ main (int argc, char *argv[]) + if (bootstrap == MACH_PORT_NULL) + error (1, 0, "must be started as a translator"); + +- 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"); ++ + /* 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, port_bucket, ++ trivfs_protid_class, port_bucket, ++ &fsys); + mach_port_deallocate (mach_task_self (), bootstrap); + if (err) + error (3, err, "Contacting parent"); +@@ -114,17 +120,17 @@ 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/password file? */ +- count = ports_count_class (trivfs_protid_portclasses[0]); ++ count = ports_count_class (trivfs_protid_class); + if (count > 0 && !(flags & FSYS_GOAWAY_FORCE)) + { + /* 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; + } +@@ -153,7 +159,7 @@ S_password_check_user (struct trivfs_protid *cred, uid_t user, char *pw, + return EOPNOTSUPP; + + if (cred->pi.bucket != port_bucket || +- cred->pi.class != trivfs_protid_portclasses[0]) ++ cred->pi.class != trivfs_protid_class) + { + ports_port_deref (cred); + return EOPNOTSUPP; +@@ -201,7 +207,7 @@ S_password_check_group (struct trivfs_protid *cred, uid_t group, char *pw, + return EOPNOTSUPP; + + if (cred->pi.bucket != port_bucket || +- cred->pi.class != trivfs_protid_portclasses[0]) ++ cred->pi.class != trivfs_protid_class) + { + ports_port_deref (cred); + return EOPNOTSUPP; +-- +2.1.4 + diff --git a/debian/patches/random-fixes0008-trans-proxy-defpager-convert-to-trivfs-dynamic-class.patch b/debian/patches/random-fixes0008-trans-proxy-defpager-convert-to-trivfs-dynamic-class.patch new file mode 100644 index 00000000..1f87f820 --- /dev/null +++ b/debian/patches/random-fixes0008-trans-proxy-defpager-convert-to-trivfs-dynamic-class.patch @@ -0,0 +1,43 @@ +From 16562faf8a87b422e1581161bcedc4622ac3f6f4 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 17:23:13 +0200 +Subject: [PATCH hurd 08/10] trans/proxy-defpager: 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 severe bug. As no classes are given to +`trivfs_startup', they are created and inserted into the dynamic +vector of classes. The helper function `allowed', however, used the +first item of the previously used static array, which is NULL. This +circumvented the typecheck, allowing the default pager protocol to be +spoken over control ports, likely resulting in a crash. + +* trans/proxy-defpager.c: Convert to dynamic classes and buckets. +--- + trans/proxy-defpager.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/trans/proxy-defpager.c b/trans/proxy-defpager.c +index 5fe8ffd..bc0d354 100644 +--- a/trans/proxy-defpager.c ++++ b/trans/proxy-defpager.c +@@ -34,7 +34,7 @@ static error_t + allowed (mach_port_t port, int mode) + { + struct trivfs_protid *cred = ports_lookup_port +- (0, port, trivfs_protid_portclasses[0]); ++ (0, port, trivfs_dynamic_protid_port_classes[0]); + if (!cred) + return MIG_BAD_ID; + error_t result = (cred->po->openmodes & mode) ? 0 : EACCES; +-- +2.1.4 + diff --git a/debian/patches/random-fixes0009-libtrivfs-optimize-the-object-lookup-code.patch b/debian/patches/random-fixes0009-libtrivfs-optimize-the-object-lookup-code.patch new file mode 100644 index 00000000..5bdae011 --- /dev/null +++ b/debian/patches/random-fixes0009-libtrivfs-optimize-the-object-lookup-code.patch @@ -0,0 +1,188 @@ +From 03093ef7b417e59e5decc96212f5aef322ec6036 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 18:55:39 +0200 +Subject: [PATCH hurd 09/10] libtrivfs: optimize the object lookup code + +* libtrivfs/mig-decls.h: Remove the specialized cases, they really +blow up these functions that are supposed to be inlined. Also, look +into the dynamically allocated vectors first, because this is the +preferred way of using libtrivfs since 1997. +--- + libtrivfs/mig-decls.h | 136 +++++++++++++++++++------------------------------- + 1 file changed, 52 insertions(+), 84 deletions(-) + +diff --git a/libtrivfs/mig-decls.h b/libtrivfs/mig-decls.h +index 13a9eb7..1909199 100644 +--- a/libtrivfs/mig-decls.h ++++ b/libtrivfs/mig-decls.h +@@ -37,57 +37,41 @@ extern size_t trivfs_num_dynamic_port_buckets; + static inline struct trivfs_protid * __attribute__ ((unused)) + trivfs_begin_using_protid (mach_port_t port) + { +- if (trivfs_protid_nportclasses + trivfs_num_dynamic_protid_port_classes > 1) ++ struct port_info *pi = ports_lookup_port (0, port, 0); ++ ++ if (pi) + { +- struct port_info *pi = ports_lookup_port (0, port, 0); +- int i; +- +- if (pi) +- { +- for (i = 0; i < trivfs_protid_nportclasses; i++) +- if (pi->class == trivfs_protid_portclasses[i]) +- return (struct trivfs_protid *) pi; +- for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++) +- if (pi->class == trivfs_dynamic_protid_port_classes[i]) +- return (struct trivfs_protid *) pi; +- ports_port_deref (pi); +- } +- +- return 0; ++ size_t i; ++ for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++) ++ if (pi->class == trivfs_dynamic_protid_port_classes[i]) ++ return (struct trivfs_protid *) pi; ++ for (i = 0; i < trivfs_protid_nportclasses; i++) ++ if (pi->class == trivfs_protid_portclasses[i]) ++ return (struct trivfs_protid *) pi; ++ ports_port_deref (pi); + } +- else if (trivfs_protid_nportclasses == 1) +- return ports_lookup_port (0, port, trivfs_protid_portclasses[0]); +- else +- return ports_lookup_port (0, port, trivfs_dynamic_protid_port_classes[0]); ++ ++ return NULL; + } + + static inline struct trivfs_protid * __attribute__ ((unused)) + trivfs_begin_using_protid_payload (unsigned long payload) + { +- if (trivfs_protid_nportclasses + trivfs_num_dynamic_protid_port_classes > 1) ++ struct port_info *pi = ports_lookup_payload (NULL, payload, NULL); ++ ++ if (pi) + { +- struct port_info *pi = ports_lookup_payload (NULL, payload, NULL); +- int i; +- +- if (pi) +- { +- for (i = 0; i < trivfs_protid_nportclasses; i++) +- if (pi->class == trivfs_protid_portclasses[i]) +- return (struct trivfs_protid *) pi; +- for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++) +- if (pi->class == trivfs_dynamic_protid_port_classes[i]) +- return (struct trivfs_protid *) pi; +- ports_port_deref (pi); +- } +- +- return NULL; ++ size_t i; ++ for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++) ++ if (pi->class == trivfs_dynamic_protid_port_classes[i]) ++ return (struct trivfs_protid *) pi; ++ for (i = 0; i < trivfs_protid_nportclasses; i++) ++ if (pi->class == trivfs_protid_portclasses[i]) ++ return (struct trivfs_protid *) pi; ++ ports_port_deref (pi); + } +- else if (trivfs_protid_nportclasses == 1) +- return ports_lookup_payload (NULL, payload, +- trivfs_protid_portclasses[0]); +- else +- return ports_lookup_payload (NULL, payload, +- trivfs_dynamic_protid_port_classes[0]); ++ ++ return NULL; + } + + static inline void __attribute__ ((unused)) +@@ -100,57 +84,41 @@ trivfs_end_using_protid (struct trivfs_protid *cred) + static inline struct trivfs_control * __attribute__ ((unused)) + trivfs_begin_using_control (mach_port_t port) + { +- if (trivfs_cntl_nportclasses + trivfs_num_dynamic_control_port_classes > 1) ++ struct port_info *pi = ports_lookup_port (0, port, 0); ++ ++ if (pi) + { +- struct port_info *pi = ports_lookup_port (0, port, 0); +- int i; +- +- if (pi) +- { +- for (i = 0; i < trivfs_cntl_nportclasses; i++) +- if (pi->class == trivfs_cntl_portclasses[i]) +- return (struct trivfs_control *) pi; +- for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++) +- if (pi->class == trivfs_dynamic_control_port_classes[i]) +- return (struct trivfs_control *) pi; +- ports_port_deref (pi); +- } +- +- return 0; ++ size_t i; ++ for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++) ++ if (pi->class == trivfs_dynamic_control_port_classes[i]) ++ return (struct trivfs_control *) pi; ++ for (i = 0; i < trivfs_cntl_nportclasses; i++) ++ if (pi->class == trivfs_cntl_portclasses[i]) ++ return (struct trivfs_control *) pi; ++ ports_port_deref (pi); + } +- else if (trivfs_cntl_nportclasses == 1) +- return ports_lookup_port (0, port, trivfs_cntl_portclasses[0]); +- else +- return ports_lookup_port (0, port, trivfs_dynamic_control_port_classes[0]); ++ ++ return NULL; + } + + static inline struct trivfs_control * __attribute__ ((unused)) + trivfs_begin_using_control_payload (unsigned long payload) + { +- if (trivfs_cntl_nportclasses + trivfs_num_dynamic_control_port_classes > 1) ++ struct port_info *pi = ports_lookup_payload (NULL, payload, NULL); ++ ++ if (pi) + { +- struct port_info *pi = ports_lookup_payload (NULL, payload, NULL); +- int i; +- +- if (pi) +- { +- for (i = 0; i < trivfs_cntl_nportclasses; i++) +- if (pi->class == trivfs_cntl_portclasses[i]) +- return (struct trivfs_control *) pi; +- for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++) +- if (pi->class == trivfs_dynamic_control_port_classes[i]) +- return (struct trivfs_control *) pi; +- ports_port_deref (pi); +- } +- +- return NULL; ++ size_t i; ++ for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++) ++ if (pi->class == trivfs_dynamic_control_port_classes[i]) ++ return (struct trivfs_control *) pi; ++ for (i = 0; i < trivfs_cntl_nportclasses; i++) ++ if (pi->class == trivfs_cntl_portclasses[i]) ++ return (struct trivfs_control *) pi; ++ ports_port_deref (pi); + } +- else if (trivfs_cntl_nportclasses == 1) +- return ports_lookup_payload (NULL, payload, +- trivfs_cntl_portclasses[0]); +- else +- return ports_lookup_payload (NULL, payload, +- trivfs_dynamic_control_port_classes[0]); ++ ++ return NULL; + } + + static inline void __attribute__ ((unused)) +-- +2.1.4 + diff --git a/debian/patches/random-fixes0010-fixup_exec.patch b/debian/patches/random-fixes0010-fixup_exec.patch new file mode 100644 index 00000000..531ac042 --- /dev/null +++ b/debian/patches/random-fixes0010-fixup_exec.patch @@ -0,0 +1,25 @@ +From 91eef760785a05de485a271522c91415922c0ab0 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 22:08:32 +0200 +Subject: [PATCH hurd 10/10] fixup_exec + +--- + exec/main.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/exec/main.c b/exec/main.c +index 9f8e53c..beb6f61 100644 +--- a/exec/main.c ++++ b/exec/main.c +@@ -226,6 +226,8 @@ main (int argc, char **argv) + 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_control_class, port_bucket, +-- +2.1.4 + diff --git a/debian/patches/series b/debian/patches/series index 68dfa6ca..c301bb1c 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -75,3 +75,13 @@ introspection0009-fixup_libports.patch introspection0010-fixup_libintrospection.patch introspection0011-fixup_libintrospection.patch introspection0012-fixup_libintrospection.patch +random-fixes0001-libdiskfs-improve-error-handling.patch +random-fixes0002-libdiskfs-fflush-stdout-when-pausing.patch +random-fixes0003-exec-convert-to-trivfs-dynamic-classes-and-buckets.patch +random-fixes0004-pfinet-convert-to-trivfs-dynamic-classes-and-buckets.patch +random-fixes0005-pflocal-convert-to-trivfs-dynamic-classes-and-bucket.patch +random-fixes0006-trans-crash-convert-to-trivfs-dynamic-classes-and-bu.patch +random-fixes0007-trans-passwd-convert-to-trivfs-dynamic-classes-and-b.patch +random-fixes0008-trans-proxy-defpager-convert-to-trivfs-dynamic-class.patch +random-fixes0009-libtrivfs-optimize-the-object-lookup-code.patch +random-fixes0010-fixup_exec.patch |