什么是Unix命令创建一个硬连接到OS X目录? [英] What is the Unix command to create a hardlink to a directory in OS X?
问题描述
如何创建一个硬连接(而不是一个符号或Mac OS化名)在OS X中指向的目录?我已经知道命令LN目标位置,但只有当目标是一个文件工作。我知道的Mac OS,不像其他的Unix环境下,确实让hardlinking文件夹(这是用于时间机器,例如),但我不知道该怎么做我自己。
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.
推荐答案
您不能直接在bash做的话。不过......我在这里找到了一篇文章,讨论如何做到这一点间接:<一href=\"http://www.mactech.com/articles/mactech/Vol.23/23.11/ExploringLeopardwithDTrace/index.html\">http://www.mactech.com/articles/mactech/Vol.23/23.11/ExploringLeopardwithDTrace/index.html通过编写一个简单的小的C程序:
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:
#include <unistd.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
if (argc != 3) return 1;
int ret = link(argv[1], argv[2]);
if (ret != 0) perror("link");
return ret;
}
...在Terminal.app与构建:
...and build in Terminal.app with:
$ gcc -o hlink hlink.c -Wall
这篇关于什么是Unix命令创建一个硬连接到OS X目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!