ad90a511eaeb0f76d9f3094e0b43a023cfb86005
[captive.git] / src / libcaptive / cc / misc.c
1 /* $Id$
2  * reactos Cache Manager (Cc*) misc 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 #include "config.h"
21
22 #include <glib/gmessages.h>
23 #include "reactos/ddk/status.h"
24 #include "reactos/ddk/iotypes.h"
25 #include "sharedcachemap.h"
26
27
28 /**
29  * CcCanIWrite:
30  * @FileObject: Initialized open #FileObject to map.
31  * %NULL value is forbidden.
32  * @BytesToWrite: Amount of data to be asked whether it will be accepted.
33  * Value %0 is permitted.
34  * @Wait: Whether disk waiting would be permitted during the forthcoming write call.
35  * @Retrying: Use %TRUE iff calling this function for the second and further times for one request.
36  *
37  * Asks cache manager if it would currently accept write request to @FileObject
38  * of @BytesToWrite bytes with @Wait condition.
39  * libcaptive will always accept any writes. This function is a NOP.
40  *
41  * Returns: libcaptive always returns %TRUE.
42  */
43 BOOLEAN CcCanIWrite(IN PFILE_OBJECT FileObject,IN ULONG BytesToWrite,IN BOOLEAN Wait,IN BOOLEAN Retrying)
44 {
45         g_return_val_if_fail(FileObject!=NULL,FALSE);
46         g_return_val_if_fail(Wait==TRUE || Wait==FALSE,FALSE);  /* Prevent 'Wait' upgrade to 'Flags'. */
47         g_return_val_if_fail(Retrying==TRUE || Retrying==FALSE,FALSE);
48
49         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: FileObject=%p,BytesToWrite=0x%lX,Wait=%d,Retrying=%d",G_STRLOC,
50                         FileObject,(gulong)BytesToWrite,(gint)Wait,(gint)Retrying);
51
52         /* sanity check */
53         captive_FileObject_to_SharedCacheMap(FileObject);
54
55         return TRUE;
56 }
57
58
59 /**
60  * CcSetReadAheadGranularity:
61  * @FileObject: Initialized open #FileObject to map.
62  * %NULL value is forbidden.
63  * @Granularity: Suggested size of the cache element.
64  * Value must be larger or requal to %PAGE_SIZE and it must be even power of two.
65  *
66  * libcaptive does not implement any caching and therefore this function
67  * is a NOP there.
68  */
69 VOID CcSetReadAheadGranularity(IN PFILE_OBJECT FileObject,IN ULONG Granularity)
70 {
71         g_return_if_fail(FileObject!=NULL);
72         g_return_if_fail(Granularity>=PAGE_SIZE);
73         g_return_if_fail((Granularity&(Granularity-1))==0);     /* Power of two */
74
75         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: FileObject=%p,Granularity=0x%lX",G_STRLOC,
76                         FileObject,(gulong)Granularity);
77
78         /* NOP; no caching by libcaptive */
79
80         /* sanity check */
81         captive_FileObject_to_SharedCacheMap(FileObject);
82 }
83
84
85 /**
86  * CcSetAdditionalCacheAttributes:
87  * @FileObject: Initialized open #FileObject to map.
88  * %NULL value is forbidden.
89  * @DisableReadAhead: Read-ahead should not be done by Cache Manager.
90  * @DisableWriteBehind: Write-behind should not be done by Cache Manager.
91  *
92  * libcaptive does not implement any caching and therefore this function
93  * is a NOP there.
94  */
95 VOID CcSetAdditionalCacheAttributes(IN PFILE_OBJECT FileObject,IN BOOLEAN DisableReadAhead,IN BOOLEAN DisableWriteBehind)
96 {
97         g_return_if_fail(FileObject!=NULL);
98
99         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: FileObject=%p,DisableReadAhead=%s,DisableWriteBehind=%s",G_STRLOC,
100                         FileObject,(DisableReadAhead ? "TRUE" : "FALSE"),(DisableWriteBehind ? "TRUE" : "FALSE"));
101
102         /* NOP; no caching by libcaptive */
103 }
104
105
106 VOID FsRtlIncrementCcFastReadNoWait(VOID)
107 {
108         /* FIXME: {{%fs:[0]}+0x4E0}:LONG++ */
109 }
110
111
112 NTSTATUS CcWaitForCurrentLazyWriterActivity(VOID)
113 {
114         return STATUS_SUCCESS;
115 }