]> git.proxmox.com Git - mirror_zfs.git/blobdiff - lib/libzpool/kernel.c
Fixes for procfs files backed by linked lists
[mirror_zfs.git] / lib / libzpool / kernel.c
index 341548ac300a1077cd809e3003f79bfecbc809e5..5baf52514a7b58e232da66f709ee5b8c82a86679 100644 (file)
@@ -424,6 +424,57 @@ cv_broadcast(kcondvar_t *cv)
        VERIFY0(pthread_cond_broadcast(cv));
 }
 
+/*
+ * =========================================================================
+ * procfs list
+ * =========================================================================
+ */
+
+void
+seq_printf(struct seq_file *m, const char *fmt, ...)
+{}
+
+void
+procfs_list_install(const char *module,
+    const char *name,
+    procfs_list_t *procfs_list,
+    int (*show)(struct seq_file *f, void *p),
+    int (*show_header)(struct seq_file *f),
+    int (*clear)(procfs_list_t *procfs_list),
+    size_t procfs_list_node_off)
+{
+       mutex_init(&procfs_list->pl_lock, NULL, MUTEX_DEFAULT, NULL);
+       list_create(&procfs_list->pl_list,
+           procfs_list_node_off + sizeof (procfs_list_node_t),
+           procfs_list_node_off + offsetof(procfs_list_node_t, pln_link));
+       procfs_list->pl_next_id = 1;
+       procfs_list->pl_node_offset = procfs_list_node_off;
+}
+
+void
+procfs_list_uninstall(procfs_list_t *procfs_list)
+{}
+
+void
+procfs_list_destroy(procfs_list_t *procfs_list)
+{
+       ASSERT(list_is_empty(&procfs_list->pl_list));
+       list_destroy(&procfs_list->pl_list);
+       mutex_destroy(&procfs_list->pl_lock);
+}
+
+#define        NODE_ID(procfs_list, obj) \
+               (((procfs_list_node_t *)(((char *)obj) + \
+               (procfs_list)->pl_node_offset))->pln_id)
+
+void
+procfs_list_add(procfs_list_t *procfs_list, void *p)
+{
+       ASSERT(MUTEX_HELD(&procfs_list->pl_lock));
+       NODE_ID(procfs_list, p) = procfs_list->pl_next_id++;
+       list_insert_tail(&procfs_list->pl_list, p);
+}
+
 /*
  * =========================================================================
  * vnode operations