How does the go language os.FileMode function convert permissions from integers/octal/??? before setting the flags?

前端 未结 2 644
独厮守ぢ
独厮守ぢ 2021-01-15 21:59

Update: based on the comment and response so far, I guess I should make it explicit that I understand 0700 is the octal representation of the decimal number

相关标签:
2条回答
  • 2021-01-15 22:50

    So your file mode was changed from the requested 0274 to the actual on-disk 0254. I'll bet that your umask is 0022. Sounds to me like everything is working fine.

    0 讨论(0)
  • 2021-01-15 23:00

    os.FileMode only knows about integers, it doesn't care whether the literal representation is octal or not.

    The fact that 0700 is interpreted in base 8 comes from the language spec itself:

    An integer literal is a sequence of digits representing an integer constant. An optional prefix sets a non-decimal base: 0 for octal, 0x or 0X for hexadecimal. In hexadecimal literals, letters a-f and A-F represent values 10 through 15.

    This is a fairly standard way of representing literal octal numbers in programming languages.

    0 讨论(0)
提交回复
热议问题