Linux system programming files and I/O (iv) file properties

Source: Internet
Author: User
Tags file system lstat linux

First, read file meta data

int stat (const char *path, struct stat *buf);

int fstat (int fd, struct stat *buf);

int Lstat (const char *path, struct stat *buf);

Stat () Stats The file pointed to by path and fills in BUF.

Lstat () is identical to stat (), except this if path is a symbolic link, then the link itself be stat-ed, not the file th At it refers to.

Fstat () is identical to stat (), except which the file to being stat-ed is specified by the file descriptor FD.

Second, stat structural body

struct STAT {

dev_t St_dev; /* ID of device containing file */

ino_t St_ino; /* Inode Number * *

mode_t St_mode; * Protection * *

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 * *

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 * *

};

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.