Questions tagged [procfs]

The proc filesystem is a virtual filesystem through which kernels of Unix-like operating systems, including Linux, expose process and kernel information. It is commonly mounted at /proc and implements a view of the system process table inside the file system. It provides a two-level view of process space.

Procfs, also known as the proc filesystem, is a virtual filesystem normally mounted at /proc. The details vary between unix variants, but on most, /proc/PID is a file or a directory that exposes information about the running process whose id is PID.

In addition, /proc can expose information about other aspects on the system. Linux, in particular, exposes information about mounted filesystems, network status, connected devices and more. This use is partly phased out in favor of the newer .

234 questions
2
votes
1 answer

How to access kernel parameters in kernel space

This is one of my lab assignments: I have to create an proc entry here: /proc/sys/kernel/ and I have to write a system call to manipulate a user space variable for different values of the proc entry I just added. For eg: say, user space variable is…
Sara.0
  • 167
  • 3
  • 15
2
votes
3 answers

What makes a pthread defunct?

i'm working with a multi-threaded program (using pthreads) that currently create a background thread (PTHREAD_DETACHED) and then invokes pthread_exit(0). My problem is that the process is then listed as "defunct" and curiously do not seems to…
PypeBros
  • 2,607
  • 24
  • 37
1
vote
1 answer

copy_from_user warning on size not being provably correct?

I encountered a warning produced when compiling my kernel module that I can't get to work around. First take a look at this simplified code: #define READ_CHUNK 100u static int _procfs_write(struct file *file, const char *buf, unsigned long count,…
Shahbaz
  • 46,337
  • 19
  • 116
  • 182
1
vote
2 answers

Idle time of a process in Linux

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…
Kornel Szymkiewicz
  • 582
  • 1
  • 6
  • 12
1
vote
1 answer

Why sysfs and procfs aren't displayed by df on Linux?

When I type df -Th I only get this : $ df -Th Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 987M 2.1M 984M 1% /run /dev/sda3 ext4 59G 34G 23G 60% / tmpfs tmpfs 4.9G 0 4.9G 0%…
Autechre
  • 171
  • 7
1
vote
2 answers

Linux procfs inode number changed whill process was running

I'm working on security software(SW) for Linux. One thing that our SW does on is that when some process is started, the SW stat()s the process's /proc/ entry and remembers the entry's inode number. When later on the SW needs to ascertain that the…
abirvalg
  • 128
  • 1
  • 7
1
vote
0 answers

/proc/interrupts not showing all irqs

I am working on a program that fetches all irqs in /proc/irq and does some parsing. I've realized however that there are a bunch of irq numbers in /proc/irq that are not listed in /proc/interrupts. For example, on my system, /proc/irq includes…
DrinkaZ
  • 79
  • 1
  • 4
1
vote
0 answers

Linux kernel module reference counter is always zero

I am implementing a kernel module that exposes some data to userspase using mmap interface. I create a file in /proc file system passing struct file_operations with pointers to needed functions: static struct file_operations module_file_ops = { …
Anton
  • 65
  • 6
1
vote
1 answer

How does OCI/runc system path constraining work to prevent remounting such paths?

The background of my question is a set of test cases for my Linux-kernel Namespaces discovery Go package lxkns where I create a new child user namespace as well as a new child PID namespace inside a test container. I then need to remount /proc,…
TheDiveO
  • 2,183
  • 2
  • 19
  • 38
1
vote
0 answers

What permission check happened in kernel when accessing files in /proc/sys?

I am interested in /proc/sys and trying to understand the access control mechanism of files in this directory. I am not sure if accessing /proc/sys is the same as accessing on-disk file systems, like ext4. So I just started with the open system…
JJ Meng
  • 11
  • 2
1
vote
1 answer

How is /proc//cmdline related to the argv variable of a process?

When I run a process and the content of argv[0], this also changes the content of /proc//cmdline. Now I checked in the kernel code in fs/proc/cmdline.c, and the cmdline_proc_show function there seems to get its content from the global…
pottea
  • 13
  • 3
1
vote
1 answer

Unable to create directories in /proc from a custom kernel module

In the /proc directory a custom module should create two directories lkm and mem to get a hierarchy like /proc/lkm/mem. A simple refactoring now broke what was working without obvious reason. After the refactoring the module is not creating the…
1
vote
1 answer

Best approach to get all recursive child processes of a PID from either the `/proc` filesystem or equivalent kernel API?

Let's say, I have chrome running, which has 100 different processeses, not all of which are direct children. What's the best way to programmatically get all of the processes from either the procfs or the any syscall may be (I believe getrusage only…
x70766c
  • 143
  • 7
1
vote
1 answer

How procfs outputs /proc/iomem?

I have looked into similar questions on this site (listed at the end) but still feel like missing a couple points, hopefully someone can help here: Is there a hook into the proc file system that connects the /proc/iomem inode to a function that…
QnA
  • 1,035
  • 10
  • 25
1
vote
2 answers

PCI device driver exporting information to /proc file system

I was asked this question in an interview. You are writing a PCI driver and you want to export the hardware-related information to the /proc filesystem. The interesting thing is that I searched the driver code and I couldn't find any call related to…
liv2hak
  • 14,472
  • 53
  • 157
  • 270