MacFUSE and sshfs on Snow Leopard 8 Comments
While in the process of working on the WordPress plugin mentioned in my last post, I found myself having to do a edit/save/upload cycle annoyingly often, as this WordPress install doesn’t run on my local machine and I didn’t feel like dealing with getting httpd up and running here again. More than once I caught myself trying to figure out why my changes weren’t having an effect until I realized I was forgetting the upload step. And entering a passphrase for scp every time I hit Save is tedious at best. But this blog is hosted on DreamHost, and TextMate doesn’t have SFTP support, so I couldn’t just mount a network drive in the Finder.
But I’d heard of this magical, wonderful thing called sshfs that would let me mount an sftp server as a volume on my machine. That would solve a lot of problems! At first I did the obvious: I went to Terminal and entered sudo port install macfuse sshfs. It didn’t work. Small wonder; the last version of MacFUSE in MacPorts is 2.0.3, which is a considerable distance behind the most recent release, 2.1.5). So I used the MacFUSE prefpane to update to 2.1.5, but then the sshfs install wanted nothing to do with me because it was built against the older version. I went to download a prebuilt binary, since that was just easier, but there wasn’t one for Snow Leopard. I tried to build sshfs from source, but the prefpane hadn’t installed sufficient libraries to do that with. So I went to build MacFUSE itself from source.
Oops. MacFUSE is another of those accursed abandoned projects and doesn’t build out of the box on Snow Leopard. I found the base MacPorts distribution wouldn’t build until I modified all the Xcode project files it uses to build only i386 and x86_64 – by default they build those and ppc and ppc64. The ppc build was okay, more or less, but the Snow Leopard toolchain has no ppc64 support and cried for its mother. I also had to rip -arch ppc out of the buildtool. Then I had to modify core/10.5/fusefs/common/fuse_param.h not to define an interim usage that didn’t compile. After that, it built.
Once I had MacFUSE itself built, I had to tackle sshfs. First step, grab the patch for the Mac version and apply it. I was surprised to find that it applied 100% cleanly. The very next step, ../macfuse/core/macfuse_buildtool.sh -t swconfigure failed with “the C compiler can not create executables”. Turned out the problem with that was the buildtool not specifying -mmacosx-version-min=10.5 for a non-10.4 build, since it was written without Snow Leopard in mind, and specifying -isysroot /Developer/SDKs/MacOSX10.5.sdk without the version specifier also is just asking for trouble. I hacked the flag in and sshfs built without further complaint.
And it worked fine after that. I was quite impressed by the performance; the delay for a Save command to complete is perceptible, but it’s less than a second. It might be because I researched the options available and used them, such things as -o auto_cache,idmap=user,noappledouble,noapplexattr,volname=...,uid=...,gid=..., or it might be because it was just that well written, but whatever the reason, it saved me a lot of time and aggravation. Very nice stuff. I hope MacFUSE doesn’t stay abandoned; it’s definitely a useful technology.
Here is the quick list of commands to make MacFUSE and sshfs build on 10.6. Keep in mind that most of this is kinda hackish, and doing it “properly” would involve setting it up to build a 10.6 target instead of hacking up the 10.5 target.
################### #### IMPORTANT #### # These steps assume you have a universal build of glib2 and its dependencies available in your PATH # The easiest way to do this is to have MacPorts installed and run $ port install glib2 +universal ################### svn co http://macfuse.googlecode.com/svn/trunk macfuse && cd macfuse open core/10.5/fusefs/fusefs.xcodeproj core/sdk-objc/MacFUSE.xcodeproj # modify every target in both Xcode projects to bulid i386 x86_64 - to my knowledge this has to be done by hand patch -p0 <<'PATCH' Index: core/macfuse_buildtool.sh =================================================================== --- core/macfuse_buildtool.sh (revision 1686) +++ core/macfuse_buildtool.sh (working copy) @@ -5,7 +5,7 @@ # Repurposes code from several earlier scripts by Ted Bonkenburg. # -PATH=/Developer/usr/sbin:/Developer/usr/bin:/Developer/Tools:/Developer/Applications:/sbin:/usr/sbin:/bin:/usr/bin +PATH=/Developer/usr/sbin:/Developer/usr/bin:/Developer/Tools:/Developer/Applications:/opt/local/bin:/opt/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin export PATH @@ -1387,11 +1387,12 @@ extra_cflags="-mmacosx-version-min=10.4" architectures="-arch i386 -arch ppc" else - architectures="-arch i386 -arch ppc" + extra_cflags="-mmacosx-version-min=10.5" + architectures="-arch i386 -arch x86_64" fi local common_cflags="-O0 -g $architectures -isysroot $m_usdk_dir -I/usr/local/include" - local common_ldflags="-Wl,-syslibroot,$m_usdk_dir $architectures -L/usr/local/lib" + local common_ldflags="-mmacosx-version-min=10.5 -Wl,-syslibroot,$m_usdk_dir $architectures -L/usr/local/lib -framework CoreFoundation" local final_cflags="$common_cflags $extra_cflags" local final_ldflags="$common_ldflags" Index: core/10.5/fusefs/common/fuse_param.h =================================================================== --- core/10.5/fusefs/common/fuse_param.h (revision 1686) +++ core/10.5/fusefs/common/fuse_param.h (working copy) @@ -21,7 +21,7 @@ #define M_MACFUSE_ENABLE_KQUEUE 1 #define M_MACFUSE_ENABLE_KUNC 0 #if __LP64__ - #define M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK 1 + #define M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK 0 #endif /* __LP64__ */ #endif /* M_MACFUSE_ENABLE_UNSUPPORTED */ PATCH core/macfuse_buildtool.sh -t smalldist installer -pkg /tmp/macfuse-core-10.5-2.1.7/MacFUSE\ Core.pkg -target / cd .. wget http://downloads.sourceforge.net/project/fuse/sshfs-fuse/2.2/sshfs-fuse-2.2.tar.gz?use_mirror=cdnetworks-us-2 tar xzf sshfs-fuse-2.2.tar.gz && rm sshfs-fuse-2.2.tar.gz && cd sshfs-fuse-2.2 patch -p1 < ../macfuse/filesystems/sshfs/sshfs-fuse-2.2-macosx.patch ../macfuse/core/macfuse_buildtool.sh -t swconfigure make make install
January 28, 2010 at 11:20 pm
March 29, 2010 at 10:24 amKarl
link
I think:
open core/10.5/fusefs.xcodeproj core/sdk-objc/MacFUSE.xcodeproj
should be:
open core/10.5/fusefs/fusefs.xcodeproj core/sdk-objc/MacFUSE.xcodeproj
May 3, 2010 at 3:28 pmGwynne Raskind
link | my site | author
Fixed, thanks!
May 22, 2010 at 4:49 pmArmin Soyka
link | my site
I’m really new to all this stuff. So I figured out how to install Xcode and glib2 and I was able to open the two xcodeproj (http://www.arminsoyka.at/asmac/xcodeproj1.png & http://www.arminsoyka.at/asmac/xcodeproj2.png) but I don’t understand what to do next.
What do you mean by “modify every target in both Xcode projects to bulid i386 x86_64 – to my knowledge this has to be done by hand” I couldnt find anything that had to do with i386 or x86_64. I really want to use macfuse so it would be awesome if you could help me out with a little bit more concrete tipps for a newbie. i386 and x86_64 has to do with the kind of kernel my mac is using right?
thanks.
June 12, 2010 at 5:24 pmJF Bohemier
link
Hello, Thanks for these instructions. I’m also stuck at the “modify every target in both Xcode projects to bulid i386 x86_64 – to my knowledge this has to be done by hand” step. Could you post more details on how to do this?
Thanks!
June 12, 2010 at 6:45 pmGwynne Raskind
link | my site | author
Assuming a basic knowledge of Xcode: Open the Xcode projects in Xcode (naturally). For each target in the project, open the target settings. At the top of the Settings tab, make sure the Configuration is set to All, then edit the Architectures and Valid Architectures settings to read “i386 x86_64″. Then close the projects and continue. This could probably have been done with an AppleScript, in retrospect; at some point I’ll probably update the build script I posted to do so.
June 14, 2010 at 9:50 amJF Bohemier
link
Thanks Gwynne, that worked perfectly. I had to install wget through macports (sudo port install wget). Coming from the Linux world, now I feel more at home with sshfs ;)