Re: Re: Dar and OS X xattrs: Willing to help

Dave Vasilevsky <[email protected]> Sat, 24 Sep 2005 23:14:52 -0400
Newsgroups gmane.comp.sysutils.backup.dar.general
Message-ID <[email protected]>
On Sep 24, 2005, at 3:09 PM, Denis Corbin wrote:

> This is no more true. The current development version does no more
> consider two namespaces, even better, it does no more consider any
> namespaces at all. The EA are just, from dar point of view, a pair of
> name and value,

That's great, it makes life much easier. I modified the version of  
dar in CVS so it supports the OS X-style *xattr calls, patch is at  
http://vasi.webhop.org/files/ports/dar-osx.patch

> This API does not covers the problem of the forks that do not exist
> under Unix, does it?

Yes it does! Apple does some magic so you can read the resource fork  
from the xattr "com.apple.ResourceFork". So if we save (and restore)  
the EAs, we automatically respect the resource fork.

> To my point of view to cover the EA feature on MacOS X the xattr  
> API is
> the best way to have something working. Probably it should now work
> without any change with the last development versions... If not it is
> still possible to adapt the code, which is now very general and not  
> much
> linux specific.

OS X uses a slightly different *xattr API from Linux. The only  
differences:

- The functions getxattr and setxattr take a 'position' argument, to  
make it easier for programs which want just part of a resource fork.  
For the purposes of dar, this should always be zero.

- There are no l* functions to not follow symlinks, like lgetxattr.  
Instead, each function takes an 'options' mask as an argument, and  
you can pass XATTR_NOFOLLOW as an option.

I modified the version of dar in CVS so it supports the OS X-style  
*xattr calls, in addition to the Linux-style. Patch is at http:// 
vasi.webhop.org/files/ports/dar-osx.patch . I've verified that this  
works, including saving and restoring resource forks.


This still leaves the problem of ACLs, since the xattr API on OS X  
doesn't make visible the xattr(s) that store ACLs.

We could do acl_get_file() and then acl_to_text() to get a text  
representation of the ACL for each file. Then it could be stored in  
the slice as a fake xattr, under a key like  
"fr.free.linux.dar.macosx.acl". Restoration would be just the reverse  
of saving, using acl_set_file() and acl_from_text(). The 'xar'  
archiver just uses the acl_to_text method I described above.

We could attempt instead to translate Linux and Mac OS X ACLs, I'm  
not sure how easy or hard that would be. I talked to some of the  
folks in #opendarwin, apparently they don't really translate too  
directly.

Dave
PGP.sig (application/pgp-signature, 186 B) - not displayed