facebookincubator / xar

executable archive format
Other
1.57k stars 55 forks source link

Add support for macfuse as the backend on macOS. #46

Closed rb2k closed 3 years ago

rb2k commented 3 years ago

This PR does two things:

  1. Switch the CMAKE_CXX_STANDARD to 17 so this can be compiled in macOS
  2. Add support for macfuse (the successor to osxfuse)

CMAKE_CXX_STANDARD

The recent macOS SDKs require this, otherwise the compile fails with something like this:

mseeger@mseeger-mbp build % make xarexec_fuse
[ 20%] Building CXX object CMakeFiles/XarHelperLib.dir/xar/XarHelpers.cpp.o
In file included from /Users/mseeger/workspace/xar/xar/XarHelpers.cpp:7:
/Users/mseeger/workspace/xar/xar/XarHelpers.h:155:6: error: no template named 'optional' in namespace 'std'
std::optional<ino_t> read_sysfs_cgroup_inode(const char *filename);
~~~~~^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:14:6: error: no template named 'optional' in namespace 'std'
std::optional<std::string> read_file_prefix(const char *filename,
~~~~~^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:18:17: error: no member named 'nullopt' in namespace 'std'
    return std::nullopt;
           ~~~~~^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:25:17: error: no member named 'nullopt' in namespace 'std'
    return std::nullopt;
           ~~~~~^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:30:17: error: no member named 'nullopt' in namespace 'std'
    return std::nullopt;
           ~~~~~^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:33:10: error: no viable conversion from returned value of type 'std::string' (aka 'basic_string<char, char_traits<char>, allocator<char> >') to function return type 'int'
  return buf;
         ^~~
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:875:5: note: candidate function
    operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); }
    ^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:93:6: error: no template named 'optional' in namespace 'std'
std::optional<ino_t> read_sysfs_cgroup_inode(const char *filename) {
~~~~~^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:96:17: error: no member named 'nullopt' in namespace 'std'
    return std::nullopt;
           ~~~~~^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:100:17: error: no member named 'nullopt' in namespace 'std'
    return std::nullopt;
           ~~~~~^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:107:17: error: no member named 'nullopt' in namespace 'std'
    return std::nullopt;
           ~~~~~^
/Users/mseeger/workspace/xar/xar/XarHelpers.cpp:125:15: error: no member named 'nullopt' in namespace 'std'
  return std::nullopt;
         ~~~~~^
11 errors generated.
make[3]: *** [CMakeFiles/XarHelperLib.dir/xar/XarHelpers.cpp.o] Error 1
make[2]: *** [CMakeFiles/XarHelperLib.dir/all] Error 2
make[1]: *** [CMakeFiles/xarexec_fuse.dir/rule] Error 2
make: *** [xarexec_fuse] Error 2

Macfuse

As you can see on https://osxfuse.github.io/, osxfuse is now macfuse.

The mount looks like this:

squashfuse_ll@macfuse0 on /System/Volumes/Data/mnt/xarfuse/uid-0/1d33f049 (macfuse, synchronous)

Adding 'macfuse' as a valid filesystem type fixes the 'wait forever for it to mount' issue that macfuse otherwise causes

Testing

I scp'ed the resulting binary to an existing host that had macfuse installed and confirmed that it did indeed correctly mount + execute a xar file (as opposed to just hang + getting a timeout)

facebook-github-bot commented 3 years ago

@rb2k has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot commented 3 years ago

@rb2k merged this pull request in facebookincubator/xar@7c6703f73edb18f50b821f5a47a83477ddddaf8d.