什么是mode_t 0644是什么意思? [英] What does mode_t 0644 mean?

查看:1042
本文介绍了什么是mode_t 0644是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#define COPYMODE 0644
creat(argV[2],COPYMODE);

我有一个文件,CSV模式中code的这两条线。
我不知道这意味着什么。
请给一些关于它的例子

I have these two lines of code in a copy.c file. I don't know what it means. Please give some example about it

推荐答案

有一个3x3的模式位标志:

There are 3x3 bit flags for a mode:


  • (拥有)用户

    • 阅读


    • 执行


    • 阅读


    • 执行


    • 阅读


    • 执行

    因此​​,每个三重连接codeS很好作为一个八进制数字。

    So each triple encodes nicely as an octal digit.

    rwx oct    meaning
    --- ---    -------
    001 01   = execute
    010 02   = write
    011 03   = write & execute
    100 04   = read
    101 05   = read & execute
    110 06   = read & write
    111 07   = read & write & execute
    

    所以0644是:

    So 0644 is:

    * (owning) User: read & write
    * Group: read
    * Other: read
    

    请注意,在C,初始 0 表示八进制,就像 0X 表示十六进制。所以每次你用C纯零,这实际上是一个的的零(有趣的事实)。

    Note that in C, an initial 0 indicates octal notation, just like 0x indicates hexadecimal notation. So every time you write plain zero in C, it's actually an octal zero (fun fact).

    这也可能会这样写:

    -rw-r--r--
    

    而完全权限,0777还可以写成:

    Whereas full permissions, 0777 can also be written:

    -rwxrwxrwx
    

    所以传递到八进制数科瑞直接对应(通过位模式的八进制编码),该文件的权限由 LS显示 - →

    So the octal number passed to creat corresponds directly (via octal encoding of the bit-pattern) to the file permissions as displayed by ls -l.

    这篇关于什么是mode_t 0644是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆