• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: file changes content but ContentModificationDate not changing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file changes content but ContentModificationDate not changing


  • Subject: Re: file changes content but ContentModificationDate not changing
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Wed, 05 Nov 2014 23:43:30 +0700

Send again - this time with correct From:

> On 5 Nov 2014, at 20:31, Quinn The Eskimo! <email@hidden> wrote:
>
>
> On 5 Nov 2014, at 13:13, Gerriet M. Denkmann <email@hidden> 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      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: file changes content but ContentModificationDate not changing
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
References: 
 >file changes content but ContentModificationDate not changing (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: file changes content but ContentModificationDate not changing (From: "Quinn \"The Eskimo!\"" <email@hidden>)

  • Prev by Date: Re: file changes content but ContentModificationDate not changing
  • Next by Date: Re: file changes content but ContentModificationDate not changing
  • Previous by thread: Re: file changes content but ContentModificationDate not changing
  • Next by thread: Re: file changes content but ContentModificationDate not changing
  • Index(es):
    • Date
    • Thread