0

I have been reading at several places that we should no longer refer to /proc/mounts and instead it is better to rely on /proc/self/mountinfo file. For example, see this question:

/proc/self/mountinfo per-mount-options vs per-super-options

However, I can't find any official documentation stating the same.

codego123
  • 3
  • 1

1 Answers1

2

Is /proc/mounts file depracated? ... I can't find any official documentation ...

According proc(5) — Linux manual page

/proc/mounts

Before Linux 2.4.19, this file was a list of all the filesystems currently mounted on the system. With the introduction of per-process mount namespaces in Linux 2.4.19 ... this file became a link to /proc/self/mounts, which lists the mounts of the process's own mount namespace. ...

See also

ll /proc/mounts
lrwxrwxrwx. 1 root root 11 Jul 18 14:45 /proc/mounts -> self/mounts
U880D
  • 1,017
  • 2
  • 12
  • 18
  • Thanks for sharing this. While it states that it is a link to /proc/self/mounts, it nowhere says that this is not a reliable method. So wondering if it is ok to use /proc/mounts? – codego123 Jul 18 '23 at 13:13
  • `/proc/mounts` is just a symlink now. Since it is pointing to properly defined target there is no need to use the "old" one other than for backward compatibility. And it might disappear in the future. Therefore, just use the final target from the beginning. – U880D Jul 18 '23 at 13:19
  • 1
    Thank you @U880D That answers my question :) So basically I can just use /proc/self/mounts or /proc/self/mountinfo instead of /proc/mounts. – codego123 Jul 18 '23 at 15:39