1.lstat 和 stat 的区别
当我们用ln -s 去软链接一个文件时,如果用stat 去查看这个链接文件的属性,则它指向的是链接文件指向的原文件的属性;
而用lstat 则可以读取到链接文件本身的属性。
2. fstat 和 stat 的区别
int fstat(int fd,struct stat *buf);
int stat(const char *pathname,struct stat *buf);
可以看到两个函数的第一个参数并不相同,stat 是用文件名来打开,而 fstat 是用 fd 来打开,这两个函数可以根据需求场景的不同来选择不同的使用。