From: Sage Weil Date: Sat, 19 May 2012 23:03:41 +0000 (-0700) Subject: filestore: test xattrs on temporary file X-Git-Tag: v0.47.1~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=13b350a57fe8f08bf28d5d7168778a5d7fe686c7;p=ceph.git 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 --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index c144fd21213..7e8f253b511 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;