ufs2: Add access() support

Change-Id: I4c2fa12a623f0893c976430893f448f734794548
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6858
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Vladimir Serbinenko 2023-08-21 01:47:21 +02:00 committed by waddlesplash
parent 260e6bd0a6
commit e62e8e246a
3 changed files with 15 additions and 1 deletions

View File

@ -232,3 +232,15 @@ Inode::ReadLink(char* buffer, size_t *_bufferSize)
strlcpy(buffer, fNode.symlinkpath, *_bufferSize);
return B_OK;
}
status_t
Inode::CheckPermissions(int accessMode) const
{
// you never have write access to a read-only volume
if ((accessMode & W_OK) != 0/* && fVolume->IsReadOnly()*/)
return B_READ_ONLY_DEVICE;
return check_access_permissions(accessMode, Mode(), (gid_t)GroupID(),
(uid_t)UserID());
}

View File

@ -109,6 +109,7 @@ class Inode {
{ fNode.GetCreationTime(timespec); }
void GetAccessTime(struct timespec& timespec) const
{ fNode.GetAccessTime(timespec); }
status_t CheckPermissions(int accessMode) const;
Volume* GetVolume() const { return fVolume; }

View File

@ -320,7 +320,8 @@ ufs2_free_cookie(fs_volume *_volume, fs_vnode *_node, void *_cookie)
static status_t
ufs2_access(fs_volume *_volume, fs_vnode *_node, int accessMode)
{
return B_OK;
Inode* inode = (Inode*)_node->private_node;
return inode->CheckPermissions(accessMode);
}