How do you create a hardlink (as opposed to a symlink or a Mac OS alias) in OS X that points to a directory? I already know the command "ln target destination" but that only works when the target is a file. I know that Mac OS, unlike other Unix environments, does allow hardlinking to folders (this is used for Time Machine, for example) but I don't know how to do it myself.
相关问题
- JQ: Select when attribute value exists in a bash a
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
- Why should we check WIFEXITED after wait in order
- Advice for supporting both Mac and Windows Desktop
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- Check if directory exists on remote machine with s
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- ImportError: No module named twisted.persisted.sty
- How can I vertically align my status bar item text
My case was that I found out that from a windows virtual machine, I cannot follow symlinks. (i wanted to test some HTML pages in Internet Explorer). And my directory structure had symlinks for CSS and images folders.
My workaround to solve the problem was a different approach than the other answers implied. I used
rsync
to create a copy of the folder. Rsync can resolve the symlinks and copy the linked files in stead.This solved my problem without using hard links to directories. And it's actually an easy solution if you're just working on a small set of files.
Piffle. On 10.5, it tells you in the man page for ln:
So yes:
Give it your password, and you're not done yet. You didn't document it, did you? You must document hard linked directories; even if it's a single user machine.
Deleting is a different story: if you go about it the usual way to delete directories, you'll delete the contents. So you must "unlink" the directory:
There. Hope you don't wreck your filesystem!
The short answer is you can't. :) (except possibly as root, when it would be more accurate to say you shouldn't.)
Unixes only allow a set number of links to directories - ".." from within all its children and "." from within itself. Anything else is potentially a recipe for a very confused directory tree. This is/was apparently a design decision by Ken Thompson.
(Having said that, apparently Apple's Time Machine does do this :) )
In Linux you can use bind mount to simulate hard linking directories. Not sure about OSX
You can't do it directly in BASH then. However... I found an article here that discusses how to do it indirectly: http://www.mactech.com/articles/mactech/Vol.23/23.11/ExploringLeopardwithDTrace/index.html by compiling a simple little C program:
...and build in Terminal.app with:
Another solution is to use bindfs https://code.google.com/p/bindfs/ which is installable via port: