summaryrefslogtreecommitdiffstats
path: root/private/ntos/raw/readwrit.c
blob: c82946a1d834e8cf925fc012bf3f8c4ed88f24a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*++

Copyright (c) 1989  Microsoft Corporation

Module Name:

    ReadWrit.c

Abstract:

    This module implements the File Read and Write routines called by the
    dispatch driver.

Author:

    David Goebel      [DavidGoe]      28-Feb-1991

Revision History:

--*/

#include "RawProcs.h"

#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, RawReadWriteDeviceControl)
#endif

NTSTATUS
RawReadWriteDeviceControl (
    IN PVCB Vcb,
    IN PIRP Irp,
    IN PIO_STACK_LOCATION IrpSp
    )

/*++

Routine Description:

    This is the a common routine for both reading and writing a volume.

Arguments:

    Vcb - Supplies the volume being queried.

    Irp - Supplies the Irp to process

    IrpSp - Supplies parameters describing the read or write

Return Value:

    NTSTATUS - The return status for the operation

--*/

{
    PIO_STACK_LOCATION NextIrpSp;
    NTSTATUS Status;

    PAGED_CODE();

    //
    //  If this was for a zero byte read or write transfer, just complete
    //  it with success.
    //

    if (((IrpSp->MajorFunction == IRP_MJ_READ) ||
         (IrpSp->MajorFunction == IRP_MJ_WRITE)) &&
        (IrpSp->Parameters.Read.Length == 0)) {

        RawCompleteRequest( Irp, STATUS_SUCCESS );

        return STATUS_SUCCESS;
    }

    //
    //  This is a very simple operation.  Simply forward the
    //  request to the device driver since exact blocks are
    //  being read and return whatever status was given.
    //
    //  Get the next stack location, and copy over the stack location
    //

    NextIrpSp = IoGetNextIrpStackLocation( Irp );

    *NextIrpSp = *IrpSp;

    //
    //  Prohibit verifies all together.
    //

    NextIrpSp->Flags |= SL_OVERRIDE_VERIFY_VOLUME;

    //
    //  Set up the completion routine
    //

    IoSetCompletionRoutine( Irp,
                            RawCompletionRoutine,
                            NULL,
                            TRUE,
                            TRUE,
                            TRUE );

    //
    //  Send the request.
    //

    Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);

    return Status;

}