]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/mountpoint-util.c
Add fopen_unlocked() wrapper
[thirdparty/systemd.git] / src / basic / mountpoint-util.c
index 0a9f479e42a376733d8d545c7c1ec79ba7bb71fc..48494320fdb55123e5e9ffa1ba308d728ec82828 100644 (file)
@@ -98,7 +98,7 @@ static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *mnt_id
         if ((flags & AT_EMPTY_PATH) && isempty(filename))
                 xsprintf(path, "/proc/self/fdinfo/%i", fd);
         else {
-                subfd = openat(fd, filename, O_CLOEXEC|O_PATH);
+                subfd = openat(fd, filename, O_CLOEXEC|O_PATH|(flags & AT_SYMLINK_FOLLOW ? 0 : O_NOFOLLOW));
                 if (subfd < 0)
                         return -errno;
 
@@ -378,11 +378,9 @@ int dev_is_devtmpfs(void) {
         if (r < 0)
                 return r;
 
-        proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");
-        if (!proc_self_mountinfo)
-                return -errno;
-
-        (void) __fsetlocking(proc_self_mountinfo, FSETLOCKING_BYCALLER);
+        r = fopen_unlocked("/proc/self/mountinfo", "re", &proc_self_mountinfo);
+        if (r < 0)
+                return r;
 
         for (;;) {
                 _cleanup_free_ char *line = NULL;