硬连接(hard link)和软连接(symbolic link)

stat - display file or file system status
struct stat {
    mode_t       st_mode;    /* file type & mode (permissions) */
    ino_t        st_ino;     /* i-node number (serial number) */
    dev_t        st_dev;     /* device number (file system) */
    dev_t        st_rdev;    /* device number for special files */
    nlink_t      st_nlink;    /* number of links */
    uid_t        st_uid;     /* user ID of owner */
    gid_t        st_gid;     /* group ID of owner */
    off_t        st_size;    /* size in bytes, for regular files */
    struct timespec st_atim;    /* time of last access */
    struct timespec st_mtim;    /* time of last modification */
    struct timespec st_ctim;    /* time of last file status change */
    blksize_t     st_blksize;   /* best I/O block size */
    blkcnt_t      st_blocks;   /* number of disk blocks allocated */
};

struct dirent
{
    __ino64_t d_ino;
    __off64_t d_off;
    unsigned short int d_reclen;
    unsigned char d_type;
    char d_name[256];       /* We must not include limits.h! */
};
ln - make links between files
硬连接(hard link)和软连接(symbolic link)。
link, linkat - make a new name for a file
link()  creates a new link (also known as a hard link) to an existing file.
symlink, symlinkat - make a new name for a file
symlink() creates a symbolic link named linkpath which contains the string target.
unlink, unlinkat - delete a name and possibly the file it refers to
This property of unlink is often used by a program to ensure that a temporary file it creates won’t be left around in case the program crashes. 

Hard Links: 为已存在的文件,新建一个指向该文件inode节点的目录项(directory entry),同时增加该inode的连接数。可以让一个文件有多个硬链接,出现在多个目录下。
Hard link一般有两个限制:
1 不能跨文件系统(不同的文件系统有不同的inode table); 
2 不能连接目录(容易在文件系统中造成循环引用)。
Most implementations require that both path
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值