filesdb.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * dpkg - main program for package management
  3. * filesdb.h - management of database of files installed on system
  4. *
  5. * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2,
  10. * or (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with dpkg; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #ifndef FILESDB_H
  22. #define FILESDB_H
  23. /*
  24. * Data structure here is as follows:
  25. *
  26. * For each package we have a `struct fileinlist *', the head of
  27. * a list of files in that package. They are in `forwards' order.
  28. * Each entry has a pointer to the `struct filenamenode'.
  29. *
  30. * The struct filenamenodes are in a hash table, indexed by name.
  31. * (This hash table is not visible to callers.)
  32. *
  33. * Each filenamenode has a (possibly empty) list of `struct
  34. * filepackage', giving a list of the packages listing that
  35. * filename.
  36. *
  37. * When we read files contained info about a particular package
  38. * we set the `files' member of the clientdata struct to the
  39. * appropriate thing. When not yet set the files pointer is
  40. * made to point to `fileslist_uninited' (this is available only
  41. * internally, withing filesdb.c - the published interface is
  42. * ensure_*_available).
  43. */
  44. struct pkginfo;
  45. struct filenamenode {
  46. struct filenamenode *next;
  47. char *name;
  48. struct filepackages *packages;
  49. struct diversion *divert;
  50. /* Fields from here on are used by archives.c &c, and cleared by
  51. * filesdbinit.
  52. */
  53. enum {
  54. fnnf_new_conff= 000001, /* in the newconffiles list */
  55. fnnf_new_inarchive= 000002, /* in the new filesystem archive */
  56. fnnf_old_conff= 000004, /* in the old package's conffiles list */
  57. fnnf_elide_other_lists= 000010, /* must remove from other packages' lists */
  58. fnnf_no_atomic_overwrite= 000020, /* >=1 instance is a dir, cannot rename over */
  59. } flags; /* Set to zero when a new node is created. */
  60. const char *oldhash; /* valid iff this namenode is in the newconffiles list */
  61. };
  62. struct fileinlist {
  63. struct fileinlist *next;
  64. struct filenamenode *namenode;
  65. };
  66. struct diversion {
  67. /* When we deal with an `overridden' file, every package except
  68. * the overriding one is considered to contain the other file
  69. * instead. Both files have entries in the filesdb database, and
  70. * they refer to each other via these diversion structures.
  71. *
  72. * The contested filename's filenamenode has an diversion entry
  73. * with useinstead set to point to the redirected filename's
  74. * filenamenode; the redirected filenamenode has camefrom set to the
  75. * contested filenamenode. Both sides' diversion entries will
  76. * have pkg set to the package (if any) which is allowed to use the
  77. * contended filename.
  78. *
  79. * Packages that contain either version of the file will all
  80. * refer to the contested filenamenode in their per-file package lists
  81. * (both in core and on disk). References are redirected to the other
  82. * filenamenode's filename where appropriate.
  83. */
  84. struct filenamenode *useinstead;
  85. struct filenamenode *camefrom;
  86. struct pkginfo *pkg;
  87. struct diversion *next;
  88. /* The `contested' halves are in this list for easy cleanup. */
  89. };
  90. #define PERFILEPACKAGESLUMP 10
  91. struct filepackages {
  92. struct filepackages *more;
  93. struct pkginfo *pkgs[PERFILEPACKAGESLUMP];
  94. /* pkgs is a null-pointer-terminated list; anything after the first null
  95. * is garbage
  96. */
  97. };
  98. struct fileiterator;
  99. struct fileiterator *iterfilestart(void);
  100. struct filenamenode *iterfilenext(struct fileiterator *i);
  101. void iterfileend(struct fileiterator *i);
  102. void ensure_diversions(void);
  103. void ensure_packagefiles_available(struct pkginfo *pkg);
  104. void ensure_allinstfiles_available(void);
  105. void ensure_allinstfiles_available_quiet(void);
  106. void note_must_reread_files_inpackage(struct pkginfo *pkg);
  107. struct filenamenode *findnamenode(const char *filename);
  108. void write_filelist_except(struct pkginfo *pkg, struct fileinlist *list, int leaveout);
  109. struct reversefilelistiter { struct fileinlist *todo; };
  110. void reversefilelist_init(struct reversefilelistiter *iterptr, struct fileinlist *files);
  111. struct filenamenode *reversefilelist_next(struct reversefilelistiter *iterptr);
  112. void reversefilelist_abort(struct reversefilelistiter *iterptr);
  113. #endif /* FILESDB_H */