]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
BlockDevice: detect symbol file basename
authorHaomai Wang <haomai@xsky.com>
Fri, 12 Feb 2016 17:19:58 +0000 (01:19 +0800)
committerHaomai Wang <haomai@xsky.com>
Sun, 21 Feb 2016 10:27:10 +0000 (18:27 +0800)
Signed-off-by: Haomai Wang <haomai@xsky.com>
src/os/bluestore/BlockDevice.cc
src/os/bluestore/BlueStore.cc

index 8286070bb11fd384ff6fbe90f0cb0011b2995e2d..829b47e6941485badc6104dbecd8d826d97ebcc8 100644 (file)
@@ -14,6 +14,7 @@
  *
  */
 
+#include <libgen.h>
 #include <unistd.h>
 
 #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;
 
index 215fe76a151c10f2d904b90ef199eedca1874918..c366f79ad24674b55dc8fe83fa44932ac7497c68 100644 (file)
@@ -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);