2 * reactos Cache Manager (Cc*) cache handling of libcaptive
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
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
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.
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
22 #include "privatebcbpin.h"
23 #include "reactos/ddk/status.h"
27 * CcPurgeCacheSection:
28 * @SectionObjectPointer: Pointer specifying file to purge;
29 * %NULL value is forbidden.
30 * libcaptive interprets only #SharedCacheMap field as #PUBLIC_BCB pointer.
31 * Field #SharedCacheMap value %NULL is permitted; libcaptive does a NOP with %TRUE return code in such case.
32 * @FileOffset: Starting offset of the ranger to purge.
33 * %NULL pointer is permitted and it means to purge the whole whole.
34 * FIXME: Non %NULL pointer is NOT IMPLEMENTED YET by libcaptive.
35 * @Length: Length of the range to purge. Ignored if @FileOffset==NULL.
36 * @UninitializeCacheMaps: Purge also private cache maps (FIXME: ???).
38 * Drop any caching for shrunken file which is not being deleted.
39 * libcaptive will no longer consider such #BCB as dirty.
41 * Undocumented: It is required during %FSCTL_LOCK_VOLUME by ntfs.sys of NT-5.1sp1
42 * to return %TRUE value if #SharedCacheMap value is %NULL.
44 * Returns: %TRUE if the range was purged successfuly.
46 BOOLEAN CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
47 IN PLARGE_INTEGER FileOffset OPTIONAL,IN ULONG Length,IN BOOLEAN UninitializeCacheMaps)
49 CaptiveSharedCacheMapObject *SharedCacheMap;
51 g_return_val_if_fail(SectionObjectPointer!=NULL,FALSE);
52 g_return_val_if_fail(FileOffset==NULL,FALSE); /* NOT IMPLEMENTED YET */
53 g_return_val_if_fail(UninitializeCacheMaps==0,FALSE); /* NOT IMPLEMENTED YET */
55 SharedCacheMap=captive_SectionObjectPointers_to_SharedCacheMap(SectionObjectPointer);
57 captive_shared_cache_map_purge(SharedCacheMap);
65 * @SectionObjectPointer: Pointer specifying file to flush;
66 * %NULL value is forbidden.
67 * libcaptive interprets only #SharedCacheMap field as #PUBLIC_BCB pointer.
68 * Field #SharedCacheMap value %NULL is permitted; libcaptive does a NOP in such case.
69 * @FileOffset: Optional starting point of the range to flush.
70 * %NULL value is permitted.
71 * @Length: Length of the range to flush. Ignored if @FileOffset is %NULL.
72 * @IoStatus: Optionally returns the resulting operation status.
73 * #Information field will contain the number of bytes flushed.
74 * %NULL value is permitted.
76 * Flushes out any pending dirty data in cache manager BCB mapping.
77 * FIXME: libcaptive currently always flushes the full file ignoring any @FileOffset or @Length.
79 * VERIFIED: Ranged flushes.
80 * VERIFIED: Synchronous write.
82 VOID CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
83 IN PLARGE_INTEGER FileOffset OPTIONAL,IN ULONG Length,OUT PIO_STATUS_BLOCK IoStatus OPTIONAL)
85 CaptiveSharedCacheMapObject *SharedCacheMap;
88 g_return_if_fail(SectionObjectPointer!=NULL);
90 SharedCacheMap=captive_SectionObjectPointers_to_SharedCacheMap(SectionObjectPointer);
93 flushed=captive_shared_cache_map_flush(SharedCacheMap,FileOffset->QuadPart,FileOffset->QuadPart+Length);
95 flushed=captive_shared_cache_map_flush(SharedCacheMap,0,G_MAXUINT64-1); /* '-1' for overflow safety */
98 IoStatus->Status=STATUS_SUCCESS;
99 IoStatus->Information=flushed;
104 BOOLEAN CcIsThereDirtyData(IN PVPB Vpb)
106 g_return_val_if_fail(Vpb!=NULL,FALSE); /* We have just one volume mounted anyway. */
108 return captive_shared_cache_map_is_any_dirty();