Send again - this time with correct From:
On 5 Nov 2014, at 20:31, Quinn The Eskimo! <eskimo1@apple.com> wrote:
On 5 Nov 2014, at 13:13, Gerriet M. Denkmann <gerriet@mdenkmann.de> wrote:
Any way to observe changes (except from polling, which I am trying to avoid)?
AFAICT ntpd doesn't write to this file, but rather writes to a temporary file and then replaces the original file with a temporary (using <x-man-page://2/rename>). This is a pretty typical 'safe save' technique.
See save_drift_file in the following.
<http://www.opensource.apple.com/source/ntp/ntp-92/ntpd/ntp_util.c>
Ok. But when I observe some other file using dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE) and do a rename, I get a DISPATCH_VNODE_DELETE or DISPATCH_VNODE_RENAME. With ntp.drift I see nothing at all (most of the time).
You can confirm this by checking the inode number of the file over time.
$ ls -li /var/db/ntp.drift 9615173 -rw-r--r-- 1 root wheel 9 4 Nov 09:46 /var/db/ntp.drift
$ date; ls -li /var/db/ntp.drift ; cat /var/db/ntp.drift Wed 5 Nov 2014 21:16:52 ICT 5424511 -rw-r--r--@ 1 root wheel 8 5 Nov 14:59 /var/db/ntp.drift <-- change-time unchanged for 6 hours -20.410 -- wait -- $ date; ls -li /var/db/ntp.drift ; cat /var/db/ntp.drift Wed 5 Nov 2014 21:21:39 ICT 5424511 -rw-r--r--@ 1 root wheel 8 5 Nov 21:21 /var/db/ntp.drift ← inode did NOT change -20.430 ← data did change This is a rare and bad example, because the change-time did actually change. And so I received two DISPATCH_VNODE_ATTRIB events. -- wait another hour -- $ date; ls -li /var/db/ntp.drift ; cat /var/db/ntp.drift Wed 5 Nov 2014 22:25:47 ICT 5424511 -rw-r--r--@ 1 root wheel 8 5 Nov 21:21 /var/db/ntp.drift ← inode did NOT change, nor did change-time -20.434 ← data did change
It [i.e. the inode] should change each time the file is saved.
It should, but it does not.
If this is, indeed, how things work, you'll have to watch for changes to the parent directory and then check the file each time that directory changes.
Good idea. I will try this later.
Also, why do you care about this value? This presence and format of this file isn't really considered API, so hard-coding that into an product that you ship to a wide variety of users would not be wise. Perhaps there's a better approach? Right now this is a private tool for my own amusement.
Kind regards, Gerriet. P.S. I forgot to mention: this is 10.10. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com