filesdb.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. /*
  2. * dpkg - main program for package management
  3. * filesdb.c - management of database of files installed on system
  4. *
  5. * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. * Copyright © 2000,2001 Wichert Akkerman <wakkerma@debian.org>
  7. *
  8. * This is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <config.h>
  22. #include <compat.h>
  23. #ifdef HAVE_LINUX_FIEMAP_H
  24. #include <linux/fiemap.h>
  25. #include <linux/fs.h>
  26. #include <sys/ioctl.h>
  27. #include <sys/vfs.h>
  28. #endif
  29. #include <sys/types.h>
  30. #include <sys/stat.h>
  31. #include <assert.h>
  32. #include <errno.h>
  33. #include <string.h>
  34. #include <pwd.h>
  35. #include <grp.h>
  36. #include <fcntl.h>
  37. #include <unistd.h>
  38. #include <stdlib.h>
  39. #include <dpkg/i18n.h>
  40. #include <dpkg/dpkg.h>
  41. #include <dpkg/dpkg-db.h>
  42. #include <dpkg/path.h>
  43. #include <dpkg/dir.h>
  44. #include <dpkg/fdio.h>
  45. #include <dpkg/pkg-array.h>
  46. #include <dpkg/progress.h>
  47. #include "filesdb.h"
  48. #include "main.h"
  49. /*** Package control information database directory routines. ***/
  50. /*
  51. * XXX: Strictly speaking these functions do not exactly belong here, and
  52. * they should be eventually moved back to a unified on-disk database
  53. * handling module in libdpkg. For now this is good enough, as it avoids
  54. * pulling unneeded code into the resulting binaries, because all its
  55. * users require filesdb anyway.
  56. */
  57. static char *infodir;
  58. static void
  59. pkgadmindir_init(void)
  60. {
  61. infodir = dpkg_db_get_path(INFODIR);
  62. }
  63. const char *
  64. pkgadmindir(void)
  65. {
  66. return infodir;
  67. }
  68. const char *
  69. pkgadminfile(struct pkginfo *pkg, struct pkgbin *pkgbin, const char *filetype)
  70. {
  71. static struct varbuf vb;
  72. varbuf_reset(&vb);
  73. varbuf_add_str(&vb, infodir);
  74. varbuf_add_char(&vb, '/');
  75. varbuf_add_str(&vb, pkg->set->name);
  76. varbuf_add_char(&vb, '.');
  77. varbuf_add_str(&vb, filetype);
  78. varbuf_end_str(&vb);
  79. return vb.buf;
  80. }
  81. /*** filepackages support for tracking packages owning a file. ***/
  82. #define PERFILEPACKAGESLUMP 10
  83. struct filepackages {
  84. struct filepackages *more;
  85. /* pkgs is a NULL-pointer-terminated list; anything after the first NULL
  86. * is garbage. */
  87. struct pkginfo *pkgs[PERFILEPACKAGESLUMP];
  88. };
  89. struct filepackages_iterator {
  90. struct filepackages *pkg_lump;
  91. int pkg_idx;
  92. };
  93. struct filepackages_iterator *
  94. filepackages_iter_new(struct filenamenode *fnn)
  95. {
  96. struct filepackages_iterator *iter;
  97. iter = m_malloc(sizeof(*iter));
  98. iter->pkg_lump = fnn->packages;
  99. iter->pkg_idx = 0;
  100. return iter;
  101. }
  102. struct pkginfo *
  103. filepackages_iter_next(struct filepackages_iterator *iter)
  104. {
  105. struct pkginfo *pkg;
  106. while (iter->pkg_lump) {
  107. pkg = iter->pkg_lump->pkgs[iter->pkg_idx];
  108. if (iter->pkg_idx < PERFILEPACKAGESLUMP && pkg) {
  109. iter->pkg_idx++;
  110. return pkg;
  111. } else {
  112. iter->pkg_lump = iter->pkg_lump->more;
  113. iter->pkg_idx = 0;
  114. }
  115. }
  116. return NULL;
  117. }
  118. void
  119. filepackages_iter_free(struct filepackages_iterator *iter)
  120. {
  121. free(iter);
  122. }
  123. /*** Generic data structures and routines. ***/
  124. static bool allpackagesdone = false;
  125. static int nfiles= 0;
  126. void
  127. ensure_package_clientdata(struct pkginfo *pkg)
  128. {
  129. if (pkg->clientdata)
  130. return;
  131. pkg->clientdata = nfmalloc(sizeof(struct perpackagestate));
  132. pkg->clientdata->istobe = itb_normal;
  133. pkg->clientdata->color = white;
  134. pkg->clientdata->fileslistvalid = false;
  135. pkg->clientdata->files = NULL;
  136. pkg->clientdata->replacingfilesandsaid = 0;
  137. pkg->clientdata->listfile_phys_offs = 0;
  138. pkg->clientdata->trigprocdeferred = NULL;
  139. }
  140. void note_must_reread_files_inpackage(struct pkginfo *pkg) {
  141. allpackagesdone = false;
  142. ensure_package_clientdata(pkg);
  143. pkg->clientdata->fileslistvalid = false;
  144. }
  145. static int saidread=0;
  146. /**
  147. * Erase the files saved in pkg.
  148. */
  149. static void
  150. pkg_files_blank(struct pkginfo *pkg)
  151. {
  152. struct fileinlist *current;
  153. struct filepackages *packageslump;
  154. int search, findlast;
  155. /* Anything to empty? */
  156. if (!pkg->clientdata)
  157. return;
  158. for (current= pkg->clientdata->files;
  159. current;
  160. current= current->next) {
  161. /* For each file that used to be in the package,
  162. * go through looking for this package's entry in the list
  163. * of packages containing this file, and blank it out. */
  164. for (packageslump= current->namenode->packages;
  165. packageslump;
  166. packageslump= packageslump->more)
  167. for (search= 0;
  168. search < PERFILEPACKAGESLUMP && packageslump->pkgs[search];
  169. search++)
  170. if (packageslump->pkgs[search] == pkg) {
  171. /* Hah! Found it. */
  172. for (findlast= search+1;
  173. findlast < PERFILEPACKAGESLUMP && packageslump->pkgs[findlast];
  174. findlast++);
  175. findlast--;
  176. /* findlast is now the last occupied entry, which may be the same as
  177. * search. We blank out the entry for this package. We also
  178. * have to copy the last entry into the empty slot, because
  179. * the list is NULL-pointer-terminated. */
  180. packageslump->pkgs[search]= packageslump->pkgs[findlast];
  181. packageslump->pkgs[findlast] = NULL;
  182. /* This may result in an empty link in the list. This is OK. */
  183. goto xit_search_to_delete_from_perfilenodelist;
  184. }
  185. xit_search_to_delete_from_perfilenodelist:
  186. ;
  187. /* The actual filelist links were allocated using nfmalloc, so
  188. * we shouldn't free them. */
  189. }
  190. pkg->clientdata->files = NULL;
  191. }
  192. static struct fileinlist **
  193. pkg_files_add_file(struct pkginfo *pkg, const char *filename,
  194. enum fnnflags flags, struct fileinlist **file_tail)
  195. {
  196. struct fileinlist *newent;
  197. struct filepackages *packageslump;
  198. int putat = 0;
  199. ensure_package_clientdata(pkg);
  200. if (file_tail == NULL)
  201. file_tail = &pkg->clientdata->files;
  202. /* Make sure we're at the end. */
  203. while ((*file_tail) != NULL) {
  204. file_tail = &((*file_tail)->next);
  205. }
  206. /* Create a new node. */
  207. newent = nfmalloc(sizeof(struct fileinlist));
  208. newent->namenode = findnamenode(filename, flags);
  209. newent->next = NULL;
  210. *file_tail = newent;
  211. file_tail = &newent->next;
  212. /* Add pkg to newent's package list. */
  213. packageslump = newent->namenode->packages;
  214. putat = 0;
  215. if (packageslump) {
  216. while (putat < PERFILEPACKAGESLUMP && packageslump->pkgs[putat])
  217. putat++;
  218. if (putat >= PERFILEPACKAGESLUMP)
  219. packageslump = NULL;
  220. }
  221. if (!packageslump) {
  222. packageslump = nfmalloc(sizeof(struct filepackages));
  223. packageslump->more = newent->namenode->packages;
  224. newent->namenode->packages = packageslump;
  225. putat = 0;
  226. }
  227. packageslump->pkgs[putat]= pkg;
  228. if (++putat < PERFILEPACKAGESLUMP)
  229. packageslump->pkgs[putat] = NULL;
  230. /* Return the position for the next guy. */
  231. return file_tail;
  232. }
  233. /**
  234. * Load the list of files in this package into memory, or update the
  235. * list if it is there but stale.
  236. */
  237. void
  238. ensure_packagefiles_available(struct pkginfo *pkg)
  239. {
  240. static int fd;
  241. const char *filelistfile;
  242. struct fileinlist **lendp;
  243. struct stat stat_buf;
  244. char *loaded_list, *loaded_list_end, *thisline, *nextline, *ptr;
  245. if (pkg->clientdata && pkg->clientdata->fileslistvalid)
  246. return;
  247. ensure_package_clientdata(pkg);
  248. /* Throw away any stale data, if there was any. */
  249. pkg_files_blank(pkg);
  250. /* Packages which aren't installed don't have a files list. */
  251. if (pkg->status == stat_notinstalled) {
  252. pkg->clientdata->fileslistvalid = true;
  253. return;
  254. }
  255. filelistfile = pkgadminfile(pkg, &pkg->installed, LISTFILE);
  256. onerr_abort++;
  257. fd= open(filelistfile,O_RDONLY);
  258. if (fd==-1) {
  259. if (errno != ENOENT)
  260. ohshite(_("unable to open files list file for package `%.250s'"),
  261. pkg->set->name);
  262. onerr_abort--;
  263. if (pkg->status != stat_configfiles) {
  264. if (saidread == 1) putc('\n',stderr);
  265. warning(_("files list file for package `%.250s' missing, assuming "
  266. "package has no files currently installed."), pkg->set->name);
  267. }
  268. pkg->clientdata->files = NULL;
  269. pkg->clientdata->fileslistvalid = true;
  270. return;
  271. }
  272. push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd);
  273. if(fstat(fd, &stat_buf))
  274. ohshite(_("unable to stat files list file for package '%.250s'"),
  275. pkg->set->name);
  276. if (!S_ISREG(stat_buf.st_mode))
  277. ohshit(_("files list for package '%.250s' is not a regular file"),
  278. pkg->set->name);
  279. if (stat_buf.st_size) {
  280. loaded_list = nfmalloc(stat_buf.st_size);
  281. loaded_list_end = loaded_list + stat_buf.st_size;
  282. if (fd_read(fd, loaded_list, stat_buf.st_size) < 0)
  283. ohshite(_("reading files list for package '%.250s'"), pkg->set->name);
  284. lendp= &pkg->clientdata->files;
  285. thisline = loaded_list;
  286. while (thisline < loaded_list_end) {
  287. if (!(ptr = memchr(thisline, '\n', loaded_list_end - thisline)))
  288. ohshit(_("files list file for package '%.250s' is missing final newline"),
  289. pkg->set->name);
  290. /* Where to start next time around. */
  291. nextline = ptr + 1;
  292. /* Strip trailing ‘/’. */
  293. if (ptr > thisline && ptr[-1] == '/') ptr--;
  294. /* Add the file to the list. */
  295. if (ptr == thisline)
  296. ohshit(_("files list file for package `%.250s' contains empty filename"),
  297. pkg->set->name);
  298. *ptr = '\0';
  299. lendp = pkg_files_add_file(pkg, thisline, fnn_nocopy, lendp);
  300. thisline = nextline;
  301. }
  302. }
  303. pop_cleanup(ehflag_normaltidy); /* fd = open() */
  304. if (close(fd))
  305. ohshite(_("error closing files list file for package `%.250s'"),
  306. pkg->set->name);
  307. onerr_abort--;
  308. pkg->clientdata->fileslistvalid = true;
  309. }
  310. #if defined(HAVE_LINUX_FIEMAP_H)
  311. static int
  312. pkg_sorter_by_listfile_phys_offs(const void *a, const void *b)
  313. {
  314. const struct pkginfo *pa = *(const struct pkginfo **)a;
  315. const struct pkginfo *pb = *(const struct pkginfo **)b;
  316. /* We can't simply subtract, because the difference may be greater than
  317. * INT_MAX. */
  318. if (pa->clientdata->listfile_phys_offs < pb->clientdata->listfile_phys_offs)
  319. return -1;
  320. else
  321. return 1;
  322. }
  323. static void
  324. pkg_files_optimize_load(struct pkg_array *array)
  325. {
  326. struct statfs fs;
  327. int i;
  328. /* Get the filesystem block size. */
  329. if (statfs(pkgadmindir(), &fs) < 0)
  330. return;
  331. /* Sort packages by the physical location of their list files, so that
  332. * scanning them later will minimize disk drive head movements. */
  333. for (i = 0; i < array->n_pkgs; i++) {
  334. struct pkginfo *pkg = array->pkgs[i];
  335. struct {
  336. struct fiemap fiemap;
  337. struct fiemap_extent extent;
  338. } fm;
  339. const char *listfile;
  340. int fd;
  341. ensure_package_clientdata(pkg);
  342. if (pkg->status == stat_notinstalled ||
  343. pkg->clientdata->listfile_phys_offs != 0)
  344. continue;
  345. pkg->clientdata->listfile_phys_offs = -1;
  346. listfile = pkgadminfile(pkg, &pkg->installed, LISTFILE);
  347. fd = open(listfile, O_RDONLY);
  348. if (fd < 0)
  349. continue;
  350. memset(&fm, 0, sizeof(fm));
  351. fm.fiemap.fm_start = 0;
  352. fm.fiemap.fm_length = fs.f_bsize;
  353. fm.fiemap.fm_flags = 0;
  354. fm.fiemap.fm_extent_count = 1;
  355. if (ioctl(fd, FS_IOC_FIEMAP, (unsigned long)&fm) == 0)
  356. pkg->clientdata->listfile_phys_offs = fm.fiemap.fm_extents[0].fe_physical;
  357. close(fd);
  358. }
  359. pkg_array_sort(array, pkg_sorter_by_listfile_phys_offs);
  360. }
  361. #elif defined(HAVE_POSIX_FADVISE)
  362. static void
  363. pkg_files_optimize_load(struct pkg_array *array)
  364. {
  365. int i;
  366. /* Ask the kernel to start preloading the list files, so as to get a
  367. * boost when later we actually load them. */
  368. for (i = 0; i < array->n_pkgs; i++) {
  369. struct pkginfo *pkg = array->pkgs[i];
  370. const char *listfile;
  371. int fd;
  372. listfile = pkgadminfile(pkg, &pkg->installed, LISTFILE);
  373. fd = open(listfile, O_RDONLY | O_NONBLOCK);
  374. if (fd != -1) {
  375. posix_fadvise(fd, 0, 0, POSIX_FADV_WILLNEED);
  376. close(fd);
  377. }
  378. }
  379. }
  380. #else
  381. static void
  382. pkg_files_optimize_load(struct pkg_array *array)
  383. {
  384. }
  385. #endif
  386. void ensure_allinstfiles_available(void) {
  387. struct pkg_array array;
  388. struct pkginfo *pkg;
  389. struct progress progress;
  390. int i;
  391. if (allpackagesdone) return;
  392. if (saidread<2) {
  393. int max = pkg_db_count_pkg();
  394. saidread=1;
  395. progress_init(&progress, _("(Reading database ... "), max);
  396. }
  397. pkg_array_init_from_db(&array);
  398. pkg_files_optimize_load(&array);
  399. for (i = 0; i < array.n_pkgs; i++) {
  400. pkg = array.pkgs[i];
  401. ensure_packagefiles_available(pkg);
  402. if (saidread == 1)
  403. progress_step(&progress);
  404. }
  405. pkg_array_destroy(&array);
  406. allpackagesdone = true;
  407. if (saidread==1) {
  408. progress_done(&progress);
  409. printf(P_("%d file or directory currently installed.)\n",
  410. "%d files and directories currently installed.)\n", nfiles),
  411. nfiles);
  412. saidread=2;
  413. }
  414. }
  415. void ensure_allinstfiles_available_quiet(void) {
  416. saidread=2;
  417. ensure_allinstfiles_available();
  418. }
  419. /*
  420. * If mask is nonzero, will not write any file whose filenamenode
  421. * has any flag bits set in mask.
  422. */
  423. void
  424. write_filelist_except(struct pkginfo *pkg, struct pkgbin *pkgbin,
  425. struct fileinlist *list, enum fnnflags mask)
  426. {
  427. static struct varbuf newvb;
  428. const char *listfile;
  429. FILE *file;
  430. listfile = pkgadminfile(pkg, pkgbin, LISTFILE);
  431. varbuf_reset(&newvb);
  432. varbuf_add_str(&newvb, listfile);
  433. varbuf_add_str(&newvb, NEWDBEXT);
  434. varbuf_end_str(&newvb);
  435. file= fopen(newvb.buf,"w+");
  436. if (!file)
  437. ohshite(_("unable to create updated files list file for package %s"),
  438. pkg->set->name);
  439. push_cleanup(cu_closestream, ehflag_bombout, NULL, 0, 1, (void *)file);
  440. while (list) {
  441. if (!(mask && (list->namenode->flags & mask))) {
  442. fputs(list->namenode->name,file);
  443. putc('\n',file);
  444. }
  445. list= list->next;
  446. }
  447. if (ferror(file))
  448. ohshite(_("failed to write to updated files list file for package %s"),
  449. pkg->set->name);
  450. if (fflush(file))
  451. ohshite(_("failed to flush updated files list file for package %s"),
  452. pkg->set->name);
  453. if (fsync(fileno(file)))
  454. ohshite(_("failed to sync updated files list file for package %s"),
  455. pkg->set->name);
  456. pop_cleanup(ehflag_normaltidy); /* file = fopen() */
  457. if (fclose(file))
  458. ohshite(_("failed to close updated files list file for package %s"),
  459. pkg->set->name);
  460. if (rename(newvb.buf, listfile))
  461. ohshite(_("failed to install updated files list file for package %s"),
  462. pkg->set->name);
  463. dir_sync_path(pkgadmindir());
  464. note_must_reread_files_inpackage(pkg);
  465. }
  466. /*
  467. * Initializes an iterator that appears to go through the file
  468. * list ‘files’ in reverse order, returning the namenode from
  469. * each. What actually happens is that we walk the list here,
  470. * building up a reverse list, and then peel it apart one
  471. * entry at a time.
  472. */
  473. void reversefilelist_init(struct reversefilelistiter *iterptr,
  474. struct fileinlist *files) {
  475. struct fileinlist *newent;
  476. iterptr->todo = NULL;
  477. while (files) {
  478. newent= m_malloc(sizeof(struct fileinlist));
  479. newent->namenode= files->namenode;
  480. newent->next= iterptr->todo;
  481. iterptr->todo= newent;
  482. files= files->next;
  483. }
  484. }
  485. struct filenamenode *reversefilelist_next(struct reversefilelistiter *iterptr) {
  486. struct filenamenode *ret;
  487. struct fileinlist *todo;
  488. todo= iterptr->todo;
  489. if (!todo)
  490. return NULL;
  491. ret= todo->namenode;
  492. iterptr->todo= todo->next;
  493. free(todo);
  494. return ret;
  495. }
  496. /*
  497. * Clients must call this function to clean up the reversefilelistiter
  498. * if they wish to break out of the iteration before it is all done.
  499. * Calling this function is not necessary if reversefilelist_next has
  500. * been called until it returned 0.
  501. */
  502. void reversefilelist_abort(struct reversefilelistiter *iterptr) {
  503. while (reversefilelist_next(iterptr));
  504. }
  505. struct fileiterator {
  506. struct filenamenode *namenode;
  507. int nbinn;
  508. };
  509. /* This must always be a power of two. If you change it consider changing
  510. * the per-character hashing factor (currently 1785 = 137 * 13) too. */
  511. #define BINS (1 << 17)
  512. static struct filenamenode *bins[BINS];
  513. struct fileiterator *iterfilestart(void) {
  514. struct fileiterator *i;
  515. i= m_malloc(sizeof(struct fileiterator));
  516. i->namenode = NULL;
  517. i->nbinn= 0;
  518. return i;
  519. }
  520. struct filenamenode *iterfilenext(struct fileiterator *i) {
  521. struct filenamenode *r= NULL;
  522. while (!i->namenode) {
  523. if (i->nbinn >= BINS)
  524. return NULL;
  525. i->namenode= bins[i->nbinn++];
  526. }
  527. r= i->namenode;
  528. i->namenode= r->next;
  529. return r;
  530. }
  531. void iterfileend(struct fileiterator *i) {
  532. free(i);
  533. }
  534. void filesdbinit(void) {
  535. struct filenamenode *fnn;
  536. int i;
  537. pkgadmindir_init();
  538. for (i=0; i<BINS; i++)
  539. for (fnn= bins[i]; fnn; fnn= fnn->next) {
  540. fnn->flags= 0;
  541. fnn->oldhash = NULL;
  542. fnn->filestat = NULL;
  543. }
  544. }
  545. static int hash(const char *name) {
  546. int v= 0;
  547. while (*name) { v *= 1787; v += *name; name++; }
  548. return v;
  549. }
  550. struct filenamenode *findnamenode(const char *name, enum fnnflags flags) {
  551. struct filenamenode **pointerp, *newnode;
  552. const char *orig_name = name;
  553. /* We skip initial slashes and ‘./’ pairs, and add our own single
  554. * leading slash. */
  555. name = path_skip_slash_dotslash(name);
  556. pointerp= bins + (hash(name) & (BINS-1));
  557. while (*pointerp) {
  558. /* XXX: Why is the assert needed? It's checking already added entries. */
  559. assert((*pointerp)->name[0] == '/');
  560. if (!strcmp((*pointerp)->name+1,name)) break;
  561. pointerp= &(*pointerp)->next;
  562. }
  563. if (*pointerp) return *pointerp;
  564. if (flags & fnn_nonew)
  565. return NULL;
  566. newnode= nfmalloc(sizeof(struct filenamenode));
  567. newnode->packages = NULL;
  568. if((flags & fnn_nocopy) && name > orig_name && name[-1] == '/')
  569. newnode->name = name - 1;
  570. else {
  571. char *newname= nfmalloc(strlen(name)+2);
  572. newname[0]= '/'; strcpy(newname+1,name);
  573. newnode->name= newname;
  574. }
  575. newnode->flags= 0;
  576. newnode->next = NULL;
  577. newnode->divert = NULL;
  578. newnode->statoverride = NULL;
  579. newnode->filestat = NULL;
  580. newnode->trig_interested = NULL;
  581. *pointerp= newnode;
  582. nfiles++;
  583. return newnode;
  584. }
  585. /* vi: ts=8 sw=2
  586. */