nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ dev_t st_rdev; /* device ID (if special file) */ off_t st_size; /* total size, in bytes */ // 在linux下,与windows不同,size值仅仅是属性 // 不能实际体现占用磁盘大小,详见 big.c
blksize_t st_blksize; /* blocksize for file system I/O */ blkcnt_t st_blocks; /* number of 512B blocks allocated */ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last status change */ };
structdirent { ino_t d_ino; /* inode number */ off_t d_off; /* offset to the next dirent */ unsignedshort d_reclen; /* length of this record */ unsignedchar d_type; /* type of file; not supported by all file system types */ char d_name[256]; /* filename */ };
structpasswd { char *pw_name; /* username */ char *pw_passwd; /* user password */ uid_t pw_uid; /* user ID */ gid_t pw_gid; /* group ID */ char *pw_gecos; /* user information */ char *pw_dir; /* home directory */ char *pw_shell; /* shell program */ };
/etc/group
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/** * 通过组ID获取组信息 */ struct group *getgrgid(gid_t gid);
/** * 通过组名获取组信息 */ struct group *getgrnam(constchar *name);
structgroup { char *gr_name; /* group name */ char *gr_passwd; /* group password */ gid_t gr_gid; /* group ID */ char **gr_mem; /* group members */ };
structspwd { char *sp_namp; /* login name */ char *sp_pwdp; /* encrypted password */ long sp_lstchg; /* last change */ long sp_min; /* min days between changes */ long sp_max; /* max days between changes */ long sp_warn; /* warning days before password expires */ long sp_inact; /* days before account inactive */ long sp_expire; /* days since 1970-01-01 until account expires */ unsignedlong sp_flag; /* reserved */ };
sturct tm { int tm_sec; /* seconds */ int tm_min; /* minutes */ int tm_hour; /* hours */ int tm_mday; /* day of the month */ int tm_mon; /* month */ int tm_year; /* year */ int tm_wday; /* day of the week */ int tm_yday; /* day in the year */ int tm_isdst; /* daylight saving time */ /* daylight 夏令时调整 */ };