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