| 11 | namespace vfs { |
| 12 | |
| 13 | auto Read(File* file, void* buf, size_t count) -> Expected<size_t> { |
| 14 | if (file == nullptr || buf == nullptr) { |
| 15 | return std::unexpected(Error(ErrorCode::kInvalidArgument)); |
| 16 | } |
| 17 | |
| 18 | LockGuard<SpinLock> guard(GetVfsState().vfs_lock_); |
| 19 | if (file->ops == nullptr) { |
| 20 | return std::unexpected(Error(ErrorCode::kDeviceNotSupported)); |
| 21 | } |
| 22 | |
| 23 | return file->ops->Read(file, buf, count); |
| 24 | } |
| 25 | |
| 26 | } // namespace vfs |