code_junkie

What is the Bash command to create a hardlink to a directory in OS X?

Nov 10th, 2011
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <stdio.h>
  3. int
  4. main(int argc, char *argv[])
  5. {
  6. if (argc != 3)
  7. return 1;
  8. int ret = link(argv[1], argv[2]);
  9. if (ret != 0)
  10. perror("link");
  11. return ret;
  12. }
  13.  
  14. $ gcc -o hlink hlink.c -Wall
  15.  
  16. #include <stdio.h>
  17. int
  18. main(int argc, char *argv[])
  19. {
  20. if (argc != 2)
  21. return 1;
  22. int ret = unlink(argv[1]);
  23. if (ret != 0)
  24. perror("unlink");
  25. return ret;
  26. }
  27.  
  28. gcc -o hunlink hunlink.c
  29.  
  30. hlink source_folder target_folder
  31.  
  32. -d, -F, --directory
  33. allow the superuser to attempt to hard link directories (note:
  34. will probably fail due to system restrictions, even for the
  35. superuser)
  36.  
  37. sudo ln -d existing_dir new_hard_link
  38.  
  39. unlink new_hard_link
  40.  
  41. link: Operation not permitted
  42.  
  43. rsync -av --copy-dirlinks --delete ../htmlguide ~/src/
Add Comment
Please, Sign In to add comment