在Mac OS X中创建目录硬链接 [英] Creating directory hard links in Mac OS X
本文介绍了在Mac OS X中创建目录硬链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Mac OS X中创建指向目录的硬链接?
此功能已添加到其文件系统中的 Mac OS X X10.5 (豹)(用于时间机器),但是我无法从命令行中找到有关实际使用它的任何信息.
This feature has been added to their file system in Mac OS X v10.5 (Leopard) (for time machine), but I could not find any information on actually using it from the command line.
推荐答案
不幸的是,Apple削弱了ln
命令.您可以使用以下程序创建指向目录的硬链接:
Unfortunately Apple has crippled the ln
command. You can use the following program to create a hard link to a directory:
#include <unistd.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
if (argc != 3) {
fprintf(stderr,"Use: hlink <src_dir> <target_dir>\n");
return 1;
}
int ret = link(argv[1],argv[2]);
if (ret != 0)
perror("link");
return ret;
}
请注意,硬链接目录可能不在同一父目录中,因此您可以执行以下操作:
Take into account that the hard linked directories may not be in the same parent directory, so you can do this:
$ gcc hlink.c -o hlink
$ mkdir child1
$ mkdir parent
$ ./hlink child1 parent/clone2
这篇关于在Mac OS X中创建目录硬链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文