static struct list_head chrdrvs;
static struct list_head blkdrvs;
+/*
+ * IPC table
+ */
+
+#define IPC_TABLE_SIZE 997
+struct ipc_table {
+ struct list_head tables[IPC_TABLE_SIZE];
+};
+
+static struct ipc_table ipc_table;
+
/*
* Column related stuffs
*/
}
}
+static void initialize_ipc_table(void)
+{
+ for (int i = 0; i < IPC_TABLE_SIZE; i++)
+ INIT_LIST_HEAD(ipc_table.tables + i);
+}
+
+static void free_ipc(struct ipc *ipc)
+{
+ if (ipc->class->free)
+ ipc->class->free(ipc);
+}
+
+static void finalize_ipc_table(void)
+{
+ for (int i = 0; i < IPC_TABLE_SIZE; i++)
+ list_free(ipc_table.tables, struct ipc, ipcs, free_ipc);
+}
+
+struct ipc *get_ipc(struct file *file)
+{
+ int slot;
+ struct list_head *e;
+ struct ipc_class *ipc_class;
+
+ if (!file->class->get_ipc_class)
+ return NULL;
+
+ ipc_class = file->class->get_ipc_class(file);
+ if (!ipc_class)
+ return NULL;
+
+ slot = ipc_class->get_hash(file) % IPC_TABLE_SIZE;
+ list_for_each (e, &ipc_table.tables[slot]) {
+ struct ipc *ipc = list_entry(e, struct ipc, ipcs);
+ if (ipc->class != ipc_class)
+ continue;
+ if (ipc_class->is_suitable_ipc(ipc, file))
+ return ipc;
+ }
+ return NULL;
+}
+
+void add_ipc(struct ipc *ipc, unsigned int hash)
+{
+ int slot = hash % IPC_TABLE_SIZE;
+ list_add(&ipc->ipcs, &ipc_table.tables[slot]);
+}
+
static void fill_column(struct proc *proc,
struct file *file,
struct libscols_line *ln,
initialize_nodevs();
initialize_classes();
initialize_devdrvs();
+ initialize_ipc_table();
collect_processes(&ctl, pids, n_pids);
free(pids);
/* cleanup */
delete(&ctl.procs, &ctl);
+ finalize_ipc_table();
finalize_devdrvs();
finalize_classes();
finalize_nodevs();
int (*handle_fdinfo)(struct file *file, const char *key, const char* value);
void (*initialize_content)(struct file *file);
void (*free_content)(struct file *file);
+ struct ipc_class *(*get_ipc_class)(struct file *file);
};
extern const struct file_class file_class, cdev_class, bdev_class, sock_class, unkn_class, fifo_class;
+/*
+ * IPC
+ */
+struct ipc {
+ const struct ipc_class *class;
+ struct list_head endpoints;
+ struct list_head ipcs;
+};
+
+struct ipc_endpoint {
+ struct ipc *ipc;
+ struct list_head endpoints;
+};
+
+struct ipc_class {
+ unsigned int (*get_hash)(struct file *file);
+ bool (*is_suitable_ipc)(struct ipc *ipc, struct file *file);
+ void (*free)(struct ipc *ipc);
+};
+
+struct ipc *get_ipc(struct file *file);
+void add_ipc(struct ipc *ipc, unsigned int hash);
+
/*
* Name managing
*/