Leaked source code of windows server 2003
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.

384 lines
11 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. fdparm.h
  5. Abstract:
  6. This file defines file-dir parameter handling data structure and prototypes.
  7. Author:
  8. Jameel Hyder (microsoft!jameelh)
  9. Revision History:
  10. 25 Apr 1992 Initial Version
  11. Notes: Tab stop: 4
  12. --*/
  13. #ifndef _FDPARM_
  14. #define _FDPARM_
  15. #define EVENALIGN(n) (((n) + 1) & ~1)
  16. // Common File and Directory bitmap definitions
  17. #define FD_BITMAP_ATTR 0x0001
  18. #define FD_BITMAP_PARENT_DIRID 0x0002
  19. #define FD_BITMAP_CREATETIME 0x0004
  20. #define FD_BITMAP_MODIFIEDTIME 0x0008
  21. #define FD_BITMAP_BACKUPTIME 0x0010
  22. #define FD_BITMAP_FINDERINFO 0x0020
  23. #define FD_BITMAP_LONGNAME 0x0040
  24. #define FD_BITMAP_SHORTNAME 0x0080
  25. #define FD_BITMAP_PRODOSINFO 0x2000
  26. // File Specific bitmap definitions
  27. #define FILE_BITMAP_FILENUM 0x0100
  28. #define FILE_BITMAP_DATALEN 0x0200
  29. #define FILE_BITMAP_RESCLEN 0x0400
  30. #define FILE_BITMAP_MASK 0x27FF
  31. // Directory bitmap definitions
  32. #define DIR_BITMAP_DIRID FILE_BITMAP_FILENUM
  33. #define DIR_BITMAP_OFFSPRINGS FILE_BITMAP_DATALEN
  34. #define DIR_BITMAP_OWNERID FILE_BITMAP_RESCLEN
  35. #define DIR_BITMAP_GROUPID 0x0800
  36. #define DIR_BITMAP_ACCESSRIGHTS 0x1000
  37. #define DIR_BITMAP_MASK 0x3FFF
  38. #define FD_VALID_SET_PARMS (FD_BITMAP_ATTR | \
  39. FD_BITMAP_FINDERINFO | \
  40. FD_BITMAP_PRODOSINFO | \
  41. FD_BITMAP_CREATETIME | \
  42. FD_BITMAP_BACKUPTIME | \
  43. FD_BITMAP_MODIFIEDTIME)
  44. #define DIR_VALID_SET_PARMS (FD_VALID_SET_PARMS | \
  45. DIR_BITMAP_OWNERID | \
  46. DIR_BITMAP_GROUPID | \
  47. DIR_BITMAP_ACCESSRIGHTS)
  48. #define FILE_VALID_SET_PARMS (FD_VALID_SET_PARMS)
  49. // We have no way of knowing what the ASP buffer size on the client end is,
  50. // from trial and error it appears to be less than 578
  51. #define MAX_CATSEARCH_REPLY 512
  52. // Valid Request (search criteria) bitmaps for AfpCatSearch
  53. #define FD_VALID_SEARCH_CRITERIA (FD_BITMAP_PARENT_DIRID | \
  54. FD_BITMAP_CREATETIME | \
  55. FD_BITMAP_MODIFIEDTIME | \
  56. FD_BITMAP_BACKUPTIME | \
  57. FD_BITMAP_FINDERINFO | \
  58. FD_BITMAP_LONGNAME)
  59. #define FILE_VALID_SEARCH_CRITERIA (FD_VALID_SEARCH_CRITERIA | \
  60. FD_BITMAP_ATTR | \
  61. FILE_BITMAP_DATALEN | \
  62. FILE_BITMAP_RESCLEN)
  63. #define DIR_VALID_SEARCH_CRITERIA (FD_VALID_SEARCH_CRITERIA | \
  64. FD_BITMAP_ATTR | \
  65. DIR_BITMAP_OFFSPRINGS)
  66. // The only valid information that can be requested as a result of a
  67. // AfpCatSearch is the parent dirid and the longname of the file/dir found.
  68. #define FD_VALID_SEARCH_RESULT (FD_BITMAP_PARENT_DIRID | \
  69. FD_BITMAP_LONGNAME)
  70. // Common File and Directory attribute definitions
  71. #define FD_BITMAP_ATTR_INVISIBLE 0x0001
  72. #define FD_BITMAP_ATTR_SYSTEM 0x0004
  73. #define FD_BITMAP_ATTR_BACKUPNEED 0x0040
  74. #define FD_BITMAP_ATTR_RENAMEINH 0x0080
  75. #define FD_BITMAP_ATTR_DELETEINH 0x0100
  76. #define FD_BITMAP_ATTR_SET 0x8000
  77. // File specific attribute definitions
  78. #define FILE_BITMAP_ATTR_MULTIUSER 0x0002
  79. #define FILE_BITMAP_ATTR_DATAOPEN 0x0008
  80. #define FILE_BITMAP_ATTR_RESCOPEN 0x0010
  81. #define FILE_BITMAP_ATTR_WRITEINH 0x0020
  82. #define FILE_BITMAP_ATTR_COPYPROT 0x0400
  83. #define FD_VALID_ATTR (FD_BITMAP_ATTR_SET | \
  84. FD_BITMAP_ATTR_DELETEINH | \
  85. FILE_BITMAP_ATTR_WRITEINH | \
  86. FD_BITMAP_ATTR_RENAMEINH | \
  87. FD_BITMAP_ATTR_BACKUPNEED | \
  88. FD_BITMAP_ATTR_INVISIBLE | \
  89. FD_BITMAP_ATTR_SYSTEM)
  90. // File/Dir Attributes that map onto the NT ReadOnly attribute
  91. #define FD_BITMAP_ATTR_NT_RO (FD_BITMAP_ATTR_RENAMEINH | \
  92. FD_BITMAP_ATTR_DELETEINH | \
  93. FILE_BITMAP_ATTR_WRITEINH)
  94. // This is the set of attributes that are part DfeEntry
  95. #define AFP_FORK_ATTRIBUTES (FILE_BITMAP_ATTR_DATAOPEN | \
  96. FILE_BITMAP_ATTR_RESCOPEN)
  97. // Dir Attributes that can only be changed *from their current settings*
  98. // by the owner of the directory
  99. #define DIR_BITMAP_ATTR_CHG_X_OWNER_ONLY (FD_BITMAP_ATTR_RENAMEINH | \
  100. FD_BITMAP_ATTR_DELETEINH | \
  101. FD_BITMAP_ATTR_INVISIBLE | \
  102. FILE_BITMAP_ATTR_WRITEINH)
  103. // These are the OpenAccess bits that encode the FILEIO_ACCESS_XXX values
  104. // into the Bitmap parameter so that the pathmap code can open the file/dir
  105. // (under impersonation) with the appropriate access for each AFP API.
  106. // We also encode the access needed by the AdminDirectory Get/Set apis for
  107. // when admin calls into pathmap.
  108. #define FD_INTERNAL_BITMAP_SKIP_IMPERSONATION 0x00200000
  109. #define FD_INTERNAL_BITMAP_OPENFORK_RESC 0x00400000
  110. // Tells pathmap code whether it should return the paths in the
  111. // PATHMAPENTITY structure for APIs which will cause disk changes that will
  112. // cause a change notify to complete.
  113. #define FD_INTERNAL_BITMAP_RETURN_PMEPATHS 0x00800000
  114. // AdminDirectoryGetInfo: FILE_READ_ATTRIBUTES | READ_CONTROL | SYNCHRONIZE
  115. #define FD_INTERNAL_BITMAP_OPENACCESS_ADMINGET 0x01000000
  116. // AdminDirectorySetInfo: same as ADMINGET plus the following:
  117. // FILE_WRITE_ATTRIBUTES | WRITE_DAC | WRITE_OWNER
  118. #define FD_INTERNAL_BITMAP_OPENACCESS_ADMINSET 0x02000000
  119. #define FD_INTERNAL_BITMAP_OPENACCESS_READCTRL 0x04000000 //READ_CONTROL+FILEIO_ACCESS_NONE
  120. #define FD_INTERNAL_BITMAP_OPENACCESS_RWCTRL 0x08000000 //READ_CONTROL+WRITE_CONTROL+FILEIO_ACCESS_NONE
  121. #define FD_INTERNAL_BITMAP_OPENACCESS_READ 0x10000000 //FILEIO_ACCESS_READ
  122. #define FD_INTERNAL_BITMAP_OPENACCESS_WRITE 0x20000000 //FILEIO_ACCESS_WRITE
  123. #define FD_INTERNAL_BITMAP_OPENACCESS_RW_ATTR 0x40000000 //FILE_WRITE_ATTRIBUTES+FILEIO_ACCESS_NONE
  124. #define FD_INTERNAL_BITMAP_OPENACCESS_DELETE 0x80000000 //FILEIO_ACCESS_DELETE
  125. #define FD_INTERNAL_BITMAP_OPENACCESS_READWRITE ( \
  126. FD_INTERNAL_BITMAP_OPENACCESS_READ | \
  127. FD_INTERNAL_BITMAP_OPENACCESS_WRITE)
  128. #define FD_INTERNAL_BITMAP_OPENACCESS_ALL ( \
  129. FD_INTERNAL_BITMAP_OPENACCESS_ADMINGET | \
  130. FD_INTERNAL_BITMAP_OPENACCESS_ADMINSET | \
  131. FD_INTERNAL_BITMAP_OPENACCESS_READCTRL | \
  132. FD_INTERNAL_BITMAP_OPENACCESS_RWCTRL | \
  133. FD_INTERNAL_BITMAP_OPENACCESS_READ | \
  134. FD_INTERNAL_BITMAP_OPENACCESS_WRITE | \
  135. FD_INTERNAL_BITMAP_OPENACCESS_RW_ATTR | \
  136. FD_INTERNAL_BITMAP_OPENACCESS_DELETE)
  137. // These are the DenyMode bits that encode the FILEIO_DENY_XXX values
  138. // into the Bitmap parameter so that the pathmap code can open the fork
  139. // with the appropriate deny modes when mac is calling FpOpenFork. Pathmap
  140. // will shift these bits right by FD_INTERNAL_BITMAP_DENYMODE_SHIFT and use
  141. // the value as an index into the AfpDenyModes array to come up with the
  142. // correct deny mode to open the fork with. Note how these bit values
  143. // correspond to the FORK_DENY_xxx bits in forks.h
  144. #define FD_INTERNAL_BITMAP_DENYMODE_READ 0x00010000 //FILEIO_DENY_READ
  145. #define FD_INTERNAL_BITMAP_DENYMODE_WRITE 0x00020000 //FILEIO_DENY_WRITE
  146. #define FD_INTERNAL_BITMAP_DENYMODE_ALL ( \
  147. FD_INTERNAL_BITMAP_DENYMODE_READ | \
  148. FD_INTERNAL_BITMAP_DENYMODE_WRITE)
  149. // Number of bits to shift right in order to get the correct index into the
  150. // AfpDenyModes array
  151. #define FD_INTERNAL_BITMAP_DENYMODE_SHIFT 16
  152. // This gets returned as part of GetFileDirParms
  153. #define FILEDIR_FLAG_DIR 0x80
  154. #define FILEDIR_FLAG_FILE 0x00
  155. // Directory Access Permissions
  156. #define DIR_ACCESS_SEARCH 0x01 // See Folders
  157. #define DIR_ACCESS_READ 0x02 // See Files
  158. #define DIR_ACCESS_WRITE 0x04 // Make Changes
  159. #define DIR_ACCESS_OWNER 0x80 // Only for user
  160. // if he has owner rights
  161. #define OWNER_BITS_ALL 0x00808080
  162. // Mask used to clear owner bit for
  163. // Owner/Group/World. We are only
  164. // required to report this bit for
  165. // 'ThisUser'
  166. #define DIR_ACCESS_ALL (DIR_ACCESS_READ | \
  167. DIR_ACCESS_SEARCH | \
  168. DIR_ACCESS_WRITE)
  169. #define OWNER_RIGHTS_SHIFT 0
  170. #define GROUP_RIGHTS_SHIFT 8
  171. #define WORLD_RIGHTS_SHIFT 16
  172. #define USER_RIGHTS_SHIFT 24
  173. typedef struct _FileDirParms
  174. {
  175. DWORD _fdp_AfpId;
  176. DWORD _fdp_ParentId;
  177. DWORD _fdp_Flags; // one of DFE_FLAGS_DFBITS
  178. USHORT _fdp_Attr;
  179. USHORT _fdp_EffectiveAttr; // After any additions/subtractions
  180. AFPTIME _fdp_CreateTime;
  181. AFPTIME _fdp_ModifiedTime;
  182. AFPTIME _fdp_BackupTime;
  183. union
  184. {
  185. struct
  186. {
  187. DWORD _fdp_DataForkLen;
  188. DWORD _fdp_RescForkLen;
  189. };
  190. struct
  191. {
  192. DWORD _fdp_FileCount;
  193. DWORD _fdp_DirCount;
  194. DWORD _fdp_OwnerId;
  195. DWORD _fdp_GroupId;
  196. };
  197. };
  198. FINDERINFO _fdp_FinderInfo;
  199. ANSI_STRING _fdp_LongName; // Name of the entity (Not fully qualified)
  200. ANSI_STRING _fdp_ShortName;
  201. PRODOSINFO _fdp_ProDosInfo;
  202. BOOLEAN _fdp_UserIsMemberOfDirGroup;
  203. BOOLEAN _fdp_UserIsOwner;
  204. union
  205. {
  206. struct
  207. {
  208. BYTE _fdp_OwnerRights; // The Rights bytes must be in the order
  209. BYTE _fdp_GroupRights; // of Owner,Group,World,User
  210. BYTE _fdp_WorldRights;
  211. BYTE _fdp_UserRights;
  212. };
  213. DWORD _fdp_Rights; // All rights accessed as a single entity
  214. };
  215. BOOLEAN _fdp_fPartialName; // For FpCatSearch partial name flag
  216. BYTE _fdp_LongNameBuf [AFP_LONGNAME_LEN+1];
  217. BYTE _fdp_ShortNameBuf[AFP_SHORTNAME_LEN+1];
  218. } FILEDIRPARM, *PFILEDIRPARM;
  219. #define IsDir(pFDParm) (BOOLEAN)(((pFDParm)->_fdp_Flags & DFE_FLAGS_DIR) == DFE_FLAGS_DIR)
  220. #define AfpInitializeFDParms(pFDParms) \
  221. (pFDParms)->_fdp_LongName.MaximumLength = AFP_LONGNAME_LEN+1; \
  222. (pFDParms)->_fdp_LongName.Length = 0; \
  223. (pFDParms)->_fdp_LongName.Buffer = (pFDParms)->_fdp_LongNameBuf;\
  224. (pFDParms)->_fdp_ShortName.MaximumLength = AFP_SHORTNAME_LEN+1; \
  225. (pFDParms)->_fdp_ShortName.Length = 0; \
  226. (pFDParms)->_fdp_ShortName.Buffer = (pFDParms)->_fdp_ShortNameBuf;
  227. extern
  228. USHORT
  229. AfpGetFileDirParmsReplyLength(
  230. IN PFILEDIRPARM pFDParm,
  231. IN DWORD Bitmap
  232. );
  233. extern
  234. VOID
  235. AfpPackFileDirParms(
  236. IN PFILEDIRPARM pFileDirParm,
  237. IN DWORD Bitmap,
  238. OUT PBYTE pBuffer
  239. );
  240. extern
  241. AFPSTATUS
  242. AfpUnpackFileDirParms(
  243. IN PBYTE pBuffer,
  244. IN LONG Length,
  245. IN PDWORD pBitmap,
  246. OUT PFILEDIRPARM pFileDirParm
  247. );
  248. extern
  249. AFPSTATUS
  250. AfpSetFileDirParms(
  251. IN PVOLDESC pVolDesc,
  252. IN struct _PathMapEntity * pPME,
  253. IN DWORD Bitmap,
  254. IN PFILEDIRPARM pFDParm
  255. );
  256. extern
  257. USHORT
  258. AfpConvertNTAttrToAfpAttr(
  259. IN DWORD Attr
  260. );
  261. extern
  262. DWORD
  263. AfpConvertAfpAttrToNTAttr(
  264. IN USHORT Attr
  265. );
  266. extern
  267. VOID
  268. AfpNormalizeAfpAttr(
  269. IN OUT PFILEDIRPARM pFDParm,
  270. IN DWORD NtAttr
  271. );
  272. extern
  273. DWORD
  274. AfpMapFDBitmapOpenAccess(
  275. IN DWORD Bitmap,
  276. IN BOOLEAN IsDir
  277. );
  278. extern
  279. AFPSTATUS
  280. AfpQuerySecurityIdsAndRights(
  281. IN PSDA pSda,
  282. IN PFILESYSHANDLE FSHandle,
  283. IN DWORD Bitmap,
  284. IN OUT PFILEDIRPARM pFDParm
  285. );
  286. extern
  287. AFPSTATUS
  288. AfpCheckForInhibit(
  289. IN PFILESYSHANDLE hData,
  290. IN DWORD InhibitBit,
  291. IN DWORD AfpAttr,
  292. OUT PDWORD pNTAttr
  293. );
  294. extern
  295. AFPSTATUS
  296. AfpUnpackCatSearchSpecs(
  297. IN PBYTE pBuffer, // Pointer to beginning of Spec data
  298. IN USHORT BufLength, // Length of Spec1 + Spec2 data
  299. IN DWORD Bitmap,
  300. OUT PFILEDIRPARM pFDParm1,
  301. OUT PFILEDIRPARM pFDParm2,
  302. OUT PUNICODE_STRING pMatchString
  303. );
  304. extern
  305. SHORT
  306. AfpIsCatSearchMatch(
  307. IN PDFENTRY pDFE,
  308. IN DWORD Bitmap, // Search criteria
  309. IN DWORD ReplyBitmap, // Info to return
  310. IN PFILEDIRPARM pFDParm1,
  311. IN PFILEDIRPARM pFDParm2,
  312. IN PUNICODE_STRING pMatchName OPTIONAL
  313. );
  314. #endif // _FDPARM
  315.