inode
每个inode保存了文件系统中的一个文件系统对象(包括文件、目录、设备文件、socket、管道, 等等)的元信息数据,但不包括数据内容或者文件名
ftell
Get current position in stream
long int ftell ( FILE * stream );
rewind
Set position of stream to the beginning
void rewind ( FILE * stream );
fseek
Reposition stream position indicator
void rewind ( FILE * stream );
opendir
The opendir() function opens a directory stream corresponding to the directory name, and returns a pointer to the directory stream. The stream is positioned at the first entry in the directory.
#include <sys/types.h> #include <dirent.h> DIR *opendir(const char *name);
readdir
The readdir() function returns a pointer to a dirent structure representing the next directory entry in the directory stream pointed to by dirp. It returns NULL on reaching the end of the directory stream or
if an error occurred.
1 #include <dirent.h> 2 struct dirent *readdir(DIR *dirp); 3 struct dirent { 4 ino_t d_ino; /* inode number */ 5 off_t d_off; /* not an offset; see NOTES */ 6 unsigned short d_reclen; /* length of this record */ 7 unsigned char d_type; /* type of file; not supported 8 by all filesystem types */ 9 char d_name[256]; /* filename */ 10 };
stat
These functions return information about a file.
1 #include <sys/types.h> 2 #include <sys/stat.h> 3 #include <unistd.h> 4 5 int stat(const char *path, struct stat *buf); 6 7 struct stat { 8 dev_t st_dev; /* ID of device containing file */ 9 ino_t st_ino; /* inode number */ 10 mode_t st_mode; /* protection */ 11 nlink_t st_nlink; /* number of hard links */ 12 uid_t st_uid; /* user ID of owner */ 13 gid_t st_gid; /* group ID of owner */ 14 dev_t st_rdev; /* device ID (if special file) */ 15 off_t st_size; /* total size, in bytes */ 16 blksize_t st_blksize; /* blocksize for filesystem I/O */ 17 blkcnt_t st_blocks; /* number of 512B blocks allocated */ 18 time_t st_atime; /* time of last access */ 19 time_t st_mtime; /* time of last modification */ 20 time_t st_ctime; /* time of last status change */ 21 };