{"id":12,"date":"2005-10-11T20:30:19","date_gmt":"2005-10-11T10:30:19","guid":{"rendered":"http:\/\/www.allocinit.net\/blog\/?p=12"},"modified":"2005-10-11T20:36:46","modified_gmt":"2005-10-11T10:36:46","slug":"extended-attributes-and-tigers-rsync","status":"publish","type":"post","link":"https:\/\/www.allocinit.net\/blog\/2005\/10\/11\/extended-attributes-and-tigers-rsync\/","title":{"rendered":"Extended Attributes and Tiger&#8217;s Rsync"},"content":{"rendered":"<p>It&#8217;s been a while, but never fear I&#8217;ve got a nice shiny new bug for you today.<\/p>\n<p>Rsync can in some cases not handle the <tt>-E<\/tt> and <tt>-&#8205;-delete<\/tt> functions very well when combined together. Because Apple chose to implement resource forks in rsync using their you-beaut-gee-whiz <tt>._<\/tt> files, when the resource fork doesn&#8217;t exist for the file, or indeed the file doesn&#8217;t exist at all in the source directory rsync happily attempts to unlink the corresponding <tt>._<\/tt> file. On an HFS+ volume, clearly this is going to fail, as it doesn&#8217;t exist (incidentally on a UFS, Xsan, FAT, etc volume, it&#8217;d work just fine, but rsync is still broken).<\/p>\n<h3>A Patch<\/h3>\n<p>Due to my extreme generosity, or alternatively in an attempt to get away from some software with a name that rhymes with <i>typo<\/i>, I&#8217;ve whipped up a quick fix to this problem. It may not be the best way to fix it, but it works, and it even removes the resource fork from a file if the resource fork should be deleted, but not the file itself. How&#8217;s that for slick?<\/p>\n<p>(Yeah, pasting it into a website isn&#8217;t all that slick, but I&#8217;m too lazy to upload it as a file right now, so tough luck. And WordPress seems to have stuck \\ characters before the quote characters. They shouldn&#8217;t be there.)<\/p>\n<pre>--- rsync-2.6.3\/syscall.c\t2005-10-11 14:44:42.000000000 +1000\r\n+++ rsync-2.6.3\/syscall.c\t2005-10-11 15:47:06.000000000 +1000\r\n@@ -53,6 +53,31 @@\r\n {\r\n \tif (dry_run) return 0;\r\n \tRETURN_ERROR_IF_RO_OR_LO;\r\n+#ifdef EA_SUPPORT\r\n+\tif (extended_attributes\r\n+\t\t&& !strncmp(basename(fname), \"._\", 2)) {\r\n+\t\tint retval;\r\n+\t\tretval = unlink(fname);\r\n+\t\tif (retval == -1 && errno == ENOENT) {\r\n+\t\t\tchar ftemp[MAXPATHLEN+17];\r\n+\t\t\tif (snprintf(ftemp, MAXPATHLEN+17, \"%s\/%s\/..namedfork\/rsrc\", \r\n+\t\t\t\t\tdirname(fname), basename(fname)+2) >= MAXPATHLEN+17)\r\n+\t\t\t{\r\n+\t\t\t\terrno = ENOENT;\r\n+\t\t\t\treturn -1;\r\n+\t\t\t}\r\n+\t\t\tfprintf(stderr, \"%s\", ftemp);\r\n+\t\t\tretval = truncate(ftemp, 0);\r\n+\t\t\tif (retval == -1 && errno == ENOENT) {\r\n+\t\t\t\treturn 0;\r\n+\t\t\t} else {\r\n+\t\t\t\treturn retval;\r\n+\t\t\t}\r\n+\t\t} else {\r\n+\t\t\treturn retval;\r\n+\t\t}\r\n+\t}\r\n+#endif\r\n \treturn unlink(fname);\r\n }\r\n <\/pre>\n<p>For reference the bug is Radar <a href=\"rdar:\/\/problem\/4295233\">4295233<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s been a while, but never fear I&#8217;ve got a nice shiny new bug for you today. Rsync can in some cases not handle the -E and -&#8205;-delete functions very well when combined together. Because Apple chose to implement resource forks in rsync using their you-beaut-gee-whiz ._ files, when the resource fork doesn&#8217;t exist for [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.allocinit.net\/blog\/wp-json\/wp\/v2\/posts\/12"}],"collection":[{"href":"https:\/\/www.allocinit.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.allocinit.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.allocinit.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.allocinit.net\/blog\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":0,"href":"https:\/\/www.allocinit.net\/blog\/wp-json\/wp\/v2\/posts\/12\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.allocinit.net\/blog\/wp-json\/wp\/v2\/media?parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.allocinit.net\/blog\/wp-json\/wp\/v2\/categories?post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.allocinit.net\/blog\/wp-json\/wp\/v2\/tags?post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}