From 57289de42b7d5e1f0b88d1c2f2f40a74851ad04e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 7 Jan 2016 10:47:28 -0500 Subject: [PATCH] os/FuseStore: more ENOENT on getattr for non-existent items Signed-off-by: Sage Weil --- src/os/FuseStore.cc | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/os/FuseStore.cc b/src/os/FuseStore.cc index 0c9e0edb15dd2..35f54e6678171 100644 --- a/src/os/FuseStore.cc +++ b/src/os/FuseStore.cc @@ -211,28 +211,43 @@ static int os_getattr(const char *path, struct stat *stbuf) stbuf->st_mode = S_IFREG | 0700; switch (t) { - case FN_OBJECT: case FN_OBJECT_OMAP: case FN_OBJECT_ATTR: + case FN_OBJECT: + if (!fs->store->exists(cid, oid)) + return -ENOENT; + // fall-thru case FN_ALL: case FN_HASH_DIR: case FN_HASH_VAL: - case FN_ROOT: case FN_COLLECTION: + if (!fs->store->collection_exists(cid)) + return -ENOENT; + // fall-thru + case FN_ROOT: stbuf->st_mode = S_IFDIR | 0700; return 0; + case FN_OBJECT_HASH: + if (!fs->store->exists(cid, oid)) + return -ENOENT; + stbuf->st_size = 9; + return 0; + case FN_HASH_END: + if (!fs->store->collection_exists(cid)) + return -ENOENT; if (fs->store->collection_bits(cid) < 0) return -ENOENT; // fall-thru case FN_HASH_START: - case FN_OBJECT_HASH: stbuf->st_size = 9; return 0; case FN_HASH_BITS: { + if (!fs->store->collection_exists(cid)) + return -ENOENT; int bits = fs->store->collection_bits(cid); if (bits < 0) return -ENOENT; @@ -244,6 +259,8 @@ static int os_getattr(const char *path, struct stat *stbuf) case FN_OBJECT_DATA: { + if (!fs->store->exists(cid, oid)) + return -ENOENT; int r = fs->store->stat(cid, oid, stbuf); if (r < 0) return r; @@ -252,6 +269,8 @@ static int os_getattr(const char *path, struct stat *stbuf) case FN_OBJECT_OMAP_HEADER: { + if (!fs->store->exists(cid, oid)) + return -ENOENT; bufferlist bl; fs->store->omap_get_header(cid, oid, &bl); stbuf->st_size = bl.length(); @@ -260,6 +279,8 @@ static int os_getattr(const char *path, struct stat *stbuf) case FN_OBJECT_OMAP_VAL: { + if (!fs->store->exists(cid, oid)) + return -ENOENT; set k; k.insert(key); map v; @@ -273,6 +294,8 @@ static int os_getattr(const char *path, struct stat *stbuf) case FN_OBJECT_ATTR_VAL: { + if (!fs->store->exists(cid, oid)) + return -ENOENT; bufferptr v; int r = fs->store->getattr(cid, oid, key.c_str(), v); if (r == -ENODATA) -- 2.39.5