1.1 --- a/libfsserver/lib/files/ext2_file_operations.cc Tue Feb 08 00:03:32 2022 +0100
1.2 +++ b/libfsserver/lib/files/ext2_file_operations.cc Wed Feb 09 22:30:29 2022 +0100
1.3 @@ -22,10 +22,27 @@
1.4 #include <e2access/access.h>
1.5 #include <e2access/image.h>
1.6 #include <e2access/path.h>
1.7 +#include <systypes/fcntl.h>
1.8
1.9 #include "ext2_file_operations.h"
1.10
1.11 -/* Object type tests. */
1.12 +
1.13 +
1.14 +/* Access and object type tests. */
1.15 +
1.16 +bool Ext2FileOperations::can_access(user_t user, flags_t flags, ext2_ino_t ino)
1.17 +{
1.18 + struct ext2_inode inode;
1.19 + errcode_t retval = ext2fs_read_inode(_fs, ino, &inode);
1.20 +
1.21 + if (retval)
1.22 + return false;
1.23 +
1.24 + if ((flags & O_RDWR) || (flags & O_WRONLY))
1.25 + return access_can_write(user, &inode);
1.26 + else
1.27 + return access_can_read(user, &inode);
1.28 +}
1.29
1.30 bool Ext2FileOperations::is_directory(ext2_ino_t ino_file)
1.31 {
1.32 @@ -41,6 +58,8 @@
1.33 return _image_isfile(_fs, ino_file);
1.34 }
1.35
1.36 +
1.37 +
1.38 /* Perform closing operations on a file. */
1.39
1.40 void Ext2FileOperations::close_file(ext2_file_t file)