[vlc-commits] [Git][videolan/vlc][master] access: file: properly report local files on Darwin

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Jul 26 18:47:13 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
132ef662 by Marvin Scholz at 2022-07-26T18:34:14+00:00
access: file: properly report local files on Darwin

While Darwin implements fstatvfs, the statvfs structures f_flag
field is only defined to contain two flags, ST_RDONLY and ST_NOSUID.
So the check for MNT_LOCAL would always be false, reporting all files
as non-local.

To mitigate that, on Darwin we can just use fstatfs and check
statfs.f_flags for MNT_LOCAL.

- - - - -


1 changed file:

- modules/access/file.c


Changes:

=====================================
modules/access/file.c
=====================================
@@ -75,7 +75,19 @@ typedef struct
 #if !defined (_WIN32) && !defined (__OS2__)
 static bool IsRemote (int fd)
 {
-#if defined (HAVE_FSTATVFS) && defined (MNT_LOCAL)
+#if defined(__APPLE__)
+    /* This has to preceed the general fstatvfs implmentation below,
+     * as even though Darwin has fstatvfs, it does not expose the
+     * MNT_LOCAL in the statvfs.f_flag field.
+     */
+    struct statfs sfs;
+
+    if (fstatfs (fd, &sfs))
+        return false;
+
+    return !((sfs.f_flags & MNT_LOCAL) == MNT_LOCAL);
+
+#elif defined (HAVE_FSTATVFS) && defined (MNT_LOCAL)
     struct statvfs stf;
 
     if (fstatvfs (fd, &stf))



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/132ef662489942d81cf1d974690cf6f10589ce7f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/132ef662489942d81cf1d974690cf6f10589ce7f
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list