Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / libcaptive / cc / sharedcachemap-priv.h
1 /* $Id$
2  * Object-private include file for reactos Cache Manager (Cc*) SharedCacheMap structure of libcaptive
3  * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #ifndef _CAPTIVE_CC_SHARED_CACHE_MAP_PRIV_H
21 #define _CAPTIVE_CC_SHARED_CACHE_MAP_PRIV_H 1
22
23
24 #include <glib/gmacros.h>
25 #include <glib-object.h>
26 #include "reactos/ddk/cctypes.h"
27 #include "privatebcbmap.h"
28
29
30 G_BEGIN_DECLS
31
32 typedef struct _CaptiveSharedCacheMapObject_page CaptiveSharedCacheMapObject_page;
33
34 struct _CaptiveSharedCacheMapObject_page {
35         gboolean data_valid;
36         gboolean dirty;
37         gint64 lsn_oldest,lsn_newest;
38         };
39
40 struct _CaptiveSharedCacheMapObject {
41         GObject parent_instance;
42
43         gint w32_ref_count;
44         FILE_OBJECT *FileObject;
45         SECTION_OBJECT_POINTERS *SectionObjectPointer;
46         /* ValidDataLength<=FileSize<=AllocationSize */
47         /* 'AllocationSize' sets the mmap(2)ed area of buffers of this SharedCacheMap.
48          * We must reallocate this area if 'AllocationSize' changes and in such case
49          * there must exist no map-Bcb or pin-Bcbs for it.
50          * We would cope with 'buffer' change with existing Bcbs but W32 client could not.
51          */
52         guint64 AllocationSize; /* ==CC_FILE_SIZES.AllocationSize.QuadPart */
53         /* We generally check against CAPTIVE_ROUND_UP64(FileSize,PAGE_SIZE)
54          * as the offsets are usually PAGE_SIZE aligned due to pin-Bcb expectations.
55          */
56         guint64 FileSize;       /* ==CC_FILE_SIZES.FileSize.QuadPart */
57         /* We use do not use 'ValidDataLength' as I assume W32
58          * automatically increases 'ValidDataLength' during Cache Manager write operations.
59          * We do not increase it and therefore it is mostly useless for us.
60          * In some cases (during NTFS mount) there may be also invalid 'ValidDataLength' at all:
61          *      CcSetFileSizes(AllocationSize=0x1000000,FileSize=0xf80208,ValidDataLength=0x23b801a0)
62          */
63         guint64 ValidDataLength;        /* ==CC_FILE_SIZES.ValidDataLength.QuadPart */
64         /* The real allocation size of 'buffer' and 'pages'.
65          * Maintained by captive_shared_cache_map_object_FileSizes_changed()
66          * to prevent continous reallocation to (n+1) size.
67          * We use (n*2) sizes for logaritmic time complexity.
68          */
69         guint64 alloc_length;
70         CACHE_MANAGER_CALLBACKS CallBacks;
71         VOID *LazyWriterContext;
72         gboolean PinAccess;
73         CaptivePrivateBcbMapObject *map;        /* 'map' will g_object_ref(CaptiveSharedCacheMapObject). */
74         GHashTable *pin_hash;   /* map: (guint64 *) -> (CaptivePrivateBcbPinObject *) */
75         gboolean LogHandle_set;
76         gboolean FlushToLsnRoutine_set;
77
78         gpointer buffer;        /* FileOffset 0 based */
79         CaptiveSharedCacheMapObject_page *pages;        /* FileOffset 0 based, item corresponds to 'buffer' PAGE_SIZE */
80         };
81 struct _CaptiveSharedCacheMapObjectClass {
82         GObjectClass parent_class;
83
84         void (*FileSizes_changed)(CaptiveSharedCacheMapObject *captive_shared_cache_map_object,
85                         guint64 AllocationSize,guint64 FileSize,guint64 ValidDataLength);
86         void (*purge)(CaptiveSharedCacheMapObject *captive_shared_cache_map_object);
87         };
88
89 G_END_DECLS
90
91
92 #endif /* _CAPTIVE_CC_SHARED_CACHE_MAP_PRIV_H */