什么是mode_t 0644是什么意思? [英] What does mode_t 0644 mean?
问题描述
#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 like0x
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 byls -l
.这篇关于什么是mode_t 0644是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!