diff --git a/kernel/src/fs/VFS.h b/kernel/src/fs/VFS.h index 6ab313cb..e5de6afa 100644 --- a/kernel/src/fs/VFS.h +++ b/kernel/src/fs/VFS.h @@ -286,7 +286,7 @@ namespace VFS bool is_setuid(SharedPtr inode); bool is_setgid(SharedPtr inode); - bool is_seekable(VFS::InodeType type); + bool is_seekable(SharedPtr inode); Inode& root_inode(); diff --git a/kernel/src/sys/file.cpp b/kernel/src/sys/file.cpp index aa36a940..735d224a 100644 --- a/kernel/src/sys/file.cpp +++ b/kernel/src/sys/file.cpp @@ -33,7 +33,7 @@ Result sys_read(Registers*, SyscallArgs args) usize nread = TRY(descriptor.inode->read(buf, descriptor.offset, size)); - if (VFS::is_seekable(descriptor.inode->type())) descriptor.offset += nread; + if (VFS::is_seekable(descriptor.inode)) descriptor.offset += nread; return nread; } @@ -52,12 +52,11 @@ Result sys_write(Registers*, SyscallArgs args) if (!descriptor.is_writable()) return err(EBADF); - if (descriptor.should_append() && VFS::is_seekable(descriptor.inode->type())) - descriptor.offset = descriptor.inode->size(); + if (descriptor.should_append() && VFS::is_seekable(descriptor.inode)) descriptor.offset = descriptor.inode->size(); usize nwritten = TRY(descriptor.inode->write(buf, descriptor.offset, size)); - if (VFS::is_seekable(descriptor.inode->type())) descriptor.offset += nwritten; + if (VFS::is_seekable(descriptor.inode)) descriptor.offset += nwritten; return nwritten; } @@ -74,7 +73,7 @@ Result sys_lseek(Registers*, SyscallArgs args) if (descriptor.inode->type() == VFS::InodeType::FIFO) return err(ESPIPE); - if (!VFS::is_seekable(descriptor.inode->type())) return descriptor.offset; + if (!VFS::is_seekable(descriptor.inode)) return descriptor.offset; off_t new_offset;