-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invariant Disks #258
Invariant Disks #258
Conversation
InvariantDisks is a small program maintaining a mapping from invariant labels to the potentially varying /dev/disk* entries. Only the CLI skeleton and other infrastructure exists.
The DiskArbitrationDispatcher dispatches appearance and disappearance events from disks to the registered handlers. The log handler just logs the disks with the aid of the disk arbitration utilities.
This program is licensed under a "3-Clause BSD" license.
Renamed from DiskArbitrationLogger, which is a very unwieldy name.
Create symlinks from a media path derived link to the associated dev files. This is only possible for disks that have an IODeviceTree media path.
Also extract the volume path and the media content keys from the DADiskRef. An IOKit dictionary is also created as preparation for additional information demand.
More details, and using the correct project name.
Use 755 instead of 744 when creating new directories, which gives list rights to group and others as well. Simplified directory creation code. Dead code is not needed.
Only create a DiskInformation object once per DADiskRef in the dispatcher. That allows DiskArbitrationHandler to reuse the information which improves efficiency.
Make the logging much more readable, with just one data element per line.
Links disks/volumes by media/volume/device ID. I am unclear what the various IDs imply, but disk images have volume UUIDs, while normal volumes and core-storage volumes have both media and volume UUIDs, and some volumes only have media UUIDs.
Add the device serial number and some flags to the DiskInformation object. The serial number is available in all devices, volumes and even core storage devices on a particular device. The device model is also available.
Links whole disks by their device serial number. The model and serial number are both used in the symlinks for more human readability. There is no straight-forward way to identify physical whole disks, but the implemented heuristic seems to work well.
The new features are now properly described in the readme file.
Instead of checking for potential issues with symlink creation/ removal, just try it and handle the errors. The errors are now also made more human readable.
The verbosity of the logging can now be changed by adding -v. By default, the Program is significantly less talkative.
Command line parsing is now more scalable and more reliable. A map of Handler for the command line flags replaces counting and searching in the flags. Not quite boost::program_options but ...
263b4c5
to
13be1eb
Compare
Cool - one question, can the launchd plist specify a dependency to load prior zpool import? Or if it already does so, is it simply loading the service/plist by lexicographical / alphabetical order? e.g.
I haven't had the time to complete it, but I have on multiple occasions begun porting find_by_guid into vdev_disk - using minimally IOKit c++ to locate disks, and only in the case of a mismatch. On one hand the end result is almost the same, except the output of |
@evansus I don't think launchd supports dependencies in that way, but perhaps we could have import all wait for a cookie file that invariant disks could place in /tmp after its first run as we do with zfs_util: Other ideas? @evansus have you tried invariant + vdev_iokit yet? |
@ilovezfs Sounds good, I just checked out the Mac developer reference on launchd and I see that this is the recommended behavior. And to answer the other question, no, but I already determined that additional work is needed for it to resolve the symlink to the disk device. vdev-iokit currently does not handle symlinks properly. I haven't needed it, with the find_by_guid logic, but it does mean that |
Partitions are now also linked in by-serial, with a media-path style colon + partitionId suffix. This allows using stable IDs without a fixed partitioning scheme.
A tiny bit more consistency.
In addition to the 3-Clause BSD License, also license under the CDDL.
e811605
to
e9b95eb
Compare
Apparently there's no clear Standard on how to label Serial Numbers, so try different strings, and just take the first.
Don't try to trim if there's nothing found to keep. This would lead to an out-of-bounds exception.
The new idle handler can do things when DiskArbitration has not given any new disks in a user-defined time span. This uses a timer dispatch source, so some of the dispatch related code was moved into its own files.
Create a file to allow scripts and other API limited entities to detect if InvariantDisk has been idle. The file is deleted when ever disk changes happen, and created after the idle timeout has passed.
Only use non-empty model names for generating a serial number. Do not format and link a serial number if the serial number is not sufficiently non-empty.
Correctly pass through empty serials as empty, so they can later be ignored.
No description provided.