Annotation of ntddk/src/comm/serial/qsfile.c, revision 1.1.1.1

1.1       root        1: /*++
                      2: 
                      3: Copyright (c) 1991, 1992, 1993 Microsoft Corporation
                      4: 
                      5: Module Name:
                      6: 
                      7:     qsfile.c
                      8: 
                      9: Abstract:
                     10: 
                     11:     This module contains the code that is very specific to query/set file
                     12:     operations in the serial driver.
                     13: 
                     14: Author:
                     15: 
                     16:     Anthony V. Ercolano 26-Sep-1991
                     17: 
                     18: Environment:
                     19: 
                     20:     Kernel mode
                     21: 
                     22: Revision History :
                     23: 
                     24: --*/
                     25: 
                     26: #include <stddef.h>
                     27: #include "ntddk.h"
                     28: #include "ntddser.h"
                     29: #include "serial.h"
                     30: #include "serialp.h"
                     31: 
                     32: 
                     33: NTSTATUS
                     34: SerialQueryInformationFile(
                     35:     IN PDEVICE_OBJECT DeviceObject,
                     36:     IN PIRP Irp
                     37:     )
                     38: 
                     39: /*++
                     40: 
                     41: Routine Description:
                     42: 
                     43:     This routine is used to query the end of file information on
                     44:     the opened serial port.  Any other file information request
                     45:     is retured with an invalid parameter.
                     46: 
                     47:     This routine always returns an end of file of 0.
                     48: 
                     49: Arguments:
                     50: 
                     51:     DeviceObject - Pointer to the device object for this device
                     52: 
                     53:     Irp - Pointer to the IRP for the current request
                     54: 
                     55: Return Value:
                     56: 
                     57:     The function value is the final status of the call
                     58: 
                     59: --*/
                     60: 
                     61: {
                     62:     //
                     63:     // The status that gets returned to the caller and
                     64:     // set in the Irp.
                     65:     //
                     66:     NTSTATUS Status;
                     67: 
                     68:     //
                     69:     // The current stack location.  This contains all of the
                     70:     // information we need to process this particular request.
                     71:     //
                     72:     PIO_STACK_LOCATION IrpSp;
                     73: 
                     74:     UNREFERENCED_PARAMETER(DeviceObject);
                     75: 
                     76:     SerialDump(
                     77:         SERIRPPATH,
                     78:         ("SERIAL: Dispatch entry for: %x\n",Irp)
                     79:         );
                     80:     if (SerialCompleteIfError(
                     81:             DeviceObject,
                     82:             Irp
                     83:             ) != STATUS_SUCCESS) {
                     84: 
                     85:         return STATUS_CANCELLED;
                     86: 
                     87:     }
                     88:     IrpSp = IoGetCurrentIrpStackLocation(Irp);
                     89:     Irp->IoStatus.Information = 0L;
                     90:     Status = STATUS_SUCCESS;
                     91:     if (IrpSp->Parameters.QueryFile.FileInformationClass ==
                     92:         FileStandardInformation) {
                     93: 
                     94:         PFILE_STANDARD_INFORMATION Buf = Irp->AssociatedIrp.SystemBuffer;
                     95: 
                     96:         Buf->AllocationSize = RtlConvertUlongToLargeInteger(0ul);
                     97:         Buf->EndOfFile = Buf->AllocationSize;
                     98:         Buf->NumberOfLinks = 0;
                     99:         Buf->DeletePending = FALSE;
                    100:         Buf->Directory = FALSE;
                    101:         Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
                    102: 
                    103:     } else if (IrpSp->Parameters.QueryFile.FileInformationClass ==
                    104:                FilePositionInformation) {
                    105: 
                    106:         ((PFILE_POSITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer)->
                    107:             CurrentByteOffset = RtlConvertUlongToLargeInteger(0ul);
                    108:         Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
                    109: 
                    110:     } else {
                    111: 
                    112:         Status = STATUS_INVALID_PARAMETER;
                    113: 
                    114:     }
                    115: 
                    116:     SerialDump(
                    117:         SERIRPPATH,
                    118:         ("SERIAL: Complete Irp: %x\n",Irp)
                    119:         );
                    120:     IoCompleteRequest(
                    121:         Irp,
                    122:         0
                    123:         );
                    124: 
                    125:     return Status;
                    126: 
                    127: }
                    128: 
                    129: NTSTATUS
                    130: SerialSetInformationFile(
                    131:     IN PDEVICE_OBJECT DeviceObject,
                    132:     IN PIRP Irp
                    133:     )
                    134: 
                    135: /*++
                    136: 
                    137: Routine Description:
                    138: 
                    139:     This routine is used to set the end of file information on
                    140:     the opened parallel port.  Any other file information request
                    141:     is retured with an invalid parameter.
                    142: 
                    143:     This routine always ignores the actual end of file since
                    144:     the query information code always returns an end of file of 0.
                    145: 
                    146: Arguments:
                    147: 
                    148:     DeviceObject - Pointer to the device object for this device
                    149: 
                    150:     Irp - Pointer to the IRP for the current request
                    151: 
                    152: Return Value:
                    153: 
                    154: The function value is the final status of the call
                    155: 
                    156: --*/
                    157: 
                    158: {
                    159:     //
                    160:     // The status that gets returned to the caller and
                    161:     // set in the Irp.
                    162:     //
                    163:     NTSTATUS Status;
                    164: 
                    165:     UNREFERENCED_PARAMETER(DeviceObject);
                    166: 
                    167:     SerialDump(
                    168:         SERIRPPATH,
                    169:         ("SERIAL: Dispatch entry for: %x\n",Irp)
                    170:         );
                    171:     if (SerialCompleteIfError(
                    172:             DeviceObject,
                    173:             Irp
                    174:             ) != STATUS_SUCCESS) {
                    175: 
                    176:         return STATUS_CANCELLED;
                    177: 
                    178:     }
                    179:     Irp->IoStatus.Information = 0L;
                    180:     if ((IoGetCurrentIrpStackLocation(Irp)->
                    181:             Parameters.SetFile.FileInformationClass ==
                    182:          FileEndOfFileInformation) ||
                    183:         (IoGetCurrentIrpStackLocation(Irp)->
                    184:             Parameters.SetFile.FileInformationClass ==
                    185:          FileAllocationInformation)) {
                    186: 
                    187:         Status = STATUS_SUCCESS;
                    188: 
                    189:     } else {
                    190: 
                    191:         Status = STATUS_INVALID_PARAMETER;
                    192: 
                    193:     }
                    194: 
                    195:     Irp->IoStatus.Status = Status;
                    196: 
                    197:     SerialDump(
                    198:         SERIRPPATH,
                    199:         ("SERIAL: Complete Irp: %x\n",Irp)
                    200:         );
                    201:     IoCompleteRequest(
                    202:         Irp,
                    203:         0
                    204:         );
                    205: 
                    206:     return Status;
                    207: 
                    208: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.