diff options
author | Mike Yuan <me@yhndnzj.com> | 2024-04-20 21:02:38 +0200 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2024-05-21 18:48:51 +0200 |
commit | 88873231c87411f7513428cb4237e4877249c4bf (patch) | |
tree | 5fa2737757b305d831145ed2dede4985c336ffa0 /src/basic/mountpoint-util.c | |
parent | Merge pull request #32957 from mrc0mmand/fix-coverage-builds (diff) | |
download | systemd-88873231c87411f7513428cb4237e4877249c4bf.tar.xz systemd-88873231c87411f7513428cb4237e4877249c4bf.zip |
mountpoint-util: add missing assertions, make mount_fd static
Diffstat (limited to 'src/basic/mountpoint-util.c')
-rw-r--r-- | src/basic/mountpoint-util.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 66fa35b630..03e56f6cab 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -596,11 +596,14 @@ int dev_is_devtmpfs(void) { return false; } -int mount_fd(const char *source, - int target_fd, - const char *filesystemtype, - unsigned long mountflags, - const void *data) { +static int mount_fd( + const char *source, + int target_fd, + const char *filesystemtype, + unsigned long mountflags, + const void *data) { + + assert(target_fd >= 0); if (mount(source, FORMAT_PROC_FD_PATH(target_fd), filesystemtype, mountflags, data) < 0) { if (errno != ENOENT) @@ -626,6 +629,8 @@ int mount_nofollow( _cleanup_close_ int fd = -EBADF; + assert(target); + /* In almost all cases we want to manipulate the mount table without following symlinks, hence * mount_nofollow() is usually the way to go. The only exceptions are environments where /proc/ is * not available yet, since we need /proc/self/fd/ for this logic to work. i.e. during the early |