Copy the Mac com.apple.ResourceFork extended attribute, causing the list of arguments to be too long.

I am trying to copy extended attributes from one file to another using the OSX utility "xattr". The background is that we are creating a backup tool, and the files / structure should preserve all attributes, ACLs, etc. Everything works fine except for large attributes such as resource forks. Small attributes work fine using the method below. Trying this on OS X 10.7.5 Here is what I am doing:

First, I identify the attributes in the file with "ls -l @". The result is below:

-rwxrwxrwx@ 1 testuser staff 0 3 Jan 2011 File com.apple.FinderInfo 32 com.apple.ResourceFork 237246 

Now I export the attribute (com.apple.ResourceFork is the one that causes the problems):

 xattr -px com.apple.ResourceFork File > attribfile 

Now I want to apply this attribute to a copy of the file on another mac with this command:

 xattr -wx com.apple.ResourceFork "`cat attribfile`" File 

This leads to:

 -bash: /usr/bin/xattr: Argument list too long 

I think I know why this happens ... the fork resource data is too long to fit into the argument. I have not set a threshold at which it starts to break, but I suspect that this is due to ARG_MAX. xargs does not help here, since it is not a few smaller arguments, but one very large one.

So many questions:

  • Is there a way to get xattr to accept this big deal? How to connect it through a standard input? The man page does not show it, but I am not an expert and there may be some creative way to do this.
  • Can someone tell me the correct way to apply a large extended attribute using command line tools using command line tools?
  • If there are no command line tools, any recommendations for third-party tools?
+4
source share
2 answers

I don't know how to do this with xattr , but there is an old file system trick that you can use. Note: this is mostly deprecated, but still works in 10.8.2; I do not do promises around 10.8.3 etc. If the file attribute is in hexadecimal format, use this:

 xxd -r -p attribfile >File/..namedfork/rsrc 

If the attribute file is raw, use cat instead of xxd -r -p . If an attribute is something other than a fork resource ... I have no idea.

+3
source

The accepted answer did not work for me, so I continued and found another solution that I am posting here if other people need it.

My problem was copying vlc-2.1.4 to the / Applications folder. He continued to say:

 The Finder can't complete the operation because some data in "VLC" can't be read or written. (Error code -36) 

And if I tried to use cp in the terminal, I got the error indicated in this thread.

So, I did to execute the following commands in the console (to summarize I tar VLC and deploy it to the destination, so ... it works like cp ):

 cd /Volumes/vlc-2.1.4/ tar cf /Applications/vlc.tar VLC.app cd /Applications/ tar xf vlc.tar rm vlc.tar 

I hope this will be useful to others with the same problem.

+1
source

Source: https://habr.com/ru/post/1448007/


All Articles