+static inline bool hfs_should_save_atime(cnode_t *cp)
+{
+ /*
+ * We only write atime updates to disk if the delta is greater
+ * than ATIME_ONDISK_ACCURACY.
+ */
+ return (cp->c_atime < cp->c_attr.ca_atimeondisk
+ || cp->c_atime - cp->c_attr.ca_atimeondisk > ATIME_ONDISK_ACCURACY);
+}
+
+typedef enum {
+ HFS_NOT_DIRTY = 0,
+ HFS_DIRTY = 1,
+ HFS_DIRTY_ATIME = 2
+} hfs_dirty_t;
+
+static inline hfs_dirty_t hfs_is_dirty(cnode_t *cp)
+{
+ if (ISSET(cp->c_flag, C_NOEXISTS))
+ return HFS_NOT_DIRTY;
+
+ if (ISSET(cp->c_flag, C_MODIFIED | C_MINOR_MOD | C_NEEDS_DATEADDED)
+ || cp->c_touch_chgtime || cp->c_touch_modtime) {
+ return HFS_DIRTY;
+ }
+
+ if (cp->c_touch_acctime || hfs_should_save_atime(cp))
+ return HFS_DIRTY_ATIME;
+
+ return HFS_NOT_DIRTY;
+}