diff --git a/src/os/bluestore/BlockDevice.cc b/src/os/bluestore/BlockDevice.cc index 8286070bb11..829b47e6941 100644 --- a/src/os/bluestore/BlockDevice.cc +++ b/src/os/bluestore/BlockDevice.cc @@ -14,6 +14,7 @@ * */ +#include #include #include "KernelDevice.h" @@ -45,10 +46,12 @@ void IOContext::aio_wait() BlockDevice *BlockDevice::create(const string& path, aio_callback_t cb, void *cbpriv) { string type = "kernel"; - char buf[10]; + char buf[PATH_MAX]; int r = ::readlink(path.c_str(), buf, sizeof(buf)); - if (r >= 0 && strncmp(buf, SPDK_PREFIX, sizeof(SPDK_PREFIX)-1) == 0) { - type = "ust-nvme"; + if (r >= 0) { + char *bname = ::basename(buf); + if (strncmp(bname, SPDK_PREFIX, sizeof(SPDK_PREFIX)-1) == 0) + type = "ust-nvme"; } dout(1) << __func__ << " path " << path << " type " << type << dendl; diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 215fe76a151..c366f79ad24 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1583,12 +1583,11 @@ int BlueStore::_setup_block_symlink_or_file( flags |= O_CREAT; if (epath.length()) { if (!epath.compare(0, sizeof(SPDK_PREFIX)-1, SPDK_PREFIX)) { - string symbol_spdk_file = path + "/" + epath; - r = ::symlinkat(symbol_spdk_file.c_str(), path_fd, name.c_str()); + r = ::symlinkat(epath.c_str(), path_fd, name.c_str()); if (r < 0) { r = -errno; derr << __func__ << " failed to create " << name << " symlink to " - << symbol_spdk_file << ": " << cpp_strerror(r) << dendl; + << epath << ": " << cpp_strerror(r) << dendl; return r; } int fd = ::openat(path_fd, epath.c_str(), flags, 0644);