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.

488 lines
12 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. fileio.h
  5. Abstract:
  6. This file defines the file I/O prototypes
  7. Author:
  8. Jameel Hyder (microsoft!jameelh)
  9. Revision History:
  10. 18 Jun 1992 Initial Version
  11. Notes: Tab stop: 4
  12. --*/
  13. #ifndef _FILEIO_
  14. #define _FILEIO_
  15. #define FILEIO_OPEN_FILE (FILE_NON_DIRECTORY_FILE |\
  16. FILE_RANDOM_ACCESS |\
  17. FILE_SYNCHRONOUS_IO_NONALERT)
  18. #define FILEIO_OPEN_FILE_SEQ (FILE_NON_DIRECTORY_FILE |\
  19. FILE_SEQUENTIAL_ONLY |\
  20. FILE_NO_INTERMEDIATE_BUFFERING |\
  21. FILE_SYNCHRONOUS_IO_NONALERT)
  22. #define FILEIO_OPEN_DIR (FILE_DIRECTORY_FILE |\
  23. FILE_SYNCHRONOUS_IO_NONALERT)
  24. #define FILEIO_OPEN_EITHER (FILE_SYNCHRONOUS_IO_NONALERT)
  25. #define FILEIO_ACCESS_NONE (FILE_READ_ATTRIBUTES |\
  26. SYNCHRONIZE)
  27. #define FILEIO_ACCESS_READ (GENERIC_READ |\
  28. SYNCHRONIZE)
  29. #define FILEIO_ACCESS_WRITE (GENERIC_WRITE |\
  30. SYNCHRONIZE)
  31. #define FILEIO_ACCESS_READWRITE (FILEIO_ACCESS_READ |\
  32. FILEIO_ACCESS_WRITE)
  33. #define FILEIO_ACCESS_DELETE (DELETE |\
  34. SYNCHRONIZE)
  35. #define FILEIO_ACCESS_MAX 4
  36. // Note that READ and WRITE share modes are enforced on a per-stream
  37. // basis, whereas DELETE share mode is still per-file. We must include
  38. // SHARE_DELETE even for deny-all since things like cmd.exe will open
  39. // a directory for DELETE when cd-ing into that directory. If we were to
  40. // then try to open the AFP_AfpInfo stream with no share delete access it
  41. // would fail. Since mac has no concept of share delete this is acceptible.
  42. // In addition, mac must open for delete in order to rename/move a file/dir.
  43. //
  44. // The sharing modes are strictly per-stream except for the following
  45. // exceptions:
  46. //
  47. // To delete the entire file, the caller must open the unnamed data
  48. // stream (file) or the directory for delete access.
  49. //
  50. // If an open of any stream does not permit delete access to that stream
  51. // then no one may open the file for for delete access. Conversely if
  52. // the file is already opened for delete access then any open of a
  53. // stream which denies delete access will fail with a sharing violation.
  54. //
  55. // The reasoning is that if someone wants to prevent a stream from being
  56. // deleted then they must prevent anyone from opening the file for
  57. // delete.
  58. #define FILEIO_DENY_NONE (FILE_SHARE_READ |\
  59. FILE_SHARE_WRITE |\
  60. FILE_SHARE_DELETE)
  61. #define FILEIO_DENY_READ (FILE_SHARE_WRITE |\
  62. FILE_SHARE_DELETE)
  63. #define FILEIO_DENY_WRITE (FILE_SHARE_READ |\
  64. FILE_SHARE_DELETE)
  65. #define FILEIO_DENY_ALL FILE_SHARE_DELETE
  66. #define FILEIO_DENY_MAX 4
  67. #define FILEIO_CREATE_SOFT FILE_CREATE
  68. #define FILEIO_CREATE_HARD FILE_SUPERSEDE
  69. #define FILEIO_CREATE_INTERNAL FILE_OPEN_IF
  70. #define FILEIO_CREATE_MAX 2
  71. // do NOT change the order of these unless you also change the code in
  72. // afpVolumeCloseHandleAndFreeDesc for deleting streams from volume root.
  73. #define AFP_STREAM_DATA 0
  74. #define AFP_STREAM_RESC 1
  75. #define AFP_STREAM_IDDB 2
  76. #define AFP_STREAM_DT 3
  77. #define AFP_STREAM_INFO 4
  78. #define AFP_STREAM_COMM 5
  79. #define AFP_STREAM_MAX 6
  80. // directories to ignore when enumerating
  81. GLOBAL UNICODE_STRING Dot EQU {0, 0, NULL};
  82. GLOBAL UNICODE_STRING DotDot EQU {0, 0, NULL};
  83. // stream not to create during CopyFile
  84. GLOBAL UNICODE_STRING DataStreamName EQU {0, 0, NULL};
  85. #define IS_DATA_STREAM(pUnicodeStreamName) \
  86. EQUAL_UNICODE_STRING(pUnicodeStreamName, &DataStreamName, False)
  87. GLOBAL UNICODE_STRING FullCommentStreamName EQU {0, 0, NULL};
  88. #define IS_COMMENT_STREAM(pUnicodeStreamName) \
  89. EQUAL_UNICODE_STRING(pUnicodeStreamName, &FullCommentStreamName, False)
  90. GLOBAL UNICODE_STRING FullResourceStreamName EQU {0, 0, NULL};
  91. #define IS_RESOURCE_STREAM(pUnicodeStreamName) \
  92. EQUAL_UNICODE_STRING(pUnicodeStreamName, &FullResourceStreamName, True)
  93. GLOBAL UNICODE_STRING FullInfoStreamName EQU {0, 0, NULL};
  94. #define IS_INFO_STREAM(pUnicodeStreamName) \
  95. EQUAL_UNICODE_STRING(pUnicodeStreamName, &FullInfoStreamName, True)
  96. // temporary filename when renaming files for FpExchangeFiles
  97. // the name is composed of 40 spaces
  98. #define AFP_TEMP_EXCHANGE_NAME L" "
  99. GLOBAL UNICODE_STRING AfpExchangeName EQU {0, 0, NULL};
  100. GLOBAL UNICODE_STRING DosDevices EQU {0, 0, NULL};
  101. GLOBAL UNICODE_STRING AfpStreams[AFP_STREAM_MAX] EQU { 0 };
  102. #define AfpIdDbStream AfpStreams[AFP_STREAM_IDDB]
  103. #define AfpDesktopStream AfpStreams[AFP_STREAM_DT]
  104. #define AfpResourceStream AfpStreams[AFP_STREAM_RESC]
  105. #define AfpInfoStream AfpStreams[AFP_STREAM_INFO]
  106. #define AfpCommentStream AfpStreams[AFP_STREAM_COMM]
  107. #define AfpDataStream AfpStreams[AFP_STREAM_DATA]
  108. #pragma warning(disable:4010)
  109. #if 0
  110. GLOBAL DWORD AfpAccessModes[FILEIO_ACCESS_MAX] EQU \
  111. { \
  112. FILEIO_ACCESS_NONE, \
  113. FILEIO_ACCESS_READ, \
  114. FILEIO_ACCESS_WRITE, \
  115. FILEIO_ACCESS_READWRITE \
  116. };
  117. #endif
  118. GLOBAL DWORD AfpDenyModes[FILEIO_DENY_MAX] EQU \
  119. { \
  120. FILEIO_DENY_NONE, \
  121. FILEIO_DENY_READ, \
  122. FILEIO_DENY_WRITE, \
  123. FILEIO_DENY_ALL \
  124. };
  125. GLOBAL DWORD AfpCreateDispositions[FILEIO_CREATE_MAX] EQU\
  126. { \
  127. FILEIO_CREATE_SOFT, \
  128. FILEIO_CREATE_HARD \
  129. };
  130. // This structure is used by file-system interface code
  131. #if DBG
  132. #define FSH_SIGNATURE *(DWORD *)"FSH"
  133. #define VALID_FSH(pFSH) (((pFSH) != NULL) && \
  134. ((pFSH)->fsh_FileHandle != NULL) && \
  135. ((pFSH)->fsh_FileObject != NULL) && \
  136. ((pFSH)->Signature == FSH_SIGNATURE))
  137. #else
  138. #define VALID_FSH(pFSH) (((pFSH)->fsh_FileHandle != NULL) && \
  139. ((pFSH)->fsh_FileObject != NULL))
  140. #endif
  141. // NOTE: We overload the FileObject pointer to keep track of internal/client
  142. // handles. We always mask off this while actually accessing it. The
  143. // assumption here is that this pointer will never be odd.
  144. //
  145. #define FSH_INTERNAL_MASK 1
  146. #define AfpGetRealFileObject(pFileObject) (PFILE_OBJECT)((ULONG_PTR)(pFileObject) & ~FSH_INTERNAL_MASK)
  147. typedef struct _FileSysHandle
  148. {
  149. #if DBG
  150. DWORD Signature;
  151. #endif
  152. HANDLE fsh_FileHandle; // Host file handle
  153. PFILE_OBJECT fsh_FileObject; // File Object corres. to the file handle
  154. PDEVICE_OBJECT fsh_DeviceObject; // Device Object corres. to the file handle
  155. } FILESYSHANDLE, *PFILESYSHANDLE;
  156. #define INTERNAL_HANDLE(pFSHandle) ((ULONG_PTR)((pFSHandle)->fsh_FileObject) & FSH_INTERNAL_MASK) ? True : False
  157. #define UPGRADE_HANDLE(pFSHandle) ((ULONG_PTR)((pFSHandle)->fsh_FileObject) &= ~FSH_INTERNAL_MASK)
  158. typedef struct _StreamsInfo
  159. {
  160. UNICODE_STRING si_StreamName;
  161. LARGE_INTEGER si_StreamSize;
  162. } STREAM_INFO, *PSTREAM_INFO;
  163. typedef struct _CopyFileInfo
  164. {
  165. LONG cfi_NumStreams;
  166. PFILESYSHANDLE cfi_SrcStreamHandle;
  167. PFILESYSHANDLE cfi_DstStreamHandle;
  168. } COPY_FILE_INFO, *PCOPY_FILE_INFO;
  169. #define AFP_RETRIEVE_MODTIME 1
  170. #define AFP_RESTORE_MODTIME 2
  171. extern
  172. NTSTATUS
  173. AfpFileIoInit(
  174. VOID
  175. );
  176. extern
  177. VOID
  178. AfpFileIoDeInit(
  179. VOID
  180. );
  181. extern
  182. AFPSTATUS
  183. AfpIoOpen(
  184. IN PFILESYSHANDLE hRelative,
  185. IN DWORD StreamId,
  186. IN DWORD Options,
  187. IN PUNICODE_STRING pObject,
  188. IN DWORD AfpAccess,
  189. IN DWORD AfpDenyMode,
  190. IN BOOLEAN CheckAccess,
  191. OUT PFILESYSHANDLE pFileSysHandle
  192. );
  193. extern
  194. AFPSTATUS
  195. AfpIoCreate(
  196. IN PFILESYSHANDLE hRelative, // create relative to this
  197. IN DWORD StreamId, // Id of stream to create
  198. IN PUNICODE_STRING pObject, // Name of file
  199. IN DWORD AfpAccess, // FILEIO_ACCESS_XXX desired access
  200. IN DWORD AfpDenyMode, // FILEIO_DENY_XXX
  201. IN DWORD CreateOptions, // File/Directory etc.
  202. IN DWORD Disposition, // Soft or hard create
  203. IN DWORD Attributes, // hidden, archive, normal, etc.
  204. IN BOOLEAN CheckAccess, // If TRUE, enforce security
  205. IN PSECURITY_DESCRIPTOR pSecDesc OPTIONAL, // Security descriptor to slap on
  206. OUT PFILESYSHANDLE pFileSysHandle, // Place holder for the handle
  207. OUT PDWORD pInformation OPTIONAL, // file opened, created, etc.
  208. IN struct _VolDesc * pVolDesc OPTIONAL, // only if NotifyPath
  209. IN PUNICODE_STRING pNotifyPath OPTIONAL,
  210. IN PUNICODE_STRING pNotifyParentPath OPTIONAL
  211. );
  212. extern
  213. AFPSTATUS
  214. AfpIoRead(
  215. IN PFILESYSHANDLE pFileSysHandle,
  216. IN PFORKOFFST pForkOffset,
  217. IN LONG SizeReq,
  218. OUT PLONG pSizeRead,
  219. OUT PBYTE pBuffer
  220. );
  221. extern
  222. AFPSTATUS
  223. AfpIoWrite(
  224. IN PFILESYSHANDLE pFileSysHandle,
  225. IN PFORKOFFST pForkOffset,
  226. IN LONG SizeReq,
  227. OUT PBYTE pBuffer
  228. );
  229. extern
  230. AFPSTATUS FASTCALL
  231. AfpIoQuerySize(
  232. IN PFILESYSHANDLE pFileSysHandle,
  233. OUT PFORKSIZE pForkLength
  234. );
  235. extern
  236. AFPSTATUS FASTCALL
  237. AfpIoSetSize(
  238. IN PFILESYSHANDLE pFileSysHandle,
  239. IN LONG ForkLength
  240. );
  241. extern
  242. AFPSTATUS
  243. AfpIoChangeNTModTime(
  244. IN PFILESYSHANDLE pFileHandle,
  245. OUT PTIME pModTime
  246. );
  247. extern
  248. AFPSTATUS
  249. AfpIoQueryTimesnAttr(
  250. IN PFILESYSHANDLE pFileHandle,
  251. OUT PDWORD pCreatTime OPTIONAL,
  252. OUT PTIME pModTime OPTIONAL,
  253. OUT PDWORD pAttr OPTIONAL
  254. );
  255. extern
  256. AFPSTATUS
  257. AfpIoSetTimesnAttr(
  258. IN PFILESYSHANDLE pFileSysHandle,
  259. IN PAFPTIME pCreateTime OPTIONAL,
  260. IN PAFPTIME pModTime OPTIONAL,
  261. IN DWORD AttrSet,
  262. IN DWORD AttrClear,
  263. IN struct _VolDesc * pVolDesc OPTIONAL, // only if NotifyPath
  264. IN PUNICODE_STRING pNotifyPath OPTIONAL
  265. );
  266. extern
  267. AFPSTATUS
  268. AfpIoRestoreTimeStamp(
  269. IN PFILESYSHANDLE pFileSysHandle,
  270. IN OUT PTIME pOriginalModTime,
  271. IN DWORD dwFlag
  272. );
  273. extern
  274. AFPSTATUS FASTCALL
  275. AfpIoQueryShortName(
  276. IN PFILESYSHANDLE pFileSysHandle,
  277. OUT PANSI_STRING pName
  278. );
  279. extern
  280. NTSTATUS
  281. AfpIoQueryLongName(
  282. IN PFILESYSHANDLE pFileHandle,
  283. IN PUNICODE_STRING pShortname,
  284. OUT PUNICODE_STRING pLongName
  285. );
  286. extern
  287. PSTREAM_INFO FASTCALL
  288. AfpIoQueryStreams(
  289. IN PFILESYSHANDLE pFileHandle
  290. );
  291. extern
  292. NTSTATUS
  293. AfpIoMarkFileForDelete(
  294. IN PFILESYSHANDLE pFileSysHandle,
  295. IN struct _VolDesc * pVolDesc OPTIONAL, // only if pNotifyPath
  296. IN PUNICODE_STRING pNotifyPath OPTIONAL,
  297. IN PUNICODE_STRING pNotifyParentPath OPTIONAL
  298. );
  299. extern
  300. NTSTATUS
  301. AfpIoQueryDirectoryFile(
  302. IN PFILESYSHANDLE pFileSysHandle,
  303. OUT PVOID Enumbuf,
  304. IN ULONG Enumbuflen,
  305. IN ULONG FileInfoClass,
  306. IN BOOLEAN ReturnSingleEntry,
  307. IN BOOLEAN RestartScan,
  308. IN PUNICODE_STRING pString OPTIONAL
  309. );
  310. NTSTATUS
  311. AfpIoQueryBasicInfo(
  312. IN PFILESYSHANDLE pFileHandle,
  313. OUT PVOID BasicInfoBuf
  314. );
  315. extern
  316. AFPSTATUS FASTCALL
  317. AfpIoClose(
  318. IN PFILESYSHANDLE pFileSysHandle
  319. );
  320. extern
  321. AFPSTATUS
  322. AfpIoQueryVolumeSize(
  323. IN struct _VolDesc * pVolDesc,
  324. OUT LARGE_INTEGER * pFreeBytes,
  325. OUT LARGE_INTEGER * pVolumeSize OPTIONAL
  326. );
  327. extern
  328. AFPSTATUS
  329. AfpIoMoveAndOrRename(
  330. IN PFILESYSHANDLE pfshFile,
  331. IN PFILESYSHANDLE pfshNewParent OPTIONAL,// Supply for Move operation
  332. IN PUNICODE_STRING pNewName,
  333. IN struct _VolDesc * pVolDesc OPTIONAL,// only if NotifyPath
  334. IN PUNICODE_STRING pNotifyPath1 OPTIONAL,// REMOVE or RENAME action
  335. IN PUNICODE_STRING pNotifyParentPath1 OPTIONAL,
  336. IN PUNICODE_STRING pNotifyPath2 OPTIONAL,// ADDED action
  337. IN PUNICODE_STRING pNotifyParentPath2 OPTIONAL
  338. );
  339. extern
  340. AFPSTATUS
  341. AfpIoCopyFile1(
  342. IN PFILESYSHANDLE phSrcFile,
  343. IN PFILESYSHANDLE phDstDir,
  344. IN PUNICODE_STRING pNewName,
  345. IN struct _VolDesc * pVolDesc OPTIONAL, // only if pNotifyPath
  346. IN PUNICODE_STRING pNotifyPath OPTIONAL,
  347. IN PUNICODE_STRING pNotifyParentPath OPTIONAL,
  348. OUT PCOPY_FILE_INFO pCopyFileInfo
  349. );
  350. extern
  351. AFPSTATUS
  352. AfpIoCopyFile2(
  353. IN PCOPY_FILE_INFO pCopyFileInfo,
  354. IN struct _VolDesc * pVolDesc OPTIONAL, // only if pNotifyPath
  355. IN PUNICODE_STRING pNotifyPath OPTIONAL,
  356. IN PUNICODE_STRING pNotifyParentPath OPTIONAL
  357. );
  358. extern
  359. AFPSTATUS FASTCALL
  360. AfpIoConvertNTStatusToAfpStatus(
  361. IN NTSTATUS Status
  362. );
  363. extern
  364. VOID FASTCALL
  365. AfpUpgradeHandle(
  366. IN PFILESYSHANDLE pFileHandle
  367. );
  368. extern
  369. NTSTATUS FASTCALL
  370. AfpIoWait(
  371. IN PVOID pObject,
  372. IN PLARGE_INTEGER pTimeOut OPTIONAL
  373. );
  374. extern
  375. NTSTATUS
  376. AfpQueryPath(
  377. IN HANDLE FileHandle,
  378. IN PUNICODE_STRING pPath,
  379. IN ULONG MaximumBuf
  380. );
  381. extern
  382. BOOLEAN FASTCALL
  383. AfpIoIsSupportedDevice(
  384. IN PFILESYSHANDLE pFileHandle,
  385. OUT PDWORD pFlags
  386. );
  387. #ifdef FILEIO_LOCALS
  388. LOCAL UNICODE_STRING afpNTFSName = { 0 };
  389. LOCAL UNICODE_STRING afpCDFSName = { 0 };
  390. LOCAL UNICODE_STRING afpAHFSName = { 0 };
  391. LOCAL VOID FASTCALL
  392. afpUpdateOpenFiles(
  393. IN BOOLEAN Internal, // True for internal handles
  394. IN BOOLEAN Open // True for open, False for close
  395. );
  396. LOCAL VOID FASTCALL
  397. afpUpdateFastIoStat(
  398. IN BOOLEAN Success
  399. );
  400. #endif // FILEIO_LOCALS
  401. #endif // _FILEIO_
  402. 
  403.