1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or https://opensource.org/licenses/CDDL-1.0. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 2018 by Delphix. All rights reserved. 24 */ 25 26 #ifndef _SPL_PROCFS_LIST_H 27 #define _SPL_PROCFS_LIST_H 28 29 #include <sys/kstat.h> 30 #include <sys/mutex.h> 31 #include <linux/proc_fs.h> 32 #include <linux/seq_file.h> 33 34 typedef struct procfs_list procfs_list_t; 35 struct procfs_list { 36 /* Accessed only by user of a procfs_list */ 37 void *pl_private; 38 39 /* 40 * Accessed both by user of a procfs_list and by procfs_list 41 * implementation 42 */ 43 kmutex_t pl_lock; 44 list_t pl_list; 45 46 /* Accessed only by procfs_list implementation */ 47 uint64_t pl_next_id; 48 int (*pl_show)(struct seq_file *f, void *p); 49 int (*pl_show_header)(struct seq_file *f); 50 int (*pl_clear)(procfs_list_t *procfs_list); 51 size_t pl_node_offset; 52 kstat_proc_entry_t pl_kstat_entry; 53 }; 54 55 typedef struct procfs_list_node { 56 list_node_t pln_link; 57 uint64_t pln_id; 58 } procfs_list_node_t; 59 60 void procfs_list_install(const char *module, 61 const char *submodule, 62 const char *name, 63 mode_t mode, 64 procfs_list_t *procfs_list, 65 int (*show)(struct seq_file *f, void *p), 66 int (*show_header)(struct seq_file *f), 67 int (*clear)(procfs_list_t *procfs_list), 68 size_t procfs_list_node_off); 69 void procfs_list_uninstall(procfs_list_t *procfs_list); 70 void procfs_list_destroy(procfs_list_t *procfs_list); 71 72 void procfs_list_add(procfs_list_t *procfs_list, void *p); 73 74 #endif /* _SPL_PROCFS_LIST_H */ 75