mirror of
https://github.com/ceph/ceph
synced 2025-03-10 02:09:21 +00:00
BlockDevice: detect symbol file basename
Signed-off-by: Haomai Wang <haomai@xsky.com>
This commit is contained in:
parent
d208668d57
commit
b5cdc33250
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user