Procfs in Linux (Virtual File System) EmbeTronicX
Procfs in Linux (Virtual File System) EmbeTronicX
Linux
SSSP
PPO OON
NNSSSO
O
ORR
REEED
D
DBB
BYYY D
D
DIIISSSN
N
NEEEYYYLLLA
A
ANN
NDD
D
Learn More
RRREEESSSO
O
ORR
RTTT
Table of Contents
1. Introduction
2. Procfs in Linux
2.1. Introduction
3. Creating procfs directory
4. Creating Procfs Entry
5. Procfs File System
6. Open and Release Function
7. Write Function
8. Read Function
9. Remove Proc Entry
10. Procfs in Linux – Complete Driver Source
Code
11. MakeFile
12. Building and Testing Driver
Introduction
IOCTL
Procfs
Sysfs
Configfs
Debugfs
Sysctl
UDP Sockets
Netlink Sockets
Procfs in Linux
Introduction
so important.
system information.
___
See More
Ad By Sponsor
cat /proc/meminfo
kernel.
cat /proc/modules
/proc/interrupts — registered
/proc/partitions — currently
partitions
filesystem drivers
SSSP
PPO OON
NNSSSO
O
ORR
REEED
D
DBB
BYYY D
D
DIIISSSN
N
NEEEYYYLLLA
A
ANN
NDD
D
Learn More
RRREEESSSO
O
ORR
RTTT
kernel space.
→
Creating procfs directory
Table of Contents
struct proc_dir_entry
proc_dir_entry *parent)
where,
NULL.
in version 3.10.
Where,
defined as below,
1. proc_create("etx_proc",0666,NULL,&pr
A better trading
experience - Start
with $20 USD only
oqtimalp.com/F…
init function.
entry.
create_proc_read_entry()
create_proc_entry()
file linux/proc_fs.h.
entries.
SSSP
PPO OON
NNSSSO
O
ORR
REEED
D
DBB
BYYY D
D
DIIISSSN
N
NEEEYYYLLLA
A
ANN
NDD
D
Learn More
RRREEESSSO
O
ORR
RTTT
Write Function
an array “etx_array”.
Read Function
See More
Ad By Sponsor
Example:
1. remove_proc_entry("etx_proc",NULL);
proc_dir_entry *parent).
source code.
Note:
LINUX_KERNEL_VERSION.
Example:
Your Linux
LINUX_KERNEL_VERSION
Kernel version
v3.10 310
v5.6 506
v5.10 510
1. /***********************************
2. * \file driver.c
3. *
4. * \details Simple Linux device d
5. *
6. * \author EmbeTronicX
7. *
8. * \Tested with Linux raspberrypi 5.
9. *
10. * **********************************
11. #include <linux/kernel.h>
12. #include <linux/init.h>
13. #include <linux/module.h>
14. #include <linux/kdev_t.h>
15. #include <linux/fs.h>
16. #include <linux/cdev.h>
17. #include <linux/device.h>
18. #include<linux/slab.h>
19. #include<linux/uaccess.h>
20. #include <linux/ioctl.h>
21. #include<linux/proc_fs.h>
22. #include <linux/err.h>
23.
24. /*
25. ** I am using the kernel 5.10.27-v7l
26. ** If you are using the kernel 3.10,
27. ** and for kernel 5.1, set this as 5
28. ** changed in kernel above v5.5.
29. **
30. */
31. #define LINUX_KERNEL_VERSION 510
32.
33. #define WR_VALUE _IOW('a','a',int32_
34. #define RD_VALUE _IOR('a','b',int32_
35.
36. int32_t value = 0;
37. char etx_array[20]="try_proc_array\n
38. static int len = 1;
39.
40.
41. dev_t dev = 0;
42. static struct class *dev_class;
43. static struct cdev etx_cdev;
44. static struct proc_dir_entry *parent
45.
46. /*
47. ** Function Prototypes
48. */
49. static int __init etx_driver_in
50. static void __exit etx_driver_ex
51.
52. /*************** Driver Functions **
53. static int etx_open(struct inod
54. static int etx_release(struct i
55. static ssize_t etx_read(struct file
56. static ssize_t etx_write(struct fil
57. static long etx_ioctl(struct fil
58.
59. /***************** Procfs Functions
60. static int open_proc(struct ino
61. static int release_proc(struct
62. static ssize_t read_proc(struct fil
63. static ssize_t write_proc(struct fi
64.
65. /* The 2024 Niro EV
Available government
66. ** File operation
incentives of $5,000. sturcture
67. */
68. static struct file_operations fops =
69. {
70. .owner = THIS_MODUL
71. .read = etx_read,
Build and Price