Ignore NTFS hidden flag for root volume
ClosedPublic

Authored by broulik on Jun 28 2018, 1:06 PM.

Details

Summary

Those are always hidden as far as NTFS is concerned but leads to unwanted side-effects of NTFS volumes becoming inaccessible in the UI

BUG: 392913

Test Plan

My NTFS drive in /media is visible again
Inside the folder I get /media/foo/. where the mapping fails again. Any QUrl or KIO resolve magic to fix that?
No idea this patch is the right approach, just throwing it out for discussion

Diff Detail

Repository
R241 KIO
Lint
Lint Skipped
Unit
Unit Tests Skipped
broulik created this revision.Jun 28 2018, 1:06 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 28 2018, 1:06 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
broulik requested review of this revision.Jun 28 2018, 1:06 PM
broulik updated this revision to Diff 36838.Jun 28 2018, 1:23 PM

Only check for folders, a file cannot be a mount, saves querying mount points for hidden files

wbauer added a subscriber: wbauer.Jul 5 2018, 3:16 PM

I tried the patch and it doesn't make a difference here, the mountpoint of my NTFS partition is still hidden.
(it's on an internal drive and mounted to /windows/C via fstab in case it matters)

Additional debug output showed that ep->d_type is not DT_DIR but 0 (which would be DT_UNKNOWN IIANM?) in my case.

wbauer added a comment.Jul 5 2018, 3:41 PM

I tried the patch and it doesn't make a difference here, the mountpoint of my NTFS partition is still hidden.
(it's on an internal drive and mounted to /windows/C via fstab in case it matters)

Additional debug output showed that ep->d_type is not DT_DIR but 0 (which would be DT_UNKNOWN IIANM?) in my case.

It does seem to matter.
I just created an NTFS partition on an USB stick, mounted it via dolphin (to /run/media/...) and in this case ep->d_type is indeed DT_DIR, the patch works as intended in this case.

So maybe you should check for DT_UNKNOWN as well...

wbauer added inline comments.Jul 5 2018, 4:17 PM
src/ioslaves/file/file_unix.cpp
566 ↗(On Diff #36838)

Changing this to 'if (ep->d_type == DT_DIR || ep->d_type == DT_UNKNOWN) {' makes it work in both mentioned cases (internal harddisk mounted on boot via fstab, and external USB stick mounted via dolphin/solid) for me.

And hidden directories on the filesystem still are hidden.

broulik updated this revision to Diff 37229.Jul 6 2018, 7:46 AM

Also check for DT_UNKNOWN

ngraham resigned from this revision.Jul 23 2018, 3:24 PM

@wbauer, does this work for you now? Or @bruns? Still cannot test as I have no NTFS partitions.

wbauer added a subscriber: ngraham.Jul 25 2018, 8:48 AM

@wbauer, does this work for you now?

Yes, it does work as expected now here in all cases I tested, and I didn't notice problems.

With additional debug output I do see the '.' entry in the root dir still marked as hidden (as mentioned in the test plan), and also the '..' entry in (first-level) subdirs is hidden.
This could be fixed e.g. by using QDir::cleanPath(), i.e.:

const QString fullFilePath = QDir::cleanPath(path + QLatin1Char('/') + filename);

But I'm not sure that is really necessary as those entries are not displayed at all anyway (even with hidden files enabled).

src/ioslaves/file/file_unix.cpp
575

This is entry.fastInsert(...) now as of KIO 5.48.0, see https://cgit.kde.org/kio.git/commit/?id=7048d259529fd37134e9bc1bc8d3edc3d4ac8ef4
Maybe the patch should be rebased...

With additional debug output I do see the '.' entry in the root dir still marked as hidden (as mentioned in the test plan), and also the '..' entry in (first-level) subdirs is hidden.

I also found another problem though: symlinks to the mountpoint/NTFS root dir are (still) hidden as well (also if they are on different partitions).

Using QDir::canonicalPath() (instead of QDir::cleanPath() ) would fix all 3 cases:

const QString fullFilePath = QDir(path + QLatin1Char('/') + filename).canonicalPath();

(that one isn't static...)

Using QDir::canonicalPath() (instead of QDir::cleanPath() ) would fix all 3 cases:

const QString fullFilePath = QDir(path + QLatin1Char('/') + filename).canonicalPath();

Or rather, as the current directory is set to path in line#507, this would actually suffice:

const QString fullFilePath = QDir(filename).canonicalPath();

I cannot speak for the code, but this seems to work perfectly well when I tested it today. I used Kate and KBackup to open some files/directories on an external NTFS, and used KBackup to write a backup to the drive. I didn't have to check 'Show hidden folders' and the device shortcut for the NTFS drive in the Open dialog worked as expected.
I hope this can be pushed soon.

@broulik? Is it ready to land?

broulik updated this revision to Diff 39331.Aug 9 2018, 6:44 AM
broulik retitled this revision from RFC: Ignore NTFS hidden flag for root volume to Ignore NTFS hidden flag for root volume.
  • Rebase
  • use QDir().absoluteFilePath()
dfaure accepted this revision.Aug 9 2018, 7:46 AM
This revision is now accepted and ready to land.Aug 9 2018, 7:46 AM
This revision was automatically updated to reflect the committed changes.
wbauer added inline comments.Aug 9 2018, 8:27 AM
src/ioslaves/file/file_unix.cpp
567 ↗(On Diff #36838)

This still doesn't handle symlinks.
E.g. if you create a symlink to the NTFS partition's mount point/root dir on your desktop, it will still be hidden.

As mentioned, const QString fullFilePath = QDir(filename).canonicalPath(); instead should fix that (and still handle . and ..).

broulik added inline comments.Aug 9 2018, 9:12 AM
src/ioslaves/file/file_unix.cpp
567 ↗(On Diff #36838)