在用户打开文件时,更改inodes中的文件权限

发布于 2025-02-10 03:58:07 字数 583 浏览 1 评论 0原文

根据 this 问题,当我们打开文件以阅读文件时,我们只在打开它时一次检查一次权限。而且,如果我们更改文件的权限并说不再允许用户从文件中读取用户,则用户仍然可以读取文件。

这提出了一些问题:

  1. 我们不需要继续检查权限,因为例如,如果我们打开一个文件来读取它,然后尝试使用write,我们不应该得到错误?这意味着我们检查我们允许使用该文件的操作。 (也许我们与FD在本地保存我们允许使用的操作并每次检查它们?)

  2. 当我们更新权限时,我们是否在Inode表中更新Inode的单个副本,还是我们直接更新磁盘上的副本?因为如果我们直接在磁盘上的副本上更新权限,则查看Inode表的其他进程将看不到更新的版本,因此更新Inode表的更新更有意义磁盘。

According to this SO question, when we open a file to read it we only check permissions once when we open it. And if we change the permissions of the file and say the user is no longer allowed to read from the file, the user will still be able to read the file.

This raises a few questions:

  1. Don't we need to keep checking permissions, since if for example we open a file to read it, and then try to use write, shouldn't we get an error? This means that we check what we're allowed to do with the file. (perhaps we save locally with the fd the operations we are allowed to do with it and check them each time?)

  2. When we update permissions, do we update the single copy of the inode in the inode table or do we directly update the copy on the disk? Since if we update the permissions directly on the copy on the disk, other processes looking at the inode table will not see the updated version, so it makes more sense to update the inode table and from there let the OS write the changes back to the disk.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文