1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/init.h>
4 #include <linux/proc_fs.h>
5 #include <linux/seq_file.h>
6 #include <linux/blkdev.h>
9 static int devinfo_show(struct seq_file *f, void *v)
11 int i = *(loff_t *) v;
13 if (i < CHRDEV_MAJOR_MAX) {
15 seq_puts(f, "Character devices:\n");
20 i -= CHRDEV_MAJOR_MAX;
22 seq_puts(f, "\nBlock devices:\n");
29 static void *devinfo_start(struct seq_file *f, loff_t *pos)
31 if (*pos < (BLKDEV_MAJOR_MAX + CHRDEV_MAJOR_MAX))
36 static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos)
39 if (*pos >= (BLKDEV_MAJOR_MAX + CHRDEV_MAJOR_MAX))
44 static void devinfo_stop(struct seq_file *f, void *v)
49 static const struct seq_operations devinfo_ops = {
50 .start = devinfo_start,
56 static int __init proc_devices_init(void)
58 struct proc_dir_entry *pde;
60 pde = proc_create_seq("devices", 0, NULL, &devinfo_ops);
61 pde_make_permanent(pde);
64 fs_initcall(proc_devices_init);