zoukankan      html  css  js  c++  java
  • [转载]mode_t等系统数据类型

    mode_t 数据类型究竟是什么类型

    让我们逐步查找一下。

    首先从文件 /usr/include/sys/stat.h 中找到 mode_t 类型

    /usr/include/sys/stat.h -> typedef __mode_t mode_t;

    说明 mode_t 只是对 __mode_t 的一种定义。

    然后从 /usr/include/bits/types.h 中找到 __mode_t 类型

    /usr/include/bits/types.h -> __STD_TYPE __MODE_T_TYPE __mode_t;

    说明 __mode_t 也只是对 __MODE_T_TYPE 的一种定义。

    /usr/include/bits/typesizes.h -> #define __MODE_T_TYPE __U32_TYPE

    说明 __MODE_T_TYPE 是对 __U32_TYPE 的一种定义。

    /usr/include/bits/types.h -> #define __U32_TYPE unsigned int

    最后 __U32_TYPE 是一种无符号的整数的定义。

    从上述推导可以看出,mode_t 实际上也就是一种无符号整数。

    另外如下结构 struct stat 定义中的 st_mode 成员变量也是使用的 mode_t 类型的变量。

    从 man 2 stat 中可以找到结构 struct stat 的定义,如下:

      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 filesystem I/O */
    blkcnt_t st_blocks; /* number of 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 */

    };

  • 相关阅读:
    2019.4.26 周五 阴转小雨
    2019.4.25 周四 阴有小雨
    2019.4.24 周三 阴
    2019.4.23 周二 阴
    2019.4.22 周一 阴转小雨
    oracle优化(一)
    Opencv-Python学习笔记(二)
    Opencv-Python学习笔记(一)
    XtraGrid实现checkbox全选功能
    XtraGrid中checkbox状态设置
  • 原文地址:https://www.cnblogs.com/buxianghe/p/2538753.html
Copyright © 2011-2022 走看看