1 Kernel Data Structures Review

1.每个进程都有一个process table,索引是文件描述符,指向filetable
2.file table中有对文件状态的描述,比如offset
3.v-node(是虚拟文件,一切皆文件) i-node(实际的物理装置信息)

2 Hard Links

  1. v-nodes are the file system enteries
  2. i-nodes represent the underlying storage mechanisms for that data within that file.
  3. hard-link
    1. there are two virtual v-nodes that reference the same i-node

    2. the file exists in multiple places within the file system, and can have different names. But, whenever you open that file, it is the same underlying data that is accessed.

2.1 Creating Links with ln

1)创建文件f,此时links是1

#> touch f
#> ls -l
-rw-r--r--  1 aviv  staff  0 Mar 23 12:51 f# 解释links--.                  .--file size\                /
-rw-r--r--  1 aviv  staff  0 Mar 23 12:51 f
\________/    \_________/    \__________/  \_|             |              |          |
permissions    user/group       mod time     file name

2)创建硬链接

#> ln f hl   #Create a hard link to f named hl
#> ls -l
total 0
-rw-r--r--  2 aviv  staff  0 Mar 23 12:51 f
-rw-r--r--  2 aviv  staff  0 Mar 23 12:51 hl

2.2 Hard Links and Directories

1..有两个连接:1).本身 2)具体的路径
2...有三个连接:两个来自于.,还有一个来自..本身

#> ls -lia
34996362 drwxr-x--- 2 aviv scs 4096 Mar 23 18:14 .
34996236 drwxr-x--- 3 aviv scs 4096 Mar 23 18:14 ..
34996364 -rw-r----- 2 aviv scs    0 Mar 23 18:14 f
34996364 -rw-r----- 2 aviv scs    0 Mar 23 18:14 hl

2.3 Un-linking is the same as removal

1.un-linked hl is that we removed it, and that is exactly what remove does
2. In other terms, the unlink command removes an entry from the file system by removing a link.

#> ls -li
total 0
34996364 -rw-r----- 2 aviv scs 0 Mar 23 18:14 f
34996364 -rw-r----- 2 aviv scs 0 Mar 23 18:14 hl
#> unlink hl
#>ls -l
total 0
-rw-r----- 1 aviv scs 0 Mar 23 18:14 f

2.4 Hard-linking across file systems

3 Symbolic Links

  1. Symbolic Links

    1. Symbolic Linking is when one file links to another file, which refernces the underlying file block.

    2. 类似于win的shortcut

3.1 Creating Symbolic Links

#> ln -s f sl
#> ls -l
-rw-r----- 1 aviv scs 0 Mar 23 18:14 f
lrwxrwxrwx 1 aviv scs 1 Mar 23 18:44 sl -> f

3.2 Dangling Links

#> rm f
rm: remove regular empty file `f'? y
#> ls -l
lrwxrwxrwx 1 aviv scs 1 Mar 23 18:44 sl -> f
#> cat sl
cat: sl: No such file or directory

3.3 Symbolic Links across Files Systems

22 File Links: Hard and Symbolic相关推荐

  1. Linux - 硬链接(Hard Links)和符号链接(Symbolic Links)

    硬链接(Hard Links)和符号链接(Symbolic Links) 本文地址: http://blog.csdn.net/caroline_wendy/article/details/21593 ...

  2. CMake中file的使用

    CMake中的file命令用于文件操作,其文件格式如下:此命令专用于需要访问文件系统的文件和路径操作 Readingfile(READ <filename> <variable> ...

  3. Java IO流-File类

    2017-10-24 23:50:22 File类 File类:文件和目录路径名的抽象表示形式.该文件或者目录不一定真实存在. * 构造方法 File类有四种构造方法,主要采用的构造方法师第二种,也就 ...

  4. 【IO面试题】打印目录树形结构,并输出到file.txt中

    1 package com.peter.solution; 2 3 import java.io.File; 4 import java.io.FileWriter; 5 import java.io ...

  5. 西电李航 操作系统课程笔记 day8 Implementation of File system

    文章目录 File system Implementation 文件系统(file system) 布局 普通文件(file) 分配(allocation) 连续存储 指针存储 追踪(tracking ...

  6. fd与FILE结构体

    文件描述符 每个进程都有一个指针*file,指向表file_struct,该表中最重要的部分是fd_array[]的一个指针数组,每个元素都是一个指向打开文件的指针.文件描述符就是该数组的下标.系统对 ...

  7. 初识50个Linux命令

    1. [命令]:cat [功能说明]: concatenate files and print on the standard output #连接文件并打印到标准输出,有标准输出的都可以用重定向定向 ...

  8. python文件路径操作及pathlib库

    对文件的路径操作是一个非常基础的问题,但也是一个至关重要的问题,优雅的路径操作不仅可以让代码可读性更高:还可以让用户避免很多不必要的麻烦.python中路径操作常用的几种方式重要包括:字符串拼接.os ...

  9. linux(四) -- 常用基本命令

    Shell 可以看作是一个命令解释器,为我们提供了交互式的文本控制台界面.我们可以 通过终端控制台来输入命令,由 shell 进行解释并最终交给内核执行. 部分基础命令: history:常看历史命令 ...

最新文章

  1. ADAS方案设计成功关键:图像处理技术
  2. 一条SQL语句查询数据库中的所有表、存储过程、触发器
  3. innobackupex远程备份脚本
  4. 设计模式学习笔记——装饰(Decorator)模式
  5. Eclipse添加注释的快捷键alt+shift+j,在菜单中是source-gt;generate element comment
  6. 让 Cloud Native 飞,Pick 干货,看这里、看这里!
  7. 这几年养成的几个比较好的工作习惯
  8. centos 7 之nginx
  9. 【贪心】hdu5969 最大的位或
  10. ASP.NET---动态生成Word文档
  11. RoR介绍:一个Java程序员的开发体验
  12. NH2-UiO-66|CAS号1260119-00-3金属有机骨架
  13. DDR3联合HDMI进行图片数据的传输
  14. 学钢琴时如何提高识谱能力
  15. 文本分类之降维技术之特征抽取之SVD矩阵的分解的原理的介绍
  16. C语言(宏,内存,地址,指针,解引用)
  17. 起底币圈地下骗局:传销币、资金盘横行,百亿财富被黑手收割
  18. [贴装专题] 基于halcon的最小二乘法计算吸嘴或机械轴旋转中心
  19. 【DOTS学习笔记】从第一个Jobs程序入门
  20. 小明加密通道进入_门禁系统跟闸机通道的区分是什么?功能是一样吗

热门文章

  1. flag push tcp 作用_TCP协议超详细解析及攻击/防范
  2. html在线时间24小时代码,每24小时弹一次的HTML代码
  3. 从零开始学前端: HTML框架和VS Code安装 --- 今天你学习了吗?(CSS:Day01)
  4. 微课|玩转Python轻松过二级(3.1节):列表常用方法
  5. Python编写人机对战小游戏(抓小狐狸)
  6. Python分离GIF动画成为多帧图像
  7. Python标准库shutil中rmtree()使用回调函数
  8. Linux 线程控制
  9. string 都不能作用于switch_这个东西看似细细的,作用大大滴!每个人的牙齿都不能没有它!...
  10. python write函数换行_python中文件的知识点总结