From 13b350a57fe8f08bf28d5d7168778a5d7fe686c7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 19 May 2012 16:03:41 -0700 Subject: [PATCH] filestore: test xattrs on temporary file There isn't one we can rely on existing yet. Broken by 1314a00798ed4b7ef2f2686f0195c5c53c98c2ce while fixing #2452. Backport: dho Signed-off-by: Sage Weil --- src/os/FileStore.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index c144fd21213ff..7e8f253b51139 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -1312,7 +1312,16 @@ int FileStore::_detect_fs() char fn[PATH_MAX]; int x = rand(); int y = x+1; - snprintf(fn, sizeof(fn), "%s/whoami", basedir.c_str()); + + snprintf(fn, sizeof(fn), "%s/xattr_test", basedir.c_str()); + + int tmpfd = ::open(fn, O_CREAT|O_WRONLY|O_TRUNC, 0700); + if (tmpfd < 0) { + int ret = -errno; + derr << "_detect_fs unable to create " << fn << ": " << cpp_strerror(ret) << dendl; + return ret; + } + int ret = do_setxattr(fn, "user.test", &x, sizeof(x)); if (ret >= 0) ret = do_getxattr(fn, "user.test", &y, sizeof(y)); @@ -1345,6 +1354,9 @@ int FileStore::_detect_fs() do_removexattr(fn, "user.test4"); do_removexattr(fn, "user.test5"); + ::unlink(fn); + TEMP_FAILURE_RETRY(::close(tmpfd)); + int fd = ::open(basedir.c_str(), O_RDONLY); if (fd < 0) return -errno; -- 2.39.5