当前位置:网站首页>Detailed explanation of stat function
Detailed explanation of stat function
2022-07-24 11:27:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Linux File system management of system functions ( Two )
stat function
effect : Get file information
The header file :
include <sys/types.h> #include <sys/stat.h> #include <unistd.h> The function prototype :
int stat(const char *path, struct stat *buf) Return value : Successfully returns 0, Failure to return -1;
Parameters : File path ( name ),struct stat Type of structure
struct stat Structure details :
struct stat
{
dev_t st_dev; /* ID of device containing file */ The equipment number used in the document
ino_t st_ino; /* inode number */ Inode number
mode_t st_mode; /* protection */ The pattern corresponding to the file , file , Directory etc.
nlink_t st_nlink; /* number of hard links */ Number of hard connections to the file
uid_t st_uid; /* user ID of owner */ Owner user id
gid_t st_gid; /* group ID of owner */ Group identification number
dev_t st_rdev; /* device ID (if special file) */ The equipment number of the equipment file
off_t st_size; /* total size, in bytes */ File capacity in bytes
blksize_t st_blksize; /* blocksize for file system I/O */ The size of the disk block containing the file
blkcnt_t st_blocks; /* number of 512B blocks allocated */ The disk block occupied by this file
time_t st_atime; /* time of last access */ The last time the file was accessed
time_t st_mtime; /* time of last modification */ / The last time the file was modified
time_t st_ctime; /* time of last status change */ The last time the state of the file was changed
};stat In structure st_mode The following situations are defined :
S_IFMT 0170000 Bit mask of file type
S_IFSOCK 0140000 Socket
S_IFLNK 0120000 Symbolic connection
S_IFREG 0100000 General documents
S_IFBLK 0060000 Block device
S_IFDIR 0040000 Catalog
S_IFCHR 0020000 Character device
S_IFIFO 0010000 fifo
S_ISUID 04000 Of documents (set user-id on execution) position
S_ISGID 02000 Of documents (set group-id on execution) position
S_ISVTX 01000 Of documents sticky position
S_IRUSR(S_IREAD) 00400 The file owner has read permission
S_IWUSR(S_IWRITE)00200 The owner of the file has write permission
S_IXUSR(S_IEXEC) 00100 The file owner has executable rights
S_IRGRP 00040 The user group has read permission
S_IWGRP 00020 The user group has write permission
S_IXGRP 00010 The user group has executable rights
S_IROTH 00004 Other users have read permission
S_IWOTH 00002 Other users have write access
S_IXOTH 00001 Other users have executable rights
The above file types are in POSIX Macro definitions for checking these types are defined in :
S_ISLNK (st_mode) Judge whether it is a symbolic connection
S_ISREG (st_mode) Is it a general document
S_ISDIR (st_mode) Is it a directory
S_ISCHR (st_mode) Whether it is a character device file
S_ISBLK (s3e) First in first out
S_ISSOCK (st_mode) Is it socket
If a directory has sticky position (S_ISVTX), It means that the files in this directory can only be used by the owner of the file 、 The owner of this directory or root To delete or rename , stay linux in , The most typical is this /tmp It's a catalog .
st_mode Structure
st_mode Mainly consists of 3 Some information :
- 15-12 Bit save file type
- 11-9 Bit saves the information set when executing the file
- 8-0 Bit save file access
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/125171.html Link to the original text :https://javaforall.cn
边栏推荐
- 08 [AIO programming]
- Sentinel vs Hystrix 限流对比,到底怎么选?
- Lanqiao cup provincial training camp - commonly used STL
- Sorting out the ideas of data processing received by TCP server, and the note of select: invalid argument error
- 【Golang】golang中time类型的before方法
- 哈希——202. 快乐数
- Semaphore详解
- RRPN:Arbitrary-Oriented Scene Text Detection via Rotation Proposals
- 性能测试总结(一)---基础理论篇
- Nodejs ctf 基础
猜你喜欢

JMeter接口测试步骤-安装教程-脚本录制-并发测试

【反序列化漏洞-01】序列化与反序列化简介

MicroBlaze adds a custom IP core and attaches the Axi bus to realize ssd1306 OELD drive

Performance test summary (I) -- basic theory
![[deserialization vulnerability-02] principle test and magic method summary of PHP deserialization vulnerability](/img/03/f80c82d009d21a938911a155dddf6b.png)
[deserialization vulnerability-02] principle test and magic method summary of PHP deserialization vulnerability

HCIP MGRE实验 第三天

Ask n! How many zeros are there behind

Installing Oracle Xe with Linux

What is the charm of CSDN members? What's the use of him?

PDF处理还收费?不可能!
随机推荐
Semaphore details
This should be postman, the most complete interface testing tool in the whole network
Leetcode 257. 二叉树的所有路径
Exceptions about configuring Postgres parameters
Ctfshow ThinkPHP topic 1
【Golang】golang实现简单memcache
HCIP MGRE实验 第三天
哈希——18. 四数之和
如何给自己的网站接入在线客服系统代码
【Golang】golang实现发送微信服务号模板消息
系统管理员需知的 16 个 iptables 使用技巧
This is the right way for developers to open artifact!
[golang] before method of time type in golang
性能测试总结(一)---基础理论篇
运算放大器 —— 快速复苏笔记[贰](应用篇)
哈希——349. 两个数组的交集
【C】 Understanding C language variable scope and life cycle from memory
tcp 服务端接收数据处理思路梳理,以及select: Invalid argument报错 笔记
2022,软测人的平均薪资,看完我瞬间凉了...
Sentinel vs Hystrix 限流对比,到底怎么选?