Cloud file sharing services like iCloud Drive are wonderful when they work, but what can you do with them when they don’t? Apple doesn’t provide a utility to diagnose and fix their problems. As a result, they’re often almost intractable, generating many questions but few solutions.
Since iCloud Drive switched to using the File Provider framework in macOS Sonoma, as have most other cloud services supported on Macs, there has been an opportunity for a common approach. You may be surprised to learn that there already is a File Provider Consistency Check service, FPCK, intended to be analogous to fsck, but hardly anyone seems to use it.
brctl
You will come across some references to the command tool brctl, intended to manage the CloudDocs daemon. According to its man page, it currently supports the following commands:
- diagnose and log, to diagnose it and collect logs
- dump, to dump the CloudDocs database
- monitor, to query the container using NSMetadataQuery
- versions, to list document versions held in iCloud Drive
- download and evict, to control those for files.
Usage information given is different, and a bit more promising, adding status, accounts and quota, but this isn’t a tool designed for even more advanced users, and rarely credited as a means of diagnosing or fixing iCloud Drive problems. Being specific to iCloud Drive, brctl is of no help for other cloud services using File Provider.
fileproviderctl
The modest man page for fileproviderctl doesn’t look particularly promising. It describes its purpose as being to “introspect file provider extensions”, and refers to fpck(1) which doesn’t even seem to exist in macOS Sequoia or later. But its usage information is different and more tempting, with commands including:
- dump, to dump the state of a fileprovider’s daemon
- diagnose, to dump the state into “several files”
- evaluate, to “evaluate finder actions and decorations on an item”, or finder interactions
- check and repair, to run FPCK
- obfuscate, to convert a path into obfuscated form.
I’ll start with the simplest of those.
Obfuscated filenames and paths
The Unified log has extensive privacy protection that typically censors information such as filenames and paths with <private>. Instead, File Provider and iCloud Drive use a simple obfuscation scheme by referring to each part of the path by its initial and last characters, and the number of characters between them. Thus, the word examples would become e{6}s, and
/Users/hoakley/Library/Mobile\ Documents/com\~apple\~CloudDocs/backup1/325TidyUpRV.txt
becomes
/U{3}s/h{5}y/L{5}y/M{14}s/c{17}s/b{5}1/3{9}V.txt
Converting in that direction is easy, but you can’t go in the opposite direction, as e{6}s could equally be any eight-letter word starting with e and ending with s, and that’s how this transformation obfuscates. Despite that, it’s far more helpful than endless <private>.
Evaluate a file
The command
fileproviderctl evaluate [path]
where [path] is the full path to a file in iCloud Drive or another File Provider service, delivers useful information, much of which you could see using the browser in Cirrus, including file attributes, sync settings and status. Some is cryptic, including
Capabilities: rwdpfetTP---
and namespace policies, but those may make more sense to you.
FPCK
The check and repair commands are by far the most interesting for those of us trying to solve a sync problem. A full dump using
fileproviderctl check -f
is only useful if you have time to look through many MB of information, although it did reveal that a fairly standard iCloud setup consists of two separate providers, com.apple.CloudDocs.iCloudDriveFileProvider for iCloud Drive proper, and com.apple.Photos.PhotosFileProvider for Photos library, a distinction I had long suspected.
More practical are
fileproviderctl check -v -o [outputFilePath]
to perform an FPCK check and report those files with problems, or “broken invariants”, and
fileproviderctl repair -v -o [outputFilePath]
which gets FPCK to repair those files with problems.
In all tests I performed here, FPCK failed to complete those tasks, reporting
Error Domain=FPCKDomain Code=65 "(null)"
which was frustrating, and lacked useful information in the log.
I then tried running a check, then a repair, and another check, on iCloud Drive with no problems apparent:
- The first check reported that comparison between what was on disk and “FSSnapshot” in File Provider failed on 23 of 17,470 files.
- The repair claimed to fix four of those, leaving 19 still failing of 17,470 files.
- The final check confirmed those figures of 19 failing of 17,470 files.
Typical errors reported were:
- ~LMD/c{17}s/X{5}0/C{10}3/C{9}n.pchelp/I{4}s/C{10}2.jpg: ❌ Left : is_empty_file
- ~LMD/c{17}s/b{5}1/x{8}t/0{9}s/.{7}e: ❌ Left : has_decmpfs_xattr_but_not_evictable
- ~LMD/c{17}s/b{5}1/2{18}s.txt: ❌ Left : marked_in_pinned_folder_but_not_in_pinned_folder
none of which appeared to make any sense in comparison with what I could see in iCloud Drive.
Reading the log during one of the check tests showed fileproviderd launching FPCK, long runs of entries from the kernel reporting the FPCKService “is decorated as no-materialization”, and checks for FS vs snapshot, Reconciliation Table, reingestion, FS vs FP snapshot, and further reingestion. All were completed in 3.326 seconds, for a very modest iCloud Drive of 6,826 items in just over 2 GB. Quite how FPCK arrived at over 17,000 files I don’t know.
This is consistent with the experience of using fileproviderctl reported by FlohGro when they were trying to fix a problem with fileproviderd.
Conclusion
fileproviderctl and FPCK are an interesting diversion for anyone wanting to explore File Provider. But in their current state they ask more questions than they answer, and other more established fixes remain the most effective. It would be really helpful if Apple could document this.
Postscript
You may be aware of the controversy over the origin of the command tool name fsck, which apparently had a u in place of its s. This appears an appropriate moment to bear that in mind.
