--- kio-5.110.0.orig/src/core/kmountpoint.cpp +++ kio-5.110.0/src/core/kmountpoint.cpp @@ -354,6 +354,12 @@ KMountPoint::List KMountPoint::currentMo mp->d->m_mountType = QFile::decodeName(mnt_fs_get_fstype(fs)); mp->d->m_isNetFs = mnt_fs_is_netfs(fs) == 1; mp->d->m_deviceId = mnt_fs_get_devno(fs); + if(mp->d->m_mountType == QStringLiteral("btrfs")) { + QT_STATBUF buff; + if(QT_LSTAT(mnt_fs_get_target(fs), &buff) == 0) + mp->d->m_deviceId = buff.st_dev; + + } if (infoNeeded & NeedMountOptions) { mp->d->m_mountOptions = QFile::decodeName(mnt_fs_get_options(fs)).split(QLatin1Char(',')); @@ -445,6 +451,39 @@ KMountPoint::Ptr KMountPoint::List::find if (it != this->cend()) { result = *it; } + else { + // check if mount point could is a btrfs subvolume + // do this by enumerating every mountpoint, filter btrfs and use the longest common realPath match + int pathlen = 0; + auto btrfsIt = this->cbegin(); + while (btrfsIt != this->cend()) { + if((*btrfsIt)->mountPoint().length()>pathlen && (*btrfsIt)->mountType()==QStringLiteral("btrfs") && realPath.startsWith((*btrfsIt)->mountPoint())) { + result = *btrfsIt; + pathlen = result->mountPoint().length(); + } + btrfsIt++; + } + // there is indeed a upper btrfs, search btrfs subvolume boundary, use that als mountPoint and + // reuse the rest of the fstab/mountinfo information + if(result) { + QDir parentPath(realPath); + QDir path = parentPath; + while (parentPath.cdUp()) { + QT_STATBUF buff2; + QT_LSTAT(QFile::encodeName(parentPath.absolutePath()).constData(), &buff2); + if(buff2.st_dev!=buff.st_dev) { // found root change + Ptr mp(new KMountPoint); + mp->d->m_mountedFrom = result->d->m_mountedFrom; + mp->d->m_mountPoint = path.absolutePath(); + mp->d->m_mountType = result->d->m_mountType; + mp->d->m_isNetFs = result->d->m_isNetFs; + mp->d->m_deviceId = buff2.st_dev; + return mp; + } + path = parentPath; + } + } + } } return result;