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>
8 static int devinfo_show(struct seq_file
*f
, void *v
)
10 int i
= *(loff_t
*) v
;
12 if (i
< CHRDEV_MAJOR_MAX
) {
14 seq_puts(f
, "Character devices:\n");
19 i
-= CHRDEV_MAJOR_MAX
;
21 seq_puts(f
, "\nBlock devices:\n");
28 static void *devinfo_start(struct seq_file
*f
, loff_t
*pos
)
30 if (*pos
< (BLKDEV_MAJOR_MAX
+ CHRDEV_MAJOR_MAX
))
35 static void *devinfo_next(struct seq_file
*f
, void *v
, loff_t
*pos
)
38 if (*pos
>= (BLKDEV_MAJOR_MAX
+ CHRDEV_MAJOR_MAX
))
43 static void devinfo_stop(struct seq_file
*f
, void *v
)
48 static const struct seq_operations devinfo_ops
= {
49 .start
= devinfo_start
,
55 static int __init
proc_devices_init(void)
57 proc_create_seq("devices", 0, NULL
, &devinfo_ops
);
60 fs_initcall(proc_devices_init
);