From 37f7c764d1f28bb698e920bec1f8217dbdd033c4 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Wed, 30 Sep 2015 14:27:29 +0200 Subject: [PATCH] Return better fuse errors --- src/filesystem/CryDevice.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/filesystem/CryDevice.cpp b/src/filesystem/CryDevice.cpp index 1a8b0473..a069b5b8 100644 --- a/src/filesystem/CryDevice.cpp +++ b/src/filesystem/CryDevice.cpp @@ -83,22 +83,27 @@ optional> CryDevice::Load(const bf::path &path) { unique_ref CryDevice::LoadDirBlob(const bf::path &path) { auto blob = LoadBlob(path); auto dir = dynamic_pointer_move(blob); - ASSERT(dir != none, "Loaded blob is not a directory"); + if (dir == none) { + throw FuseErrnoException(ENOTDIR); // Loaded blob is not a directory + } return std::move(*dir); } unique_ref CryDevice::LoadBlob(const bf::path &path) { auto currentBlob = _fsBlobStore->load(_rootKey); - //TODO Return correct fuse error ASSERT(currentBlob != none, "rootDir not found"); for (const bf::path &component : path.relative_path()) { auto currentDir = dynamic_pointer_move(*currentBlob); - ASSERT(currentDir != none, "Path component is not a dir"); + if (currentDir == none) { + throw FuseErrnoException(ENOTDIR); // Path component is not a dir + } Key childKey = (*currentDir)->GetChild(component.c_str()).key; currentBlob = _fsBlobStore->load(childKey); - ASSERT(currentBlob != none, "Blob for directory entry not found"); + if (currentBlob == none) { + throw FuseErrnoException(ENOENT); // Blob for directory entry not found + } } return std::move(*currentBlob);