c94cda2c21d9a5f9790e19d85dd2becc513a5a35
[openafs.git] / src / WINNT / afsd / cm_memmap.h
1 /*
2  * Copyright 2004, Secure Endpoints Inc.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef CM_MEMMAP_H
11 #define CM_MEMMAP_H 1
12
13 #define CM_CONFIG_DATA_VERSION  4
14 #define CM_CONFIG_DATA_MAGIC            ('A' | 'F'<<8 | 'S'<<16 | CM_CONFIG_DATA_VERSION<<24)
15
16 typedef struct cm_config_data {
17     afs_uint32          size;
18     afs_uint32          magic;
19     CHAR *              baseAddress;
20
21     afs_uint32          stats;
22     afs_uint32          chunkSize;
23     afs_uint32          blockSize;
24     afs_uint64          bufferSize;
25     afs_uint32          cacheType;
26     afs_uint32          dirty;
27
28     cm_volume_t *       volumeBaseAddress;
29     cm_cell_t   *       cellBaseAddress; 
30     cm_aclent_t *       aclBaseAddress;
31     cm_scache_t *       scacheBaseAddress;
32     cm_nc_t     *       dnlcBaseAddress;
33     cm_buf_t    *       bufHeaderBaseAddress;
34     char *              bufDataBaseAddress;
35     char *              bufEndOfData;
36
37     cm_volume_t *       allVolumesp;
38     afs_uint32          currentVolumes;
39     afs_uint32          maxVolumes;
40
41     cm_cell_t   *       allCellsp;
42     cm_cell_t   *       freeCellsp;
43     afs_uint32          currentCells;
44     afs_uint32          maxCells;
45
46     cm_volume_t *       rootVolumep;
47     cm_cell_t   *       rootCellp;
48     cm_fid_t            rootFid;
49     cm_scache_t *       rootSCachep;
50     cm_scache_t         fakeSCache;
51     afs_uint64          fakeDirVersion;
52
53     cm_aclent_t *       aclLRUp;
54     cm_aclent_t *       aclLRUEndp;
55
56     cm_scache_t **      scacheHashTablep;
57     afs_uint32          scacheHashTableSize;
58
59     cm_scache_t *       allSCachesp;
60     afs_uint32          currentSCaches;
61     afs_uint32          maxSCaches;
62     cm_scache_t *       scacheLRUFirstp;
63     cm_scache_t *       scacheLRULastp;
64
65     cm_cell_t   **      cellNameHashTablep;
66     cm_cell_t   **      cellIDHashTablep;
67     afs_uint32          cellHashTableSize;
68
69     cm_volume_t **      volumeNameHashTablep;
70     cm_volume_t **      volumeRWIDHashTablep;
71     cm_volume_t **      volumeROIDHashTablep;
72     cm_volume_t **      volumeBKIDHashTablep;
73     afs_uint32          volumeHashTableSize;
74     cm_volume_t *       volumeLRUFirstp;
75     cm_volume_t *       volumeLRULastp;
76
77     cm_nc_t     *       ncfreelist;
78     cm_nc_t     *       nameCache;
79     cm_nc_t     **      nameHash; 
80
81     cm_buf_t    *       buf_freeListp;
82     cm_buf_t    *       buf_freeListEndp;
83     cm_buf_t    *       buf_dirtyListp;
84     cm_buf_t    *       buf_dirtyListEndp;
85     cm_buf_t    **      buf_scacheHashTablepp;
86     cm_buf_t    **      buf_fileHashTablepp;
87     cm_buf_t    *       buf_allp;
88     afs_uint64          buf_nbuffers;
89     afs_uint32          buf_blockSize;
90     afs_uint32          buf_hashSize;
91     afs_uint64          buf_nOrigBuffers;
92     afs_uint64          buf_reservedBufs;
93     afs_uint64          buf_maxReservedBufs;
94     afs_uint64          buf_reserveWaiting;
95
96     time_t              mountRootGen;
97     afsUUID             Uuid;
98     DWORD               volSerialNumber;
99     CHAR                Sid[6 * sizeof(DWORD)];
100 } cm_config_data_t;
101
102 extern cm_config_data_t cm_data;
103
104 afs_uint64 GranularityAdjustment(afs_uint64 size);
105 afs_uint64 ComputeSizeOfConfigData(void);
106 afs_uint64 ComputeSizeOfVolumes(DWORD maxvols);
107 afs_uint64 ComputeSizeOfCells(DWORD maxcells);
108 afs_uint64 ComputeSizeOfACLCache(DWORD stats);
109 afs_uint64 ComputeSizeOfSCache(DWORD stats);
110 afs_uint64 ComputeSizeOfSCacheHT(DWORD stats);
111 afs_uint64 ComputeSizeOfDNLCache(void);
112 afs_uint64 ComputeSizeOfDataBuffers(afs_uint64 cacheBlocks, DWORD blockSize);
113 afs_uint64 ComputeSizeOfDataHT(afs_uint64 cacheBlocks);
114 afs_uint64 ComputeSizeOfDataHeaders(afs_uint64 cacheBlocks);
115 afs_uint64 ComputeSizeOfMappingFile(DWORD stats, DWORD maxVols, DWORD maxCells, DWORD chunkSize, afs_uint64 cacheBlocks, DWORD blockSize);
116 PSECURITY_ATTRIBUTES CreateCacheFileSA();
117 VOID  FreeCacheFileSA(PSECURITY_ATTRIBUTES psa);
118 int   cm_ShutdownMappedMemory(void);
119 int   cm_ValidateMappedMemory(char * cachePath);
120 int   cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD maxVols, DWORD maxCells, DWORD chunkSize, afs_uint64 cacheBlocks, afs_uint32 blockSize);
121 #endif /* CM_MEMMAP_H */