]> git.ipfire.org Git - thirdparty/systemd.git/commit
stat-util: make proc_mounted() not update errno
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Jan 2026 09:41:11 +0000 (18:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Jan 2026 13:37:04 +0000 (22:37 +0900)
commite6a25c2fc7556b97406367bd1c9516ea621e1c07
tree4e7b2cf6573e390ed49bfd1556540612898ba373
parente41d7de091ea3380407d117ae7252d8cb1523b74
stat-util: make proc_mounted() not update errno

Typically, proc_mounted() is used in error handling. Hence, it is better
to make it not update the original errno.

Currently, there are two places that returns wrong error code:
- pidref_get_capability() in src/basic/capability-util.c
```c
        _cleanup_fclose_ FILE *f = fopen(path, "re");
        if (!f) {
                if (errno == ENOENT && proc_mounted() == 0)
                        return -ENOSYS;

                return -errno;
        }
```
- fdset_new_fill() in src/shared/fdset.c
```c
        d = opendir("/proc/self/fd");
        if (!d) {
                if (errno == ENOENT && proc_mounted() == 0)
                        return -ENOSYS;

                return -errno;
        }
```

Rather than fixing them, let's make proc_mounted() not update errno,
otherwise we may make a similar failure in a future.
src/basic/stat-util.c