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.

80 lines
3.0 KiB

  1. /* rm.h - include file for rm and undel facility
  2. *
  3. * Revision History:
  4. * ??-???-???? ?? Created
  5. * 27-Dec-1989 SB Added new index file header stuff
  6. *
  7. * Index file format:
  8. * The indexed file is composed of records of length RM_RECLEN.
  9. * The old index file was composed of entries each the size of a record
  10. * and composed of filename padded by NULs. The hash function mapped the
  11. * Nth record (i.e. Nth INDEXED entry) to 'deleted.xxx', where, 'xxx' is (N+1)
  12. * padded by leading zeroes.
  13. * The new index file has an header record, rm_header, followed by entries
  14. * of one or more records padded by NULs. Longfilenames occupy multiple
  15. * records. The hash function maps the entry starting at Nth record to
  16. * 'deleted.xxx' where xxx is (N+1) padded by leading zeroes. This works out
  17. * to be basically the same as that for the old format. The differences are :-
  18. * -No entry is mapped to 'deleted.000'
  19. * -Entries for filenames longer than (RM_RECLEN-1) bytes cause gaps in
  20. * mapping.
  21. *
  22. * Notes:
  23. * RM/EXP/UNDEL work as follows:-
  24. * 'RM foo' saves a copy of 'foo' and places it in an hidden
  25. * sub-directory of RM_DIR (of foo) as file 'deleted.xxx', where, xxx is
  26. * determined from the index file RM_IDX in RM_DIR. An entry is made in
  27. * the index file for this.
  28. * 'UNDEL foo' reads the index file in RM_DIR and determines xxx for
  29. * foo and renames 'deleted.xxx' as foo. The entry for foo in the index
  30. * file is filled with NULLs.
  31. * 'EXP' picks up the index file from RM_DIR and deletes 'deleted.xxx'
  32. * for each entry in the index file. It then deletes the index file and
  33. * RM_DIR.
  34. *
  35. * The new index file format can coexist with the old one because :-
  36. * The header has a starting NULL which causes it to be ignored by
  37. * the old utilities,
  38. * When the old utilities attempt to read in a long filename entry they
  39. * fail without harm as the hashed 'deleted.xx' does not exist.
  40. */
  41. #define RM_DIR "deleted."
  42. #define RM_IDX "index."
  43. #define RM_RECLEN 16
  44. /* The header record in the index file has
  45. * '\0IXn.nn\0' padded to RM_RECLEN bytes
  46. */
  47. #define RM_SIG (char)0x00
  48. #define RM_MAGIC "IX" /* IX - IndeXed file */
  49. #define RM_VER "1.01"
  50. #define RM_NULL "\0"
  51. /* Forms header for Index file using RM_MAGIC, RM_VER and RM_NULL */
  52. extern char rm_header[RM_RECLEN];
  53. /* Function prototypes */
  54. // Converts Index file to the new format
  55. int convertIdxFile (int fhidx, char *dir);
  56. // Determines if the record is a new index file header
  57. flagType fIdxHdr (char *rec);
  58. // Reads an Index file record
  59. int readIdxRec (int fhIdx, char *rec);
  60. // Reads index file records and returns INDEXED entry
  61. int readNewIdxRec (int fhIdx, char *szRec, unsigned int cbMax);
  62. // Writes an new index file header
  63. int writeIdxHdr (int fhIdx);
  64. // Writes an index file record
  65. int writeIdxRec (int fhIdx, char *rec);
  66. // Indexes an entry into the Index file
  67. int writeNewIdxRec (int fhIdx, char *szRec);