procfs

Create ProcFS entry in /proc/net

☆樱花仙子☆ 提交于 2019-12-06 13:15:55
I try to create an entry inside /proc/net from a kernel module, like this: struct file *filp = filp_open("/proc/net", O_RDONLY, 0); struct proc_dir_entry *parent = PDE(filp->f_dentry->d_inode); filp_close(filp, NULL); proc_file = create_proc_entry("test", 0644, parent); Crudely taken from here Why does it create my entry like /proc/test instead of /proc/net/test ? (Note: I'd like too use create_proc_entry , not proc_create .) In recent kernels you won't find create_proc_entry() anymore, it's been removed completely. Take a look at https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git

Linux kernel /proc FIFO/pipe

女生的网名这么多〃 提交于 2019-12-06 11:24:47
问题 I'm currently trying to create a kernel module that will produce data based on kernel events and push them to a file. After reading that this is bad (and I agree), I decided it would make more sense to have the data in a /proc file that a user program could pull from when necessary. However, this idea led to all sorts of problems, particularly when and how to clear out this file. So I thought... "why don't I make a named pipe in /proc and read from that?" I've got the general gist of setting

Current value of process' environment variable

对着背影说爱祢 提交于 2019-12-06 06:45:45
问题 I was wondering if there is a way to set an environment variable from a bash process and read it from another. As environment variables' values are local to processes (besides the inheritance), one can't just do export FOO="bar" in a terminal and read it from another. I was then trying to get them through /proc/environ , but this is what I got: etuardu@subranu:~$ FOO="foo" bash etuardu@subranu:~$ strings /proc/$$/environ | grep FOO FOO=foo etuardu@subranu:~$ export FOO="bar" etuardu@subranu:~

How to read/write from/to a linux /proc file from kernel space?

北城余情 提交于 2019-12-06 03:43:12
问题 I am writing a program consisting of user program and a kernel module. The kernel module needs to gather data that it will then "send" to the user program. This has to be done via a /proc file. Now, I create the file, everything is fine, and spent ages reading the internet for answer and still cannot find one. How do you read/write a /proc file from the kernel space ? The write_proc and read_proc supplied to the procfile are used to read and write data from USER space, whereas I need the

dereferencing proc_dir_entry pointer causing compilation error on linux version 3.11 and above

对着背影说爱祢 提交于 2019-12-05 05:20:01
问题 I am trying to follow an example rootkit given here https://github.com/ivyl/rootkit I modified this example so that I can compile it on linux version 3.11. I found that latest linux versions stopped supporting few API's such as create_proc_entry, readdir has been replaced by iterate etc. On linux version is 3.11.0-23 I also observed that my include directories does not contain internal.h so as to have complete definition of proc_dir_entry. On lower versions on linux ( < 3.10 ) we are having

What is the maximum allowed limit on the length of a process name?

假装没事ソ 提交于 2019-12-05 03:29:25
What is the maximum length allowed for a process name? I am reading the process name from /proc/[pid]/stat file and i would like to know the maximum buffer that i would need. I am pretty sure there is a limit which is configurable but just can't find out where this is. According to man 2 prctl : PR_SET_NAME (since Linux 2.6.9) Set the name of the calling thread, using the value in the location pointed to by (char *) arg2. The name can be up to 16 bytes long , and should be null-terminated if it contains fewer bytes. So I'd go for a 16 bytes long buffer. EDIT: Let me back this up a little more.

What is alternative of create_proc_entry()

自作多情 提交于 2019-12-05 02:17:44
As create_proc_entry function is deprecated, what is its replacement? I was trying to create a simple proc entry using create_proc_entry but got the this error: error: implicit declaration of function ‘create_proc_entry’ I grepped create_proc_entry in proc_fs.h but didn't find it there. Is there something that I'm missing or there's alternative to do this? The newer functions are named proc_* . You can see their declarations in include/linux/proc_fs.h . In particular, proc_create creates a proc entry. You can check out the implementation of the other (quite useful) functions in the source file

Linux c++: apis vs /proc files?

时间秒杀一切 提交于 2019-12-04 18:15:02
问题 Im working on an app to collect and send various bits of system info (partition space/free, laptop battery info, etc). Im not having much success getting this information in the form of direct c++ api.. though its all available via files in /proc (or similar). So - I'm wondering whether reading/parsing these files in my c++ app is the appropriate way to get this info or should I keep trying to discover APIs? ( NOTE: I am working with statvfs ). So far it looks like it's easier to gather this

Linux kernel /proc FIFO/pipe

爱⌒轻易说出口 提交于 2019-12-04 17:45:28
I'm currently trying to create a kernel module that will produce data based on kernel events and push them to a file. After reading that this is bad (and I agree), I decided it would make more sense to have the data in a /proc file that a user program could pull from when necessary. However, this idea led to all sorts of problems, particularly when and how to clear out this file. So I thought... "why don't I make a named pipe in /proc and read from that?" I've got the general gist of setting a read function and a write function for a proc file, but I'm still having conceptual trouble with how

How to read/write from/to a linux /proc file from kernel space?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 07:26:55
I am writing a program consisting of user program and a kernel module. The kernel module needs to gather data that it will then "send" to the user program. This has to be done via a /proc file. Now, I create the file, everything is fine, and spent ages reading the internet for answer and still cannot find one. How do you read/write a /proc file from the kernel space ? The write_proc and read_proc supplied to the procfile are used to read and write data from USER space, whereas I need the module to be able to write the /proc file itself. That's not how it works. When a userspace program opens