]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfs.h
xnu-1228.15.4.tar.gz
[apple/xnu.git] / bsd / hfs / hfs.h
index cfed9e65dee611b3cf59128ed2d541696c5ae135..5bb4ec9200f11a73b8a79bde7ef71da3e72ae494 100644 (file)
@@ -46,6 +46,7 @@
 #include <sys/quota.h>
 #include <sys/dirent.h>
 #include <sys/event.h>
+#include <kern/thread_call.h>
 
 #include <kern/locks.h>
 
@@ -266,13 +267,40 @@ typedef struct hfsmount {
 
        lck_mtx_t      hfs_mutex;      /* protects access to hfsmount data */
        void          *hfs_freezing_proc;  /* who froze the fs */
+       void          *hfs_downgrading_proc; /* process who's downgrading to rdonly */
        lck_rw_t       hfs_insync;     /* protects sync/freeze interaction */
 
        /* Resize variables: */
        u_int32_t               hfs_resize_filesmoved;
        u_int32_t               hfs_resize_totalfiles;
+
+       /*
+        * About the sync counters:
+        * hfs_sync_scheduled  keeps track whether a timer was scheduled but we
+        *                     haven't started processing the callback (i.e. we
+        *                     haven't begun the flush).  This will be non-zero
+        *                     even if the callback has been invoked, before we
+        *                    start the flush.
+        * hfs_sync_incomplete keeps track of the number of callbacks that have
+        *                     not completed yet (including callbacks not yet
+        *                     invoked).  We cannot safely unmount until this
+        *                     drops to zero.
+        *
+        * In both cases, we use counters, not flags, so that we can avoid
+        * taking locks.
+        */
+       int32_t         hfs_sync_scheduled;
+       int32_t         hfs_sync_incomplete;
+       u_int64_t       hfs_last_sync_request_time;
+       u_int64_t       hfs_last_sync_time;
+       uint32_t        hfs_active_threads;
+       thread_call_t   hfs_syncer;           // removeable devices get sync'ed by this guy
+
 } hfsmount_t;
 
+#define HFS_META_DELAY     (100)
+#define HFS_MILLISEC_SCALE (1000*1000)
+
 typedef hfsmount_t  ExtendedVCB;
 
 /* Aliases for legacy (Mac OS 9) field names */
@@ -341,6 +369,9 @@ enum privdirtype {FILE_HARDLINKS, DIR_HARDLINKS};
 #define HFS_VIRTUAL_DEVICE        0x20000
 /* When set, we're in hfs_changefs, so hfs_sync should do nothing. */
 #define HFS_IN_CHANGEFS           0x40000
+/* When set, we are in process of downgrading or have downgraded to read-only, 
+ * so hfs_start_transaction should return EROFS. */
+#define HFS_RDONLY_DOWNGRADE      0x80000
 
 
 /* Macro to update next allocation block in the HFS mount structure.  If 
@@ -685,6 +716,7 @@ extern int  hfs_virtualmetafile(struct cnode *);
 
 extern int hfs_start_transaction(struct hfsmount *hfsmp);
 extern int hfs_end_transaction(struct hfsmount *hfsmp);
+extern void hfs_sync_ejectable(struct hfsmount *hfsmp);
 
 
 /*****************************************************************************