Repository navigation
Description
Immediate goal of this enhancement is to fix macOS rclone mount which at the moment does not work properly regardless of mounting method used - macOSFUSE or FUSE-T. Optionally normalized VFS can bring other benefits as well e.g. some less common or future filesystems rclone users can work with and normalization constraints imposed.
The background issue and possible solutions have been discussed on the forum:
At the moment many cloud storage destinations (and rclone virtual crypt remote) allow to store both NFC and NFD encoded files/directories names. Also rclone allows to upload/download both forms.
This in general works trouble free on Linux and Windows but breaks rclone mount functionality in macOS - depending on mount options either only NFC or only NFD content is visible/accessible - this is unfortunate consequence of Apple design decision to be different than rest of the world and use exclusively NFD in their APIs. We won't change it.
Experimentation and testing, including attempts to improve situation with FUSE-T (it has now - since v1.0.20 - -o nfc option which should help with NFC path) lead me to believe that last missing part of the puzzle is rclone VFS lack of normalization.
I would like to propose to add optional normalization to VFS.
New option:
--vfs-normalize OFF/NFC/NFD - with OFF being default
When set to NFC or NFD it would apply characters normalization to served content.
Edge case to watch is situation where two names differ only by normalization and coexist in the same folder e.g.:
$ rclone lsf crypt:TEST
CONFLICTéééFILE.txt
CONFLICTéééFILE.txt
one file is NFC and other is NFD. Only solution I see for such case is use only one name and log ERROR.
Activity
ncw commentedon Jun 23, 2023
I think this should be achievable relatively easily.
All file / dir objects are ultimately made from the directory cache. So we only need to do the normalized comparison in the directory cache searching routine.
We actually do this already for case sensitive / insensitive file systems.
So first we look for an exact match which is a quick hash look up, and then we look for a case insensitive match which involves comparing every item.
rclone/vfs/dir.go
Lines 710 to 732 in 2c50f26
We could do something very similar for the normalization options too. I think we'd want to make a normalization function which does the (NFC, NFD) and/or (lower case) and just run through the loop once. We do exactly this in the sync routines so factoring this out would be sensible.
rclone/fs/march/march.go
Lines 58 to 71 in 2c50f26
We currently just use the first one in the case vs CASE comparison. That is the easy thing to do. To detect a collision would require scanning the whole directory which would take on average twice as long.
Worth the extra CPU for an ERROR message?
Assuming we are only using the normalize option to find matching file names and not actually returning them to the OS then we can get away with using NFC only and this would match this flag which only does NFC normalization.
Once thing I am unclear on though - do you think we need to apply that normalization to the file names sent to the OS - is that your intention? So we receive an NFC file name from Google Drive (say) and send the macOS kernel an NFD file name according to the flag? That will be a bit more work (but not much). I think this might be what the FUSE-T option
-o nfcdoes though so maybe isn't necessary?kapitainsky commentedon Jun 23, 2023
Yes this is the most important thing actually and whole purpose of this - it is about sending to OS normalized names. Today we have a problem that remotes can contain both NFC and NFD names - it works on Linux but breaks macOS.
This option converts names received from OS (macOS uses NFD) and makes sure that NFS mount receives NFC - so all NFS content is NFC. It also makes NFC content to work with macOS APIs.
It breaks when some content in remote is already NFD - files are not visible/directories are not browsable.
On macOS it happens for example when user uses
rclone copy/sync- NFD names are saved in remote.With
--vfs-normalizeto make macOS mount work we could either:--vfs-normalize NFD- this is what macOS likes the most I thinkREMOTE -----------------------> MOUNT
NFC -> RCLONE -> NFD -> FUSE -> NFD <---- rclone normalized NFC->NFD
NFD -> RCLONE -> NFD -> FUSE -> NFD
MOUNT -----------------------> REMOTE
NFC -> FUSE -> NFC -> RCLONE -> NFC
NFD -> FUSE -> NFD -> RCLONE -> NFD
--vfs-normalize NFCand use-o nfcREMOTE -----------------------> MOUNT
NFC -> RCLONE -> NFC -> FUSE -> NFD
NFD -> RCLONE -> NFC -> FUSE -> NFD <---- rclone normalized NFD->NFC
MOUNT -----------------------> REMOTE
NFC -> FUSE -> NFC -> RCLONE -> NFC
NFD -> FUSE -> NFC-> RCLONE -> NFC
It is difficult to say which one will behave better on macOS - I think that both would work. But with NFC/NFD and macOS I have learnt that only testing can tell.
kapitainsky commentedon Jun 23, 2023
The key purpose of this enhancement is to fix
rclone mounton macOS.Today it simply does not work - does not matter with macFUSE or FUSE-T. And is unfixable by
-o modules=iconv,from_code=UTF-8,to_code=UTF-8or-o modules=iconv,from_code=UTF-8,to_code=UTF-8-MACworkaround. It only helps in some cases and creates new issues - like for example that files can not be open in Finder (macOS file browser)ncw commentedon Jun 23, 2023
I think what I'll do is try the smallest patch that could work first. That would fix the "... can't be found" errors I think but it wouldn't normalize the returns to the OS. This might mean we need the
-o nfcflag. If that doesn't work I can do the further parts..kapitainsky commentedon Jun 23, 2023
Cool. I am happy at all stages to test - I do not need binary build I can happily build myself from
git clone. I have my test bed - crypt with carefully crafted mix of NFC/NFD files and folders:) so far it breaks everything.I hoped that fuse-t can handle it fully but does not seem to be possible.
kapitainsky commentedon Jun 23, 2023
Note:
With
--vfs-normalizeset to NFC or NFDiconvshould not be applied:rclone/cmd/cmount/mount.go
Lines 120 to 126 in fcb912a
It is crude way to actually try to normalize to NFD- but it stopped working fully with advent of APFS FS few years ago and changes in normalization in all macOS - also I suspect not 100% correct way macFUSE handles it. I actually suspect it never worked 100% before neither - but nowadays it is more apparent.
Still should be there for old Apple computers users - this is why
--vfs-normalizeshould be optionalkapitainsky commentedon Jul 27, 2023
Sorry to keep pestering... but can it be implemented one day? I am not skilled enough in go to give it a go. I do try to earn my karma points on the forum instead:) I do believe that it is missing piece of macOS
rclone mountto work predictably and consistently - and now it is disaster people using it do not realize.I managed to convince author of
fuse-tto make changes helping to alleviate problems moving forward. But without option to normalizemountto NFD on rclone side it is only half measure.ncw commentedon Jul 28, 2023
You have lots of karma indeed :-)
I put this on the 1.64 milestone which isn't a guarantee that it will make that release, but it will be on my radar at least!
25 remaining items
kapitainsky commentedon Feb 7, 2024
@nielash sorry for pestering:) do you think your improvements (normalisation and nfsmount writes on macOS) can be PR-ed?:) These are fixes I was waiting for years so now trying to make sure that they are not lost:)
I have been using them the last few days and this is day and night compared to what it was before in terms of macOS
rclone mountcompatibility.I bet some bits can be still ironed but the best way is to get exposure to myriad of use cases we can't even imagine - simply make it live.
rclone nfsmountmade to release in disastrous stage - effectively useless so compared to it your changes are gold.nielash commentedon Feb 7, 2024
Very glad to hear that 🙂
Yes, I can submit PRs. I was planning to also look at some of the other
nfsmountissues you mentioned (--volnameand unmounting), but as they are less critical maybe it's best to submit the most important changes first and fix the rest later. What do you think?🤣
kapitainsky commentedon Feb 7, 2024
IMO normalisation is fully working and is ready to be included in rclone release. I even took time to understand your code) it looks very clean and logical.
nfsmount - I do appreciate good engineering so have to say that indeed maybe better to solve known issues and make it real feature not just some half baked thing.
Most importantly normalisation works perfectly with macFUSE/FUSE-T so it immediately solves old issue. nfsmount is very nice addition but not critical.
nielash commentedon Feb 13, 2024
@kapitainsky I made a proof-of-concept for a
rclone convmvcommand. Very much still a WIP, but if you are interested: nielash@1d6be93Examples of what it does: Link
kapitainsky commentedon Feb 16, 2024
I have managed to compile it and run few simple tests. All worked! I think that it is very cool small utility. When needed it is purely irreplaceable. Things like this make rclone truly pro utility. Thank you very much for doing it.
vfs: fix unicode normalization on macOS - fixes #7072
vfs: fix unicode normalization on macOS - fixes rclone#7072