summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-05-21 18:17:33 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-09-10 23:30:09 +0200
commit11e33e1e9f8ddbc6d35a97893caf908bc9df1e86 (patch)
tree13e0c5445f1171d5ff06f38aa7c8ff764eec474a
parent176ec926aec9642768615d5875171c24fb10e6b7 (diff)
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.
-rw-r--r--libdiskfs/diskfs.h8
-rw-r--r--libdiskfs/init-init.c41
2 files changed, 44 insertions, 5 deletions
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 11fb0ad1..c2f97adf 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -591,6 +591,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);
+
/* Libdiskfs contains a node cache.
diff --git a/libdiskfs/init-init.c b/libdiskfs/init-init.c
index 357960b8..07714f00 100644
--- a/libdiskfs/init-init.c
+++ b/libdiskfs/init-init.c
@@ -24,6 +24,7 @@
#include <hurd/fsys.h>
#include <stdio.h>
#include <maptime.h>
+#include <inttypes.h>
/* For safe inlining of diskfs_node_disknode and
diskfs_disknode_node. */
@@ -52,6 +53,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 references;
+
+ refcounts_references (&protid->po->np->refcounts, &references);
+
+ 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,
+ references.hard,
+ references.weak,
+ protid->po->path);
+
+ return 0;
+}
+
/* Call this after arguments have been parsed to initialize the
library. */
error_t
@@ -87,13 +111,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_label_class (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);