fchmod 之后写入的预期行为是什么?
What is the expected behaviour of a write after fchmod?
如果我打开并创建一个用于 r/w 访问的文件,然后随后使用 fchmod 删除写入访问 在 fchmod 调用之后和 [=17 之前直接写入同一文件描述符的预期行为是什么=]那个文件?
这是POSIX指定的吗?
是否只在打开时检查权限?
来自 chmod
(which has the same behavior as fchmod
) 上的参考页:
The effect on file descriptors for files open at the time of a call to chmod()
is implementation-defined.
所以,POSIX 没有定义,您必须查阅您的平台文档。
对于完全符合要求的实现,似乎在打开文件后更改文件的权限对已经打开的文件描述符没有影响。
来自版本 7 chmod()
/fchmodat()
documentation:
APPLICATION USAGE
...
Any file descriptors currently open by any process on the file could
possibly become invalid if the mode of the file is changed to a value
which would deny access to that process. One situation where this
could occur is on a stateless file system. This behavior will not
occur in a conforming environment.
这与 POSIX 的版本 6 不同,其中 the chmod()
documentation states:
The effect on file descriptors for files open at the time of a call to
chmod() is implementation-defined.
如果我打开并创建一个用于 r/w 访问的文件,然后随后使用 fchmod 删除写入访问 在 fchmod 调用之后和 [=17 之前直接写入同一文件描述符的预期行为是什么=]那个文件?
这是POSIX指定的吗?
是否只在打开时检查权限?
来自 chmod
(which has the same behavior as fchmod
) 上的参考页:
The effect on file descriptors for files open at the time of a call to
chmod()
is implementation-defined.
所以,POSIX 没有定义,您必须查阅您的平台文档。
对于完全符合要求的实现,似乎在打开文件后更改文件的权限对已经打开的文件描述符没有影响。
来自版本 7 chmod()
/fchmodat()
documentation:
APPLICATION USAGE
...
Any file descriptors currently open by any process on the file could possibly become invalid if the mode of the file is changed to a value which would deny access to that process. One situation where this could occur is on a stateless file system. This behavior will not occur in a conforming environment.
这与 POSIX 的版本 6 不同,其中 the chmod()
documentation states:
The effect on file descriptors for files open at the time of a call to chmod() is implementation-defined.