#453: Formaline deletes files if lib and src are symlinks ----------------------------+----------------------------------------------- Reporter: barry.wardell | Owner: Type: defect | Status: new Priority: major | Milestone: Component: Cactus | Version: Resolution: | Keywords: ----------------------------+-----------------------------------------------
Comment (by barry.wardell):
Replying to [comment:7 eschnett]:
Yes, that is the idea. The patch as stop-gap measure, and then trying to
understand the real cause of the problem and correcting git-add-thorn.pl.
OK, I have committed this patch anyway.
I do not think that Mac OS allows hard links to directories for regular
users. With these, one can create directory structures that are not trees, which would break many Unix expectations; in particular, one can create directory structures disconnected from the root directory and hence unreachable. Root can call the "link" syscall (maybe even from the "ln" command, possibly with a special option) to do this, but it's highly discouraged.
Nevertheless, this is the case:
$ stat -f %i dir1/dir2 7846166 $ stat -f %i dir4 7846166
Note that in contrast to my above test case, the following does not have the same problem:
mkdir dir1 touch dir1/file ln -s dir1 dir3 perl -e 'link dir3, dir4'
In this case, dir4 is not created. To me this seems like an OS/perl bug to me. Would the best think to do be to add an explicit check that the source is not a symlink or directory before it does the link command?
Replying to [comment:8 rhaas]:
find's -L option recurses into symbolic links and is required by POSIX.
One can turn it off again with the -H switch eg. for '-L ! -type d -H' or just put it at the beginning of the whole find line.
I was going to originally suggest this as alternative solution. The only reason I didn't was that with the patch as-is it only affects this particular case, whereas I was worried that adding -L could have some other unrelated effects (either good or bad).