Repository: borgbackup/borg

Issue:
OS X: borg mount files are not accessible by finder
Mounting the borg repo works fine but the actual files stored inside are not accessible. In the mac os x finder (file browser) they all have a size of 0 Byte. Trying to copy one file outside the fuse volume results in a `Error -36`.

```
$ borg --version
borg 1.0.4.dev273+ngbf5406d
$ borg mount --foreground ~/Desktop/borg-repo ~/Desktop/BorgBackup
```

---

The bounty is for finding the root cause of this issue and showing a way to fix it.
A PR with a fix would be welcome (if major work, bounty could be increased / new bounty filed for the code).

:moneybag: [there is a bounty for this](https://www.bountysource.com/issues/34843144-os-x-borg-mount-files-are-not-accessible-by-finder)



Discussion:
Some minutes ago I tried `borg mount` on OS X with osxfuse 3.2.0 and it worked. File sizes correct, files readable. I didn't use the GUI / finder, but ssh and a shell, in case that matters.

So, did they do incompatible changes? Or introduce a regression?

This must be related to the `Finder`. I did browse into the mounted repo with a terminal and the files are accessible there.  

Maybe there should be a ticket about this in the osxfuse tracker - can you file one there?

I've just opened a ticket at https://github.com/osxfuse/osxfuse/issues/288

> I think this is something the Borg team needs to investigate. The loopback reference file system works fine with osxfuse 3.3.2. Finder acting up can mean that the root user does not have access to the volume.

[Quote](https://github.com/osxfuse/osxfuse/issues/288#issuecomment-223642008)

@tristan-k can you try whether 3.2.0 works with finder?

@ThomasWaldmann No it did not. Tried that before upgrading to latest version.

OK, if no borg + osxfuse version works with finder (but with shell), update issue topic and top text accordingly.

The hint about root user helped, i can reproduce on the shell:

```
(borg-env) This-MacBook-Pro:borg vagrant$ ls /vagrant/borg/mnt
borg
(borg-env) This-MacBook-Pro:borg vagrant$ sudo ls /vagrant/borg/mnt
ls: mnt: No such file or directory
```

Solved!:

```
(borg-env) This-MacBook-Pro:borg vagrant$ ./borg.exe mount repo::1 mnt -o allow_other
(borg-env) This-MacBook-Pro:borg vagrant$ ls /vagrant/borg/mnt
borg
(borg-env) This-MacBook-Pro:borg vagrant$ sudo ls /vagrant/borg/mnt
borg
```

Also possible: allow_root to just allow it for root, but nobody else.

Can you try this with finder?

Guess we should put a hint about this option into the docs.

Just did. Doesn't work in the finder.

@tristan-k are you in "admin" group (this is needed, otherwise "allow_other" is not allowed for you).

Q: What produces this? Default ACLs? Can't be unix permissions for sure. But even then, root should be able to override any DAC check.

Yes, I'am in the admin group.

What does error -36 (see top post) mean in that context?

Help wanted: we can only fix this, if we know the root cause (and how to fix it):

Why is finder not seeing files in the same was as `ls -l` on the shell?

@ThomasWaldmann I can give you remote access to my mac os x system if you like.

@tristan-k OK, let's meet on #borgbackup on chat.freenode.net?


Resolving patch:
diff --git a/borg/fuse.py b/borg/fuse.py
--- a/borg/fuse.py
+++ b/borg/fuse.py
@@ -194,7 +194,7 @@ def getxattr(self, inode, name, ctx=None):
         try:
             return item.get(b'xattrs', {})[name]
         except KeyError:
-            raise llfuse.FUSEError(errno.ENODATA) from None
+            raise llfuse.FUSEError(errno.ENOATTR) from None
 
     def _load_pending_archive(self, inode):
         # Check if this is an archive we need to load


Test patch: