1 inode 与 dentry
inode 称为索引节点
dentry 称为目录项
inode:包含文件访问权限、属主、组、大小、生成时间、访问时间、最后修改时间等信息
dentry:包含文件名、指向inode的指针等信息。
文件名-》dentry-》inode-》磁盘块
2 使用link与unlink实现mv功能
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <pthread.h>
int main(int argc, char *argv[])
{
link(argv[1], argv[2]);
ulink(argv[1]);
return 0;
}
gcc mytest.c -o mytest
./mytest hello.txt world.txt