Add the support for nvme device.

This commit is contained in:
JunjieBai 2022-10-20 11:16:10 +08:00
parent bd0acd9523
commit a088d7cf86
1 changed files with 6 additions and 6 deletions

View File

@ -213,7 +213,7 @@ void DirWatcher::mountAddCallback(GVolumeMonitor *monitor, GMount *gmount, DirWa
if (volume) {
bool canEject = g_volume_can_eject(volume);
QString devName = g_volume_get_identifier(volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
if (canEject and devName.contains(QRegExp("/sd[a-z][1-9]"))) {
if (canEject and devName.contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) {
QMutexLocker locker(&s_mutex);
pThis->m_currentUDiskDeviceList.append(devName.section("/", -1));
}
@ -478,7 +478,7 @@ void DirWatcher::initData()
GVolume *volume = (GVolume*)g_list_nth_data(list, i);
QString udiskDevName = g_volume_get_identifier(volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
bool canEject = g_volume_can_eject(volume);
if (canEject and udiskDevName.contains(QRegExp("/sd[a-z][1-9]"))) {
if (canEject and udiskDevName.contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) {
qDebug() << "udiskDevName:" << udiskDevName.section("/",-1);
m_currentUDiskDeviceList.append(udiskDevName.section("/",-1));
}
@ -523,8 +523,8 @@ void DirWatcher::handleDisk()
m_currentMountedDeviceInfo.clear();
m_repeatedlyMountedDeviceInfo.clear();
for (QStorageInfo &storage: QStorageInfo::mountedVolumes()) {
//遍历当前系统所有挂载的且以sd*开头的存储设备
if (storage.isValid() and storage.isReady() and QString(storage.device()).contains(QRegExp("/sd[a-z][1-9]"))) {
//遍历当前系统所有挂载的且以sd*和nvme开头的存储设备
if (storage.isValid() and storage.isReady() and QString(storage.device()).contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) {
m_currentMountedDeviceInfo[storage.device()].append(storage.rootPath());
//存储非子卷的重复挂载设备
if (m_currentMountedDeviceInfo.value(storage.device()).length() > 1 and storage.subvolume().isEmpty()) {
@ -578,7 +578,7 @@ void DirWatcher::handleDisk()
void DirWatcher::handleAddedUDiskDevice(QDBusMessage msg)
{
QDBusObjectPath objPath = msg.arguments().at(0).value<QDBusObjectPath>();
if (objPath.path().contains(QRegExp("/sd[a-z][1-9]"))) {
if (objPath.path().contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) {
QMutexLocker locker(&s_mutex);
m_currentUDiskDeviceList.append(objPath.path().section("/",-1));
qDebug() << "Add Udisk:" << m_currentUDiskDeviceList;
@ -589,7 +589,7 @@ void DirWatcher::handleRemovedUDiskDevice(QDBusMessage msg)
{
Q_EMIT this->udiskRemoved();
QDBusObjectPath objPath = msg.arguments().at(0).value<QDBusObjectPath>();
if (objPath.path().contains(QRegExp("/sd[a-z][1-9]"))) {
if (objPath.path().contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) {
QMutexLocker locker(&s_mutex);
m_removedUDiskDevice = objPath.path().section("/",-1);
m_currentUDiskDeviceList.removeAll(m_removedUDiskDevice);