summaryrefslogtreecommitdiff
path: root/debian/patches/0025-libdiskfs-annotate-objects-managed-by-libports.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/0025-libdiskfs-annotate-objects-managed-by-libports.patch')
-rw-r--r--debian/patches/0025-libdiskfs-annotate-objects-managed-by-libports.patch107
1 files changed, 107 insertions, 0 deletions
diff --git a/debian/patches/0025-libdiskfs-annotate-objects-managed-by-libports.patch b/debian/patches/0025-libdiskfs-annotate-objects-managed-by-libports.patch
new file mode 100644
index 00000000..7bc5edd6
--- /dev/null
+++ b/debian/patches/0025-libdiskfs-annotate-objects-managed-by-libports.patch
@@ -0,0 +1,107 @@
+From a2e4f7f47159eb668f16e76e0856aa81b09656e3 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Wed, 21 May 2014 18:17:33 +0200
+Subject: [PATCH 25/27] libdiskfs: annotate objects managed by libports
+
+Label all port classes and diskfs_port_bucket. Provide
+diskfs_format_debug_info which prints a human-readable description of
+a protid object, which notably includes the path and the inode number.
+
+* libdiskfs/diskfs.h (diskfs_format_debug_info): New declaration.
+* libdiskfs/init-init.c (diskfs_format_debug_info): New function.
+(diskfs_init_diskfs): Add annotations to classes and bucket.
+---
+ libdiskfs/diskfs.h | 8 ++++++++
+ libdiskfs/init-init.c | 41 ++++++++++++++++++++++++++++++++++++-----
+ 2 files changed, 44 insertions(+), 5 deletions(-)
+
+diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
+index e10e75e..bb12b4a 100644
+--- a/libdiskfs/diskfs.h
++++ b/libdiskfs/diskfs.h
+@@ -585,6 +585,14 @@ error_t (*diskfs_read_symlink_hook)(struct node *np, char *target);
+ default function always returns EOPNOTSUPP. */
+ error_t diskfs_get_source (struct protid *cred,
+ char *source, size_t source_len);
++
++/* The user may define this function. The function must provide a
++ human-readable description of PROTID in BUFFER of size SIZE. The
++ default implementation generates a reasonable amount of
++ information. */
++error_t diskfs_format_debug_info (const void *protid,
++ char *buffer, size_t size);
++
+
+ /* The library exports the following functions for general use */
+
+diff --git a/libdiskfs/init-init.c b/libdiskfs/init-init.c
+index 976b4e8..c7c1af7 100644
+--- a/libdiskfs/init-init.c
++++ b/libdiskfs/init-init.c
+@@ -24,6 +24,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ #include <hurd/fsys.h>
+ #include <stdio.h>
+ #include <maptime.h>
++#include <inttypes.h>
+
+ mach_port_t diskfs_default_pager;
+ mach_port_t diskfs_auth_server_port;
+@@ -48,6 +49,29 @@ struct port_class *diskfs_shutdown_notification_class;
+
+ struct port_bucket *diskfs_port_bucket;
+
++/* Provide a human-readable description of the given protid object. */
++error_t
++diskfs_format_debug_info (const void *port, char *buffer, size_t size)
++{
++ const struct protid *protid = port;
++ const struct port_info *pi = port;
++ struct references result;
++
++ refcounts_references (&protid->po->np->refcounts, &result);
++
++ snprintf (buffer, size,
++ "bucket: %s, class: %s"
++ ", node{inode: %"PRIu64", hard: %u, weak: %u}, path: %s",
++ pi->bucket->label,
++ pi->class->label,
++ protid->po->np->cache_id,
++ result.hard,
++ result.weak,
++ protid->po->path);
++
++ return 0;
++}
++
+ /* Call this after arguments have been parsed to initialize the
+ library. */
+ error_t
+@@ -83,13 +107,20 @@ diskfs_init_diskfs (void)
+
+ diskfs_auth_server_port = getauth ();
+
+- diskfs_protid_class = ports_create_class (diskfs_protid_rele, 0);
+- diskfs_control_class = ports_create_class (_diskfs_control_clean, 0);
+- diskfs_initboot_class = ports_create_class (0, 0);
+- diskfs_execboot_class = ports_create_class (0, 0);
+- diskfs_shutdown_notification_class = ports_create_class (0, 0);
++#define MAKE_CLASS(NAME, FN, ARG, DBG) \
++ NAME = ports_create_class ((FN), (ARG)); \
++ ports_set_debug_info (NAME, #NAME, (DBG))
++
++ MAKE_CLASS (diskfs_protid_class, diskfs_protid_rele, NULL,
++ diskfs_format_debug_info);
++ MAKE_CLASS (diskfs_control_class, _diskfs_control_clean, NULL, NULL);
++ MAKE_CLASS (diskfs_initboot_class, NULL, NULL, NULL);
++ MAKE_CLASS (diskfs_execboot_class, NULL, NULL, NULL);
++ MAKE_CLASS (diskfs_shutdown_notification_class, NULL, NULL, NULL);
++#undef MAKE_CLASS
+
+ diskfs_port_bucket = ports_create_bucket ();
++ ports_label_bucket (diskfs_port_bucket, "diskfs_port_bucket");
+
+ _hurd_port_init (&_diskfs_exec_portcell, MACH_PORT_NULL);
+
+--
+2.0.0.rc2
+