Merge branch 'fix_nvme_error' into dev
This commit is contained in:
commit
6a6a1ed5b6
|
@ -7,6 +7,15 @@ libkysdk-system (1.0.0testkylin19) v101; urgency=medium
|
|||
2、完善获取系统激活状态接口调用方式
|
||||
|
||||
-- chenzhikai <chenzhikai@kylinos.cn> Tue, 23 Nov 2021 10:08:33 +0800
|
||||
|
||||
libkysdk-system (1.0.0kylin5) v101; urgency=medium
|
||||
|
||||
*Bug号:90497
|
||||
*需求号:无
|
||||
*其他修改:解决nvme硬盘信息获取失败问题
|
||||
|
||||
-- chenzhikai <chenzhikai@kylinos.cn> Thu, 02 Dec 2021 17:01:49 +0800
|
||||
|
||||
libkysdk-system (1.0.0kylin4) v101; urgency=medium
|
||||
|
||||
*Bug号:92439
|
||||
|
@ -14,6 +23,7 @@ libkysdk-system (1.0.0kylin4) v101; urgency=medium
|
|||
*其他修改:解决d-feet调试服务报错问题
|
||||
|
||||
-- chenzhikai <chenzhikai@kylinos.cn> Fri, 19 Nov 2021 14:17:56 +0800
|
||||
|
||||
libkysdk-system (1.0.0kylin3) v101; urgency=medium
|
||||
|
||||
*Bug号:90619
|
||||
|
|
|
@ -15,7 +15,8 @@ Build-Depends: debhelper-compat (= 12),
|
|||
libkysdk-timer-dev,
|
||||
libqt5core5a,
|
||||
qtbase5-dev,
|
||||
libkylin-activation
|
||||
libkylin-activation,
|
||||
libudev-dev
|
||||
Standards-Version: 4.4.1
|
||||
Homepage: http://gitlab2.kylin.com/kysdk/kysdk-system
|
||||
|
||||
|
@ -63,7 +64,8 @@ Depends: ${shlibs:Depends},
|
|||
${misc:Depends},
|
||||
libkysdk-disk,
|
||||
libkysdk-log-dev,
|
||||
libkysdk-utils-dev
|
||||
libkysdk-utils-dev,
|
||||
libudev-dev
|
||||
Multi-Arch: same
|
||||
Description: 系统磁盘信息获取库 - 开发库
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@ aux_source_directory(. SOURCESCODE)
|
|||
add_library(kydiskinfo SHARED ${SOURCESCODE})
|
||||
add_executable(test-getdiskinfo test/getdiskinfo.c)
|
||||
add_executable(test-getdisklist test/getdisklist.c)
|
||||
target_link_libraries(test-getdiskinfo kydiskinfo blkid kylog pthread systemd kyconf)
|
||||
target_link_libraries(test-getdisklist kydiskinfo blkid kylog pthread systemd kyconf)
|
||||
find_library(UDEV_LIB udev)
|
||||
message(${UDEV_LIB})
|
||||
target_link_libraries(test-getdiskinfo kydiskinfo blkid kylog pthread systemd kyconf ${UDEV_LIB})
|
||||
target_link_libraries(test-getdisklist kydiskinfo blkid kylog pthread systemd kyconf ${UDEV_LIB})
|
||||
|
||||
install(TARGETS kydiskinfo
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include <limits.h>
|
||||
#include <libmount/libmount.h>
|
||||
#include <unistd.h>
|
||||
#include <libudev.h>
|
||||
#include <kysdk/kysdk-base/cstring-extension.h>
|
||||
|
||||
static int get_disk_fs(kdk_diskinfo *di)
|
||||
{
|
||||
|
@ -137,7 +139,7 @@ static int get_disk_identifier(int fd, kdk_diskinfo *di)
|
|||
klog_warning("该磁盘[%s]未写入标识信息\n", di->name);
|
||||
return -1;
|
||||
}
|
||||
klog_err("ioctl 执行失败:%s\n", strerror(errno));
|
||||
klog_warning("ioctl 执行失败:%s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
char *model = strndup((char*)&hd[27], 40);
|
||||
|
@ -371,7 +373,93 @@ kdk_diskinfo *kdk_get_diskinfo(const char *diskname)
|
|||
|
||||
if (get_disk_identifier(fd, res))
|
||||
{
|
||||
goto err_out;
|
||||
struct udev *udev;
|
||||
struct udev_device *dev;
|
||||
|
||||
udev = udev_new();
|
||||
// klog_debug("初始化udev\n");
|
||||
if (!udev)
|
||||
{
|
||||
goto err_out;
|
||||
}
|
||||
int pos = strlastof(diskname, '/');
|
||||
if (pos <= 0)
|
||||
pos = 0;
|
||||
char *dn = diskname + pos;
|
||||
// klog_debug("%s\n", dn);
|
||||
|
||||
const char *dev_PP = NULL;
|
||||
const char *serial = NULL;
|
||||
const char *dev_P = NULL;
|
||||
const char *serial_val = NULL;
|
||||
if (udev_device_new_from_subsystem_sysname(udev,"block",dn))
|
||||
{
|
||||
dev = udev_device_new_from_subsystem_sysname(udev,"block",dn);
|
||||
}
|
||||
else if (udev_device_new_from_subsystem_sysname(udev,"nvme",dn))
|
||||
{
|
||||
dev = udev_device_new_from_subsystem_sysname(udev,"nvme",dn);
|
||||
}
|
||||
else{
|
||||
klog_err("No disk information matched : %s\n",diskname);
|
||||
// goto err_out;
|
||||
}
|
||||
dev_PP = udev_device_get_parent(udev_device_get_parent(dev));
|
||||
dev_P = udev_device_get_parent(dev);
|
||||
if(udev_device_get_sysattr_value(dev,"model")){
|
||||
// klog_debug("Dev DeviceModel: %s\n", udev_device_get_sysattr_value(dev_P,"model"));
|
||||
if (udev_device_get_sysattr_value(dev,"serial"))
|
||||
{
|
||||
serial_val = udev_device_get_sysattr_value(dev,"serial");
|
||||
// klog_debug("Dev DeviceDevPath: %s\n", udev_device_get_syspath(dev));
|
||||
// klog_debug("Dev DeviceSerial: %s\n", serial_val);
|
||||
res->serial = strdup(serial_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
klog_err("Input Special Device :%s\n", dn);
|
||||
}
|
||||
res->model = strdup(udev_device_get_sysattr_value(dev,"model"));
|
||||
}
|
||||
else if (udev_device_get_sysattr_value(dev_P,"model"))
|
||||
{
|
||||
// klog_debug("Dev_P DeviceModel: %s\n", udev_device_get_sysattr_value(dev_P,"model"));
|
||||
if (udev_device_get_sysattr_value(dev_P,"serial"))
|
||||
{
|
||||
serial_val = udev_device_get_sysattr_value(dev_P,"serial");
|
||||
// klog_debug("Dev_P DeviceDevPath: %s\n", udev_device_get_syspath(dev_PP));
|
||||
}
|
||||
else{
|
||||
serial = udev_device_get_parent(udev_device_get_parent(udev_device_get_parent(dev_PP)));
|
||||
serial_val = udev_device_get_sysattr_value(serial,"serial");
|
||||
// klog_debug("Dev_P DeviceDevPath: %s\n", udev_device_get_syspath(serial));
|
||||
}
|
||||
// klog_debug("Dev_P DeviceSerial: %s\n", serial_val);
|
||||
res->serial = strdup(serial_val);
|
||||
res->model = strdup(udev_device_get_sysattr_value(dev_P,"model"));
|
||||
}
|
||||
else if (udev_device_get_sysattr_value(dev_PP,"model"))
|
||||
{
|
||||
klog_debug("DeviceModel: %s\n", udev_device_get_sysattr_value(dev_PP,"model"));
|
||||
if (udev_device_get_sysattr_value(dev_PP,"serial")){
|
||||
serial_val = udev_device_get_sysattr_value(dev_PP,"serial");
|
||||
// klog_debug("DeviceDevPath: %s\n", udev_device_get_syspath(dev_PP));
|
||||
|
||||
}
|
||||
else{
|
||||
serial = udev_device_get_parent(udev_device_get_parent(udev_device_get_parent(udev_device_get_parent(dev_PP))));
|
||||
serial_val = udev_device_get_sysattr_value(serial,"serial");
|
||||
// klog_debug("DeviceDevPath: %s\n", udev_device_get_syspath(serial));
|
||||
}
|
||||
// klog_debug("DeviceSerial: %s\n", serial_val);
|
||||
res->serial = strdup(serial_val);
|
||||
res->model = strdup(udev_device_get_sysattr_value(dev_PP,"model"));
|
||||
}
|
||||
else{
|
||||
klog_err("No disk MODEL info matched :%s\n",diskname);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (get_disk_space(fd, res))
|
||||
|
|
Loading…
Reference in New Issue