Change checkpoint object to using a bitfield
[yaffs2.git] / yaffs_guts.h
index 77bc7e9968c386612d951f818f9e1e627f69c386..b0aca333fe706330bafe0f5ad983ab5b54b3bcf2 100644 (file)
@@ -79,7 +79,6 @@
 
 /* Binary data version stamps */
 #define YAFFS_SUMMARY_VERSION          1
-#define YAFFS_CHECKPOINT_VERSION       7
 
 #ifdef CONFIG_YAFFS_UNICODE
 #define YAFFS_MAX_NAME_LENGTH          127
@@ -167,6 +166,12 @@ enum yaffs_ecc_result {
        YAFFS_ECC_RESULT_UNFIXED
 };
 
+/*
+ * Object type enum:
+ * When this is stored in flash we store it as a u32 instead
+ * to prevent any alignment change issues as compiler variants change.
+ */
+
 enum yaffs_obj_type {
        YAFFS_OBJECT_TYPE_UNKNOWN,
        YAFFS_OBJECT_TYPE_FILE,
@@ -310,7 +315,7 @@ struct yaffs_block_info {
 /* This is the object structure as stored on NAND */
 
 struct yaffs_obj_hdr {
-       enum yaffs_obj_type type;
+       u32 type;  /* enum yaffs_obj_type  */
 
        /* Apply to everything  */
        int parent_obj_id;
@@ -368,9 +373,19 @@ struct yaffs_tnode {
  * - a hard link
  */
 
+/* The file variant has three file sizes:
+ *  - file_size : size of file as written into Yaffs - including data in cache.
+ *  - stored_size - size of file as stored on media.
+ *  - shrink_size - size of file that has been shrunk back to.
+ *
+ * The stored_size and file_size might be different because the data written
+ * into the cache will increase the file_size but the stored_size will only
+ * change when the data is actually stored.
+ *
+ */
 struct yaffs_file_var {
        loff_t file_size;
-       loff_t scanned_size;
+       loff_t stored_size;
        loff_t shrink_size;
        int top_level;
        struct yaffs_tnode *top;
@@ -470,7 +485,7 @@ struct yaffs_obj {
 
        void *my_inode;
 
-       enum yaffs_obj_type variant_type;
+       u32 variant_type; /* enum yaffs_object_type */
 
        union yaffs_obj_var variant;
 
@@ -481,26 +496,6 @@ struct yaffs_obj_bucket {
        int count;
 };
 
-/* yaffs_checkpt_obj holds the definition of an object as dumped
- * by checkpointing.
- */
-
-struct yaffs_checkpt_obj {
-       int struct_type;
-       u32 obj_id;
-       u32 parent_id;
-       int hdr_chunk;
-       enum yaffs_obj_type variant_type:3;
-       u8 deleted:1;
-       u8 soft_del:1;
-       u8 unlinked:1;
-       u8 fake:1;
-       u8 rename_allowed:1;
-       u8 unlink_allowed:1;
-       u8 serial;
-       int n_data_chunks;
-       loff_t size_or_equiv_obj;
-};
 
 /*--------------------- Temporary buffers ----------------
  *
@@ -563,6 +558,8 @@ struct yaffs_param {
                                 * 0 = no limit.
                                */
 
+       int hide_lost_n_found;  /* Set non-zero to hide the lost-n-found dir. */
+
        /* The remove_obj_fn function must be supplied by OS flavours that
         * need it.
         * yaffs direct uses it to implement the faster readdir.
@@ -800,6 +797,37 @@ struct yaffs_dev {
 
 };
 
+/*
+ * Checkpointing definitions.
+ */
+
+#define YAFFS_CHECKPOINT_VERSION       8
+
+/* yaffs_checkpt_obj holds the definition of an object as dumped
+ * by checkpointing.
+ */
+
+
+/*  Checkpint object bits in bitfield: offset, length */
+#define CHECKPOINT_VARIANT_BITS                0, 3
+#define CHECKPOINT_DELETED_BITS                3, 1
+#define CHECKPOINT_SOFT_DEL_BITS       4, 1
+#define CHECKPOINT_UNLINKED_BITS       5, 1
+#define CHECKPOINT_FAKE_BITS           6, 1
+#define CHECKPOINT_RENAME_ALLOWED_BITS 7, 1
+#define CHECKPOINT_UNLINK_ALLOWED_BITS 8, 1
+#define CHECKPOINT_SERIAL_BITS         9, 8
+
+struct yaffs_checkpt_obj {
+       int struct_type;
+       u32 obj_id;
+       u32 parent_id;
+       int hdr_chunk;
+       u32 bit_field;
+       int n_data_chunks;
+       loff_t size_or_equiv_obj;
+};
+
 /* The CheckpointDevice structure holds the device information that changes
  *at runtime and must be preserved over unmount/mount cycles.
  */
@@ -876,10 +904,13 @@ struct yaffs_obj *yaffs_create_file(struct yaffs_obj *parent,
                                    const YCHAR *name, u32 mode, u32 uid,
                                    u32 gid);
 
-int yaffs_flush_file(struct yaffs_obj *obj, int update_time, int data_sync);
+int yaffs_flush_file(struct yaffs_obj *in,
+                    int update_time,
+                    int data_sync,
+                    int discard_cache);
 
 /* Flushing and checkpointing */
-void yaffs_flush_whole_cache(struct yaffs_dev *dev);
+void yaffs_flush_whole_cache(struct yaffs_dev *dev, int discard);
 
 int yaffs_checkpoint_save(struct yaffs_dev *dev);
 int yaffs_checkpoint_restore(struct yaffs_dev *dev);