procfs

How to create proc entry under /proc/driver?

隐身守侯 提交于 2019-12-04 06:13:36
I want to create a file under a /proc/driver directory. I would like to use a macro like proc_root_driver (or something else provided) rather than use "driver/MODULE_NAME" explicitly. I use create_proc_entry : struct proc_dir_entry *simpleproc_fops_entry; simpleproc_fops_entry = create_proc_entry(MODULE_NAME, 0400, NULL /* proc_root_dir */); After googling, I found suggestion to use proc_root_driver , but when I use it, I get the error proc_root_driver undeclared in this function And also, proc_root_driver is not available in linux/proc_fs.h. I have tried to declare structure like this: struct

Idle time of a process in Linux

这一生的挚爱 提交于 2019-12-04 05:12:11
问题 I need to calculate CPU usage (user mode, system mode, idle time) of a process in Linux. I am able to calculate usage in user and system mode using utime and stime values from /proc/PID/stat , but I found nothing which is related to idle time. I know I can get idle time from /proc/stat but this value is related to machine, not for particular process. Is it possible to calculate idle time of a process knowing its PID (reading data from /proc directory)? 回答1: I don't know much about it but

Linux c++: apis vs /proc files?

非 Y 不嫁゛ 提交于 2019-12-03 11:53:27
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 sort of info in Win32. Seems strange. It is best practice by far to stick with an API in the following

Entries in /proc/meminfo

浪子不回头ぞ 提交于 2019-12-03 03:14:01
问题 I can make sense of most of the information contained in /proc/meminfo like total memory, buffers, cache etc. Could you tell me what do the less obvious ones like the ones listed below mean? AnonPages Mapped Slab NFS_Unstable Bounce VmallocTotal VmallocUsed VmallocChunk If anyone is wondering, I am talking about the output of the linux command cat /proc/meminfo 回答1: The canonical source of this information is /usr/src/linux/Documentation/filesystems/proc.txt. Specifically, AnonPages: Non-file

psinfo_t solaris does not contain full process name in its field

[亡魂溺海] 提交于 2019-12-02 11:54:33
问题 Not getting full process name in psinfo_t struct's field pr_fname while reading process info from psinfo data file(/proc/%d/psinfo) into struct psinfo_t from procfs.h in solaris. Full psinfo_t struct definition is present on below site: http://docs.oracle.com/cd/E19253-01/816-5174/6mbb98ui2/index.html Only if the process name is less than equal to 15 characters then I am getting the full process name other wise if process name is more than 15 characters then I am getting only first 15

Idle time of a process in Linux

放肆的年华 提交于 2019-12-02 03:54:20
I need to calculate CPU usage (user mode, system mode, idle time) of a process in Linux. I am able to calculate usage in user and system mode using utime and stime values from /proc/PID/stat , but I found nothing which is related to idle time. I know I can get idle time from /proc/stat but this value is related to machine, not for particular process. Is it possible to calculate idle time of a process knowing its PID (reading data from /proc directory)? I don't know much about it but maybe the following works: 1) Get the process start up time. Im sure thats possible 2) Generate time difference

Is there anything like /proc for windows [closed]

浪尽此生 提交于 2019-12-01 17:22:55
I'm Curious about 2 things, What is the closest equivalent to /proc that ships with windows Are there any products which add a proc like filesystem to windows? Task manager Cygwin , giving Windows a Linux environment, certainly allows a Windows program to use /proc . Grim It would help if you explained what your final goal is. What are you trying to do? For managing processes on windows you have the following options: Windows ships with Task Manager (taskmgr.exe) A better more versatile alternative is a tool called Process Explorer You also have the command line utility called tasklist.exe

Is there anything like /proc for windows [closed]

不羁岁月 提交于 2019-12-01 16:22:46
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 months ago . I'm Curious about 2 things, What is the closest equivalent to /proc that ships with windows Are there any products which add a proc like filesystem to windows? 回答1: Task manager Cygwin, giving Windows a Linux environment, certainly allows a Windows program to use /proc . 回答2: It would help if you explained what

Knowing the process status using procf/<pid>/status

五迷三道 提交于 2019-12-01 10:10:03
问题 I am working on Solaris. I know that if there is a process running, there is a file called /proc/<PID>/status , where <PID> is the process id, and it contains a field called state . As an example, I used my shell process: > ps PID TTY TIME CMD 18671 0:01 tcsh whose process id is 18671. I had written a simple C program for extracting that information: #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/procfs

How to parse large amount of data passed to kernel module through /proc file?

浪尽此生 提交于 2019-12-01 03:14:45
Edit: I have found seq_file that eases writing a lot of data from kernel to user-space. What I am looking for is the opposite; an API that facilitates reading a lot of data (more than one page) from user-space. Edit 2 : I am implementing a port of <stdio.h> as a kernel module that would be able to open /proc (and later, other virtual file systems) similar to FILE s and handle input and output similar to <stdio.h> . You can find the project here . I have found a LOT of questions on how the kernel can write large amounts of data to /proc (for user-space programs to take), but nothing for the