linux 目录硬链接,linux为什么不能给目录做硬链接
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
issue comes up in language when you switch from single dispatch to multiple dispatch "self" no longer has any
meaning.
In a traditional UNIX filesystem, cycles are bad for two reasons: firstly, the reclamation of storage is based on
reference counting, which doesn't handle cyclic references! The only backreferences are the .. and . entries, and
these are handled as special cases.
Secondly, backreferences in the tree structure can lead to nasty multithreading problems. In the traditional kernel
design, like the BSD kernel, inodes that are in use are represented by in-memory structures called vnodes. These
nodes are accessed concurrently, and contain locks. Certain operations retain a lock on a directory while navigating
to the subdirectory. In a cycled graph, this can lead to two processes trying to acquire a pair of locks on the same
two objects, but in an opposite order, which will deadlock the processes. These locking operations are often done in
a way that cannot be interrupted by a signal, so the processes will stay deadlocked until a reboot.
There are special hacks in BSD to avoid this deadlock when navigating the .. reference. Basically, the lock on the
originating directory vnode is relinquished, the .. lock is acquired and then the originating directory is re-
locked. Yes, it's basically an open race. It's possible that the original directory is deleted by the time the lock
is re-acquired, for instance.
I once implemented a cycle detection algorithm for vnode locks, to try to support cyclic hard linking in a file
system for a version of BSD, but the problem was that although the code itself worked beautifully, it was just too
hard to make the rest of the kernel cooperate. Too many places in the kernel, in the higher layers above the
filesystem drivers, simply assume that a lock will succeed, or eventually succeed, and are consequently not prepared
to correctly deal with an EDEADLK error. It's not entirely clear, even, what to do with the information which tells
you that a deadlock would occur if you were allowed to proceed. Do you abort the whole system call? At what level do
you retry? How will applications respond to having random filesystem operations bail with deadlock errors.
And so that's about five paragraphs more than you ever wanted to know about hard links.
-- KazKylheku
linux 目录硬链接,linux为什么不能给目录做硬链接相关推荐
- Linux可以对目录进行硬链接,Linux硬链接与软链接原理及用法解析
在linux系统中有种文件是链接文件,可以为解决文件的共享使用.链接的方式可以分为两种,一种是硬链接(hard link),另一种是软链接或者也称为符号链接(symbolic link). 硬链接概念 ...
- linux不允许将硬链接指向目录,为什么 UNIX/Linux 不允许目录硬链 【翻译】
8种机械键盘轴体对比 本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选? 导语: 在学习Linux文件系统的硬链接和符号连接时,我也产生了这个疑问.搜索找到几篇中文资料,总感觉像是隔靴搔痒,似懂 ...
- Linux随笔2 - Linux的目录配置、文件元数据信息、符号链接与硬链接和常用文件和目录管理命令示例
目录 1. Linux的目录配置与FHS(Filesystem Hierarchy Standard) 1.1 根目录(/)的意义与内容 1.1.1 FHS要求根目录中必须存在的目录 1.1.2 FH ...
- linux目录硬链接,linux查看硬链接对应的所有文件
在linux中,链接文件分为硬链接和软链接文件两种,其中硬链接通过ln source_file dist_file建立,软链接通过ln -s source_file dist_file建立. 软硬链接 ...
- linux怎样创建硬链接,Linux下创建软、硬链接
在linux系统中,内核为每一个新创建的文件分配一个Inode(索引节点),每个文件都有唯一的inode号.文件属性保存在索引节点里,在访问文件时,索引节点被复制到内存,从而实现文件的快速访问. 链接 ...
- linux 软链接_面试 | Linux 下软链接和硬链接的区别
在 Linux 系统中,一切都是文件,然而为了区分不同类型的事物,我们有了: 普通文件 目录文件 链接文件 设备文件 在之前的文章<阿里面试题 | Nginx 所使用的 epoll 模型是什么? ...
- linux 软硬文件类型,linux文件属性和类型、系统链接文件、软链接和硬链接
文件属性和类型 [[email protected] ~]# ll -d wzh d rwxr-xr-x. 2 root root 6 Mar 26 06:27 wzh 目录 ,权限 硬链接数 属主 ...
- linux命令创建硬链接,Linux终端命令接口(十一)硬链接与软连接
一.进入终端 输入 使用 ls -l 即可. 示例: $ touch file1 # 创建新文件 file1 $ touch file2 # 创建新文件 file2 $ ln ...
- linux 软链接重新连接,Linux总结(十二)set_uid set_gid stic_bit 软链接 硬链接
一 set_uid 之前我们修改普通用户的登陆密码,都是以管理员身份在操作,比如我们在lv账户下,我们使用 sudo passwd lv 重置lv账户密码,此时我们直接拿到root权限忽略掉了文件权限 ...
- cp 硬连接 linux,软链接、硬链接和引用链接,以及如何实现文件快速拷贝(cp --reflink)...
Linux系统(包括Unix系统)有三种类型的链接文件:symlinks(符号链接.软连接),hardlinks(硬链接),reflinks(引用链接),其中软链接和硬链接比较常见. 首先来查看一个普 ...
最新文章
- 中国工程院《全球工程前沿2020》报告在京发布
- 0510JS基础:定义、输出、变量
- 皮一皮:狗子的眼神很绝望...
- 语音信号处理MATLAB实现
- 多stream_基础之Lambda和Stream的邂逅
- java 内存泄露监控,Linux下实用的JAVA内存泄露监控命令
- VC6.0多线程例程
- 动态绘制柱状图饼状图
- php动态柱形图,php生成柱状图(统计图)程序
- 关于直播,所有的技术细节都在这里了(一)
- 怎么用html打开图片,viewerjs 在html打开图片或打开pdf文件使用案例
- js运算符优先级速查表
- 模仿京东分类页面的布局
- U大师安装系统后,Chrome主页被7654导航劫持解决方法
- 产品管理 OKR:最佳实践和示例
- 0014 UVA1589 象棋 Xiangqi
- 会充电的CANoe又双叒叕来了:PLC数据采集、分析、仿真
- 邓紫棋歌曲计算机音乐数字,邓紫棋播放量最高的十首歌曲
- 第五章:MySQL主从复制
- SpringBoot HATEOAS用法简介(入门)