Windows NT 4.0 source code leak
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.

138 lines
5.1 KiB

4 years ago
  1. /********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1987-1990 **/
  4. /********************************************************************/
  5. #ifdef MASM
  6. include dirent.inc
  7. #else
  8. #define attr_directory 0x10
  9. #endif
  10. /* Directory Entry Fields
  11. *
  12. * Directory entries are always left as a multiple of 4
  13. * to speed up moves. The DIR_NAMA field is variable length,
  14. * the DIR_BTP field, if present, is the last dword in the record.
  15. * ACL information may be stored after the DIR_NAMA field but before
  16. * the DIR_BTP field so the DIR_BTP field must be located by going
  17. * backwards from the end of the record
  18. *
  19. * WARNING - Mkdir block copies some of these entries and
  20. * makes assumptions about which fields get copied. Check
  21. * mkdir if stuff is added.
  22. */
  23. struct DIRENT {
  24. unsigned short DIR_ELEN; /* length of this entry (including free space) */
  25. unsigned short DIR_FLAG; /* flags - low byte defined below */
  26. /* high byte holds the old attr_ FAT values */
  27. unsigned long DIR_FN; /* FNODE Sector */
  28. unsigned long DIR_MTIM; /* last modification time */
  29. unsigned long DIR_SIZE; /* file size */
  30. unsigned long DIR_ATIM; /* last access time */
  31. unsigned long DIR_CTIM; /* fnode creation time */
  32. unsigned long DIR_EALEN; /* bytes of extended attributes */
  33. char DIR_FLEX; /* description of "flex" area following the
  34. * file name. Current definition is:
  35. * bits 0-2: number of ACEs in dirent
  36. * bits 3-7: reserved.
  37. */
  38. char DIR_CPAGE; /* code page index on volume */
  39. /* the following fields have information specific to the name and directory
  40. * position of the file. This info is not propigated for a move/rename
  41. * That code uses DIR_NAML as a seperator - check MOVE if changes are
  42. * made to this structure */
  43. unsigned char DIR_NAML; /* length of file name */
  44. unsigned char DIR_NAMA; /* name goes here */
  45. /* ACL information may be stored here */
  46. /* long DIR_BTP; btree pointer to descendent DIRBLK record. */
  47. /* This is only present if DF_BTP is set. */
  48. /* This field is referenced from the end of */
  49. /* the record, not DIR_NAMA+DIR_NAML */
  50. }; /* DIRENT */
  51. #ifdef MASM
  52. #define DIR_BTP dword ptr -4 /* referenced from the end of the record */
  53. #endif
  54. #define SIZE_DIR_BTP 4
  55. #define MAX_DIRACL 3 /* max of 3 ACLs in dirent */
  56. #define DIRSIZL offset DIR_NAMA /* base size of leaf dir entry (minus name) */
  57. #define DIRSIZP (sizeof (struct DIRENT)-1+4) /* base size of dir entry with btree ptr w/o name */
  58. #define MAX_DIRENT (DIRSIZP+255+MAX_DIRACL*(sizeof (struct SPERM_LIST))+10) /* max size of a DIRENT */
  59. /* (plus some slop) */
  60. /* Directory Block Definition
  61. *
  62. * The change count field is incremented every time we move any
  63. * of the entries in this block. For efficiency reasons, folks
  64. * remember the Sector # and offset of a directory entry, and the
  65. * value of the DB_CCNT field when that info was recorded.
  66. * If the DB_CCNT field is different then the remembered value,
  67. * then the entry offset is invalid and the entry should be
  68. * refound from the top. Note that when a directory block splits,
  69. * the old DIRBLK gets the old DB_CCNT field. Since
  70. * the new DIRBLK is previously unknown, it can have
  71. * any DB_CCNT value. We start with zero so that DB_CCNT
  72. * gives us a feel for the change rate in the directory.
  73. */
  74. struct DIRBLK {
  75. unsigned long DB_SIG; /* signature value */
  76. unsigned long DB_FREP; /* offset of first free byte */
  77. unsigned long DB_CCNT; /* change count (low order bit is flag) */
  78. /* =1 if this block is topmost */
  79. /* =0 otherwise */
  80. unsigned long DB_PAR; /* parent directory PSector # if not topmost */
  81. /* FNODE sector if topmost */
  82. unsigned long DB_SEC; /* PSector # of this directory block */
  83. char DB_START; /* first dirent record goes here */
  84. char DB_DUMY[2027]; /* round out to 2048 bytes */
  85. }; /* DIRBLK */
  86. /* Maximum entries per directory. */
  87. #define MAXDIRE (size DIRBLK- DB_START)/(size DIRENT)
  88. /** DIR_FLEX mask
  89. */
  90. #define DFX_ACLMASK 0x03 /* Bits describing number of ACLS */
  91. /** DIR_FLAG values
  92. */
  93. #define DF_SPEC 0x0001 /* special . entry */
  94. #define DF_ACL 0x0002 /* item has ACL */
  95. #define DF_BTP 0x0004 /* entry has a btree down pointer */
  96. #define DF_END 0x0008 /* is dumy end record */
  97. #define DF_XACL 0x0040 /* item has explicit ACL */
  98. #define DF_NEEDEAS 0x0080 /* file has "need" EAs */
  99. #define DF_NEWNAME 0x4000 /* filename doesn't use old naming rules */
  100. #define attr_newname 0x40 /* ditto for "dos attribute byte" */
  101. #define DF_RMASK DF_ACL+DF_XACL+DF_NEEDEAS /* only attributes preserved for rename */
  102. #ifdef MASM
  103. .errnz DF_BTP - SIZE_DIR_BTP /* code uses this "coincidence" */
  104. #endif
  105. /* Attributes which creation can specify */
  106. #define DF_CMASK attr_read_only+attr_hidden+attr_archive+attr_system
  107. #define SD_ACL_LIM 1024 /* *SD_ACL lists bigger than this come from */
  108. /* system memory, smaller come from heap */