2 * reactos Cache Manager (Cc*) map/pin Bcb CcRepin*() 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 "privatebcb.h"
23 #include "reactos/ddk/status.h"
24 #include "privatebcbpin.h"
29 * @Bcb: #PUBLIB_BCB to be repinned.
30 * %NULL value is forbidden.
32 * Increases usecount on @Bcb. You must call CcUnpinRepinnedBcb() for such @Bcb
33 * afterwards before returning from the #IRP handling.
35 * libcaptive does not differentiate between CcUnpinData() and CcUnpinRepinnedBcb().
38 * This call does not set the buffer as dirty - such buffer will not be flushed automatically.
41 VOID CcRepinBcb(IN PVOID Bcb)
43 CaptivePrivateBcbObject *captive_private_bcb_object;
45 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"enter: CcRepinBcb: Bcb=0x%lX",(long)Bcb);
47 g_return_if_fail(Bcb!=NULL);
49 captive_private_bcb_object=captive_PublicBcb_to_PrivateBcbObject(Bcb);
51 g_object_ref(captive_private_bcb_object);
53 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"leave: CcRepinBcb");
59 * @Bcb: #PUBLIB_BCB to be unpinned from CcRepinBcb().
60 * %NULL value is forbidden.
61 * @WriteThrough: %TRUE if the buffer should be flushed before finishing this function.
62 * @IoStatus: #PIO_STATUS_BLOCK to return status of this operation.
63 * %NULL value is forbidden. libcaptive always returns %STATUS_SUCCESS here.
65 * Dereferencing of @Bcb after application of CcRepinBcb().
67 * This call does not set the buffer as dirty although it will flush the buffers
68 * already set as dirty. Any flushes will be postponed after return from #IRP
69 * handling by the filesystem driver if not requested to be synchronous by @WriteThrough.
71 VOID CcUnpinRepinnedBcb(IN PVOID Bcb,IN BOOLEAN WriteThrough,IN PIO_STATUS_BLOCK IoStatus)
73 CaptivePrivateBcbObject *captive_private_bcb_object;
75 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"enter: CcUnpinRepinnedBcb: Bcb=0x%lX,WriteThrough=%d",
76 (long)Bcb,WriteThrough);
78 g_return_if_fail(Bcb!=NULL);
79 g_return_if_fail(IoStatus!=NULL);
81 captive_private_bcb_object=captive_PublicBcb_to_PrivateBcbObject(Bcb);
83 IoStatus->Status=STATUS_SUCCESS;
84 IoStatus->Information=0;
86 if (WriteThrough) { /* FIXME: WriteThrough even if we do not do the last unref? */
87 CaptivePrivateBcbPinObject *captive_private_bcb_pin_object;
89 captive_private_bcb_pin_object=CAPTIVE_PRIVATE_BCB_PIN_OBJECT(captive_private_bcb_object);
90 if (captive_private_bcb_pin_object_is_dirty(captive_private_bcb_pin_object)) {
91 captive_private_bcb_pin_object_flush(captive_private_bcb_pin_object);
92 IoStatus->Information=PAGE_SIZE;
96 g_object_unref(captive_private_bcb_object);
98 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"leave: CcUnpinRepinnedBcb: IoStatus->Status=0x%lX,IoStatus->Information=0x%lX",
99 (!IoStatus ? -1 : (long)IoStatus->Status),(!IoStatus ? -1 : (long)IoStatus->Information));