0

The following two files are virtual files:

/dev/sda1
/proc/cpuinfo

I know that /dev/sda1 is a device file (that points to a device driver), so when I access this file, I am actually accessing the device driver.

But what about /proc/cpuinfo, is this file also a device file? If it is, are all other virtual files in Linux device files?

Kusalananda
  • 333,661

2 Answers2

6

All the files in /proc are provided by the proc file system, which is described thus in its manpage:

The proc filesystem is a pseudo-filesystem which provides an interface to kernel data structures.

This is a special file system provided by the kernel to provide access to the data it stores, e.g. about the CPU (cpuinfo), about processes (in the numeric directories in /proc, corresponding to each process identifier)... The files inside it aren’t device files, they are effectively endpoints for function calls into the kernel to retrieve information from it.

Other special file systems include devtmpfs and sysfs.

So no, all “virtual” files aren’t device files. Arguably, device files aren’t virtual at all, since device nodes exist as real files; the way they act is not the same as what most people think of as files, but they are files nevertheless.

These questions might help you understand all this better:

Stephen Kitt
  • 434,908
3

No. /proc on Linux is a pseudo-filesystem which provides an interface to kernel data structures. There are no character or block special files in it in the same sense as the files under /dev (you can't use the /proc files for mounting a filesystem or talk to a modem or tape drive etc).

This filesystem is fully explained by the proc(5) manual on your system (man 5 proc).

Kusalananda
  • 333,661