Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. openstrm.c
  5. Abstract:
  6. This module implements the STREAMS APIs, s_open() and OpenStream().
  7. Author:
  8. Sam Patton (sampa) November, 1991
  9. Eric Chin (ericc) July 17, 1992
  10. Revision History:
  11. --*/
  12. #include "common.h"
  13. HANDLE
  14. s_open(
  15. IN char *path,
  16. IN int oflag,
  17. IN int ignored
  18. )
  19. /*++
  20. Routine Description:
  21. This function opens a stream.
  22. Arguments:
  23. path - path to the STREAMS driver
  24. oflag - currently ignored. In the future, O_NONBLOCK will be
  25. relevant.
  26. ignored - not used
  27. Return Value:
  28. An NT handle for the stream, or INVALID_HANDLE_VALUE if unsuccessful.
  29. --*/
  30. {
  31. HANDLE StreamHandle;
  32. OBJECT_ATTRIBUTES ObjectAttributes;
  33. IO_STATUS_BLOCK IoStatusBlock;
  34. STRING name_string;
  35. UNICODE_STRING uc_name_string;
  36. PFILE_FULL_EA_INFORMATION EaBuffer;
  37. char Buffer[sizeof(FILE_FULL_EA_INFORMATION) + NORMAL_STREAM_EA_LENGTH + 1];
  38. NTSTATUS Status;
  39. RtlInitString(&name_string, path);
  40. RtlAnsiStringToUnicodeString(&uc_name_string, &name_string, TRUE);
  41. InitializeObjectAttributes(
  42. &ObjectAttributes,
  43. &uc_name_string,
  44. OBJ_CASE_INSENSITIVE,
  45. (HANDLE) NULL,
  46. (PSECURITY_DESCRIPTOR) NULL
  47. );
  48. EaBuffer = (PFILE_FULL_EA_INFORMATION) Buffer;
  49. EaBuffer->NextEntryOffset = 0;
  50. EaBuffer->Flags = 0;
  51. EaBuffer->EaNameLength = NORMAL_STREAM_EA_LENGTH;
  52. EaBuffer->EaValueLength = 0;
  53. RtlMoveMemory(
  54. EaBuffer->EaName,
  55. NormalStreamEA,
  56. NORMAL_STREAM_EA_LENGTH + 1);
  57. Status =
  58. NtCreateFile(
  59. &StreamHandle,
  60. SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA,
  61. &ObjectAttributes,
  62. &IoStatusBlock,
  63. NULL,
  64. FILE_ATTRIBUTE_NORMAL,
  65. FILE_SHARE_READ | FILE_SHARE_WRITE,
  66. FILE_OPEN_IF,
  67. 0,
  68. EaBuffer,
  69. sizeof(FILE_FULL_EA_INFORMATION) - 1 +
  70. EaBuffer->EaNameLength + 1);
  71. RtlFreeUnicodeString(&uc_name_string);
  72. if (Status != STATUS_SUCCESS) {
  73. SetLastError(MapNtToPosixStatus(Status));
  74. return(INVALID_HANDLE_VALUE);
  75. } else {
  76. return(StreamHandle);
  77. }
  78. } // s_open
  79. HANDLE
  80. OpenStream(
  81. IN char *AdapterName
  82. )
  83. /*++
  84. Routine Description:
  85. This function is used by the TCP/IP Utilities to open STREAMS drivers.
  86. It was exported by the winstrm.dll included in the July, 1992 PDC
  87. release. Hence, it will continue to be exported by winstrm.dll.
  88. Arguments:
  89. AdapterName - path of the STREAMS driver
  90. Return Value:
  91. An NT handle, or INVALID_HANDLE_VALUE if unsuccessful.
  92. --*/
  93. {
  94. return( s_open(AdapterName, 2, 0) );
  95. } // OpenStream