[Box Backup] OS X xattr backups
Martin Ebourne
boxbackup@fluffy.co.uk
Fri, 20 Jun 2008 00:12:45 +0100
On Thu, 2008-06-19 at 14:26 -0400, Eric Cronin wrote:
> On Jun 19, 2008, at 12:30 PM, Chris Wilson wrote:
>
> >
> > Yes, that's right. I'm glad it works for you. I'm still not sure
> > that 10k
> > is a reasonable buffer size though, or exactly what to do if it's
> > not big
> > enough. The API for (l)listxattr sucks. :-(
>
>
> Does the buffer size need to be static? The OS X implementation at
> least has the ability to return the size needed:
>
> If namebuf is set to NULL, the function returns the size of the
> list of
> extended attribute names. This facility can be used to
> determine the
> size of a buffer sufficiently large to hold the names of the
> attributes
> currently associated with path.
>
> Since you dynamically allocate the string already, setting
> listBufferSize with a pre-call to listxattr() seems simple enough.
The code is written to automatically resize the buffers (as it would be,
I've led a life-long campaign against fixed size buffers :)). Looks like
for OSX you need to pass NULL to get the size though. The code has been
fixed since I wrote it for the lgetxattr call below, just needs the same
fix for the listxattr call.
Cheers,
Martin.