filesdb.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /*
  2. * dpkg - main program for package management
  3. * filesdb.c - management of database of files installed on system
  4. *
  5. * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
  6. * Copyright (C) 2000 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
  10. * published by the Free Software Foundation; either version 2,
  11. * or (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful, but
  14. * 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
  19. * License along with dpkg; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include <assert.h>
  23. #include <unistd.h>
  24. #include <fcntl.h>
  25. #include <string.h>
  26. #include <errno.h>
  27. #include <sys/stat.h>
  28. #include <pwd.h>
  29. #include <grp.h>
  30. #include <sys/types.h>
  31. #include <config.h>
  32. #include <dpkg.h>
  33. #include <dpkg-db.h>
  34. #include "filesdb.h"
  35. #include "main.h"
  36. /*** Generic data structures and routines ***/
  37. static int allpackagesdone= 0;
  38. static int nfiles= 0;
  39. static struct diversion *diversions= 0;
  40. static FILE *diversionsfile= 0;
  41. static FILE *statoverridefile= 0;
  42. void note_must_reread_files_inpackage(struct pkginfo *pkg) {
  43. allpackagesdone= 0;
  44. ensure_package_clientdata(pkg);
  45. pkg->clientdata->fileslistvalid= 0;
  46. }
  47. static int saidread=0;
  48. /* load the list of files in this package into memory, or update the
  49. * list if it is there but stale
  50. */
  51. void ensure_packagefiles_available(struct pkginfo *pkg) {
  52. static struct varbuf fnvb;
  53. int fd;
  54. const char *filelistfile;
  55. struct fileinlist **lendp, *newent, *current;
  56. struct filepackages *packageslump;
  57. int search, findlast, putat;
  58. struct stat stat_buf;
  59. char *loaded_list, *loaded_list_end, *thisline, *nextline, *ptr;
  60. if (pkg->clientdata && pkg->clientdata->fileslistvalid) return;
  61. ensure_package_clientdata(pkg);
  62. /* Throw away any the stale data, if there was any. */
  63. for (current= pkg->clientdata->files;
  64. current;
  65. current= current->next) {
  66. /* For each file that used to be in the package,
  67. * go through looking for this package's entry in the list
  68. * of packages containing this file, and blank it out.
  69. */
  70. for (packageslump= current->namenode->packages;
  71. packageslump;
  72. packageslump= packageslump->more)
  73. for (search= 0;
  74. search < PERFILEPACKAGESLUMP && packageslump->pkgs[search];
  75. search++)
  76. if (packageslump->pkgs[search] == pkg) {
  77. /* Hah! Found it. */
  78. for (findlast= search+1;
  79. findlast < PERFILEPACKAGESLUMP && packageslump->pkgs[findlast];
  80. findlast++);
  81. findlast--;
  82. /* findlast is now the last occupied entry, which may be the same as
  83. * search. We blank out the entry for this package. We also
  84. * have to copy the last entry into the empty slot, because
  85. * the list is null-pointer-terminated.
  86. */
  87. packageslump->pkgs[search]= packageslump->pkgs[findlast];
  88. packageslump->pkgs[findlast]= 0;
  89. /* This may result in an empty link in the list. This is OK. */
  90. goto xit_search_to_delete_from_perfilenodelist;
  91. }
  92. xit_search_to_delete_from_perfilenodelist:
  93. ;
  94. /* The actual filelist links were allocated using nfmalloc, so
  95. * we shouldn't free them.
  96. */
  97. }
  98. pkg->clientdata->files= 0;
  99. /* Packages which aren't installed don't have a files list. */
  100. if (pkg->status == stat_notinstalled) {
  101. pkg->clientdata->fileslistvalid= 1; return;
  102. }
  103. filelistfile= pkgadminfile(pkg,LISTFILE);
  104. onerr_abort++;
  105. fd= open(filelistfile,O_RDONLY);
  106. if (fd==-1) {
  107. if (errno != ENOENT)
  108. ohshite(_("unable to open files list file for package `%.250s'"),pkg->name);
  109. onerr_abort--;
  110. if (pkg->status != stat_configfiles) {
  111. if (saidread == 1) putc('\n',stderr);
  112. fprintf(stderr,
  113. _("dpkg: serious warning: files list file for package `%.250s' missing,"
  114. " assuming package has no files currently installed.\n"), pkg->name);
  115. }
  116. pkg->clientdata->files= 0;
  117. pkg->clientdata->fileslistvalid= 1;
  118. return;
  119. }
  120. push_cleanup(cu_closefd,ehflag_bombout, 0,0, 1,&fd);
  121. if(fstat(fd, &stat_buf))
  122. ohshite("unable to stat files list file for package `%.250s'",pkg->name);
  123. if (stat_buf.st_size) {
  124. loaded_list = nfmalloc(stat_buf.st_size);
  125. loaded_list_end = loaded_list + stat_buf.st_size;
  126. fd_buf_copy(fd, loaded_list, stat_buf.st_size, _("files list for package `%.250s'"), pkg->name);
  127. lendp= &pkg->clientdata->files;
  128. thisline = loaded_list;
  129. while (thisline < loaded_list_end) {
  130. if (!(ptr = memchr(thisline, '\n', loaded_list_end - thisline)))
  131. ohshit("files list file for package `%.250s' is missing final newline",pkg->name);
  132. /* where to start next time around */
  133. nextline = ptr + 1;
  134. /* strip trailing "/" */
  135. if (ptr > thisline && ptr[-1] == '/') ptr--;
  136. /* add the file to the list */
  137. if (ptr == thisline)
  138. ohshit(_("files list file for package `%.250s' contains empty filename"),pkg->name);
  139. *ptr = 0;
  140. newent= nfmalloc(sizeof(struct fileinlist));
  141. newent->namenode= findnamenode(thisline, fnn_nocopy);
  142. newent->next= 0;
  143. *lendp= newent;
  144. lendp= &newent->next;
  145. thisline = nextline;
  146. }
  147. }
  148. pop_cleanup(ehflag_normaltidy); /* fd= open() */
  149. if (close(fd))
  150. ohshite(_("error closing files list file for package `%.250s'"),pkg->name);
  151. if (fnvb.used)
  152. ohshit(_("files list file for package `%.250s' is truncated"),pkg->name);
  153. onerr_abort--;
  154. for (newent= pkg->clientdata->files; newent; newent= newent->next) {
  155. packageslump= newent->namenode->packages;
  156. putat= 0;
  157. if (packageslump) {
  158. for (; putat < PERFILEPACKAGESLUMP && packageslump->pkgs[putat];
  159. putat++);
  160. if (putat >= PERFILEPACKAGESLUMP) packageslump= 0;
  161. }
  162. if (!packageslump) {
  163. packageslump= nfmalloc(sizeof(struct filepackages));
  164. packageslump->more= newent->namenode->packages;
  165. newent->namenode->packages= packageslump;
  166. }
  167. packageslump->pkgs[putat]= pkg;
  168. if (++putat < PERFILEPACKAGESLUMP) packageslump->pkgs[putat]= 0;
  169. }
  170. pkg->clientdata->fileslistvalid= 1;
  171. }
  172. void ensure_allinstfiles_available(void) {
  173. struct pkgiterator *it;
  174. struct pkginfo *pkg;
  175. if (allpackagesdone) return;
  176. if (saidread<2) {
  177. saidread=1;
  178. printf(_("(Reading database ... "));
  179. }
  180. it= iterpkgstart();
  181. while ((pkg= iterpkgnext(it)) != 0) ensure_packagefiles_available(pkg);
  182. iterpkgend(it);
  183. allpackagesdone= 1;
  184. if (saidread==1) {
  185. printf(_("%d files and directories currently installed.)\n"),nfiles);
  186. saidread=2;
  187. }
  188. }
  189. void ensure_allinstfiles_available_quiet(void) {
  190. saidread=2;
  191. ensure_allinstfiles_available();
  192. }
  193. void write_filelist_except(struct pkginfo *pkg, struct fileinlist *list, int leaveout) {
  194. /* If leaveout is nonzero, will not write any file whose filenamenode
  195. * has the fnnf_elide_other_lists flag set.
  196. */
  197. static struct varbuf vb, newvb;
  198. FILE *file;
  199. varbufreset(&vb);
  200. varbufaddstr(&vb,admindir);
  201. varbufaddstr(&vb,"/" INFODIR);
  202. varbufaddstr(&vb,pkg->name);
  203. varbufaddstr(&vb,"." LISTFILE);
  204. varbufaddc(&vb,0);
  205. varbufreset(&newvb);
  206. varbufaddstr(&newvb,vb.buf);
  207. varbufaddstr(&newvb,NEWDBEXT);
  208. varbufaddc(&newvb,0);
  209. file= fopen(newvb.buf,"w+");
  210. if (!file)
  211. ohshite(_("unable to create updated files list file for package %s"),pkg->name);
  212. push_cleanup(cu_closefile,ehflag_bombout, 0,0, 1,(void*)file);
  213. while (list) {
  214. if (!(leaveout && (list->namenode->flags & fnnf_elide_other_lists))) {
  215. fputs(list->namenode->name,file);
  216. putc('\n',file);
  217. }
  218. list= list->next;
  219. }
  220. if (ferror(file))
  221. ohshite(_("failed to write to updated files list file for package %s"),pkg->name);
  222. if (fflush(file))
  223. ohshite(_("failed to flush updated files list file for package %s"),pkg->name);
  224. if (fsync(fileno(file)))
  225. ohshite(_("failed to sync updated files list file for package %s"),pkg->name);
  226. pop_cleanup(ehflag_normaltidy); /* file= fopen() */
  227. if (fclose(file))
  228. ohshite(_("failed to close updated files list file for package %s"),pkg->name);
  229. if (rename(newvb.buf,vb.buf))
  230. ohshite(_("failed to install updated files list file for package %s"),pkg->name);
  231. note_must_reread_files_inpackage(pkg);
  232. }
  233. void reversefilelist_init(struct reversefilelistiter *iterptr,
  234. struct fileinlist *files) {
  235. /* Initialises an iterator that appears to go through the file
  236. * list `files' in reverse order, returning the namenode from
  237. * each. What actually happens is that we walk the list here,
  238. * building up a reverse list, and then peel it apart one
  239. * entry at a time.
  240. */
  241. struct fileinlist *newent;
  242. iterptr->todo= 0;
  243. while (files) {
  244. newent= m_malloc(sizeof(struct fileinlist));
  245. newent->namenode= files->namenode;
  246. newent->next= iterptr->todo;
  247. iterptr->todo= newent;
  248. files= files->next;
  249. }
  250. }
  251. struct filenamenode *reversefilelist_next(struct reversefilelistiter *iterptr) {
  252. struct filenamenode *ret;
  253. struct fileinlist *todo;
  254. todo= iterptr->todo;
  255. if (!todo) return 0;
  256. ret= todo->namenode;
  257. iterptr->todo= todo->next;
  258. free(todo);
  259. return ret;
  260. }
  261. void reversefilelist_abort(struct reversefilelistiter *iterptr) {
  262. /* Clients must call this function to clean up the reversefilelistiter
  263. * if they wish to break out of the iteration before it is all done.
  264. * Calling this function is not necessary if reversefilelist_next has
  265. * been called until it returned 0.
  266. */
  267. while (reversefilelist_next(iterptr));
  268. }
  269. void ensure_statoverrides(void) {
  270. static struct varbuf vb;
  271. struct stat stab1, stab2;
  272. FILE *file;
  273. char *loaded_list, *loaded_list_end, *thisline, *nextline, *ptr;
  274. struct filestatoverride *fso;
  275. struct filenamenode *fnn;
  276. varbufreset(&vb);
  277. varbufaddstr(&vb,admindir);
  278. varbufaddstr(&vb,"/" STATOVERRIDEFILE);
  279. varbufaddc(&vb,0);
  280. onerr_abort++;
  281. file= fopen(vb.buf,"r");
  282. if (!file) {
  283. if (errno != ENOENT) ohshite(_("failed to open statoverride file"));
  284. if (!statoverridefile) { onerr_abort--; return; }
  285. } else {
  286. if (fstat(fileno(file),&stab2))
  287. ohshite(_("failed to fstat statoverride file"));
  288. if (statoverridefile) {
  289. if (fstat(fileno(statoverridefile),&stab1))
  290. ohshite(_("failed to fstat previous statoverride file"));
  291. if (stab1.st_dev == stab2.st_dev && stab1.st_ino == stab2.st_ino) {
  292. fclose(file); onerr_abort--; return;
  293. }
  294. }
  295. }
  296. if (statoverridefile) fclose(statoverridefile);
  297. statoverridefile= file;
  298. /* If the statoverride list is empty we don't need to bother reading it. */
  299. if (!stab2.st_size) {
  300. onerr_abort--;
  301. return;
  302. }
  303. loaded_list = nfmalloc(stab2.st_size);
  304. loaded_list_end = loaded_list + stab2.st_size;
  305. fd_buf_copy(fileno(file), loaded_list, stab2.st_size, _("statoverride file `%.250s'"), vb.buf);
  306. thisline = loaded_list;
  307. while (thisline<loaded_list_end) {
  308. char* endptr;
  309. fso= nfmalloc(sizeof(struct filestatoverride));
  310. if (!(ptr = memchr(thisline, '\n', loaded_list_end - thisline)))
  311. ohshit("statoverride file is missing final newline");
  312. /* where to start next time around */
  313. nextline = ptr + 1;
  314. if (ptr == thisline)
  315. ohshit(_("statoverride file contains empty line"));
  316. *ptr = 0;
  317. /* Extract the uid */
  318. if (!(ptr=memchr(thisline, ' ', nextline-thisline)))
  319. ohshit("syntax error in statusoverride file ");
  320. *ptr=0;
  321. if (thisline[0]=='#') {
  322. fso->uid=strtol(thisline + 1, &endptr, 10);
  323. if (*endptr!=0)
  324. ohshit("syntax error: invalid uid in statusoverride file ");
  325. } else {
  326. struct passwd* pw = getpwnam(thisline);
  327. if (pw==NULL)
  328. ohshit("syntax error: unknown user `%s' in statusoverride file ", thisline);
  329. fso->uid=pw->pw_uid;
  330. }
  331. /* Move to the next bit */
  332. thisline=ptr+1;
  333. if (thisline>=loaded_list_end)
  334. ohshit("unexpected end of line in statusoverride file");
  335. /* Extract the gid */
  336. if (!(ptr=memchr(thisline, ' ', nextline-thisline)))
  337. ohshit("syntax error in statusoverride file ");
  338. *ptr=0;
  339. if (thisline[0]=='#') {
  340. fso->gid=strtol(thisline + 1, &endptr, 10);
  341. if (*endptr!=0)
  342. ohshit("syntax error: invalid gid in statusoverride file ");
  343. } else {
  344. struct group* gr = getgrnam(thisline);
  345. if (gr==NULL)
  346. ohshit("syntax error: unknown group `%s' in statusoverride file ", thisline);
  347. fso->gid=gr->gr_gid;
  348. }
  349. /* Move to the next bit */
  350. thisline=ptr+1;
  351. if (thisline>=loaded_list_end)
  352. ohshit("unexecpted end of line in statusoverride file");
  353. /* Extract the mode */
  354. if (!(ptr=memchr(thisline, ' ', nextline-thisline)))
  355. ohshit("syntax error in statusoverride file ");
  356. *ptr=0;
  357. fso->mode=strtol(thisline, &endptr, 8);
  358. if (*endptr!=0)
  359. ohshit("syntax error: invalid mode in statusoverride file ");
  360. /* Move to the next bit */
  361. thisline=ptr+1;
  362. if (thisline>=loaded_list_end)
  363. ohshit("unexecpted end of line in statusoverride file");
  364. fnn= findnamenode(thisline, 0);
  365. if (fnn->statoverride)
  366. ohshit("multiple statusoverides present for file `%.250s'", thisline);
  367. fnn->statoverride=fso;
  368. /* Moving on.. */
  369. thisline=nextline;
  370. }
  371. onerr_abort--;
  372. }
  373. void ensure_diversions(void) {
  374. static struct varbuf vb;
  375. struct stat stab1, stab2;
  376. char linebuf[MAXDIVERTFILENAME];
  377. FILE *file;
  378. struct diversion *ov, *oicontest, *oialtname;
  379. int l;
  380. varbufreset(&vb);
  381. varbufaddstr(&vb,admindir);
  382. varbufaddstr(&vb,"/" DIVERSIONSFILE);
  383. varbufaddc(&vb,0);
  384. onerr_abort++;
  385. file= fopen(vb.buf,"r");
  386. if (!file) {
  387. if (errno != ENOENT) ohshite(_("failed to open diversions file"));
  388. if (!diversionsfile) { onerr_abort--; return; }
  389. } else if (diversionsfile) {
  390. if (fstat(fileno(diversionsfile),&stab1))
  391. ohshite(_("failed to fstat previous diversions file"));
  392. if (fstat(fileno(file),&stab2))
  393. ohshite(_("failed to fstat diversions file"));
  394. if (stab1.st_dev == stab2.st_dev && stab1.st_ino == stab2.st_ino) {
  395. fclose(file); onerr_abort--; return;
  396. }
  397. }
  398. l= fcntl(fileno(file), F_GETFD);
  399. if (l >= 0) fcntl(fileno(file), F_SETFD, l | FD_CLOEXEC);
  400. if (diversionsfile) fclose(diversionsfile);
  401. diversionsfile= file;
  402. for (ov= diversions; ov; ov= ov->next) {
  403. ov->useinstead->divert->camefrom->divert= 0;
  404. ov->useinstead->divert= 0;
  405. }
  406. diversions= 0;
  407. if (!file) { onerr_abort--; return; }
  408. while (fgets(linebuf,sizeof(linebuf),file)) {
  409. oicontest= nfmalloc(sizeof(struct diversion));
  410. oialtname= nfmalloc(sizeof(struct diversion));
  411. l= strlen(linebuf);
  412. if (l == 0) ohshit(_("fgets gave an empty string from diversions [i]"));
  413. if (linebuf[--l] != '\n') ohshit(_("diversions file has too-long line or EOF [i]"));
  414. linebuf[l]= 0;
  415. oialtname->camefrom= findnamenode(linebuf, 0);
  416. oialtname->useinstead= 0;
  417. if (!fgets(linebuf,sizeof(linebuf),file)) {
  418. if (ferror(file)) ohshite(_("read error in diversions [ii]"));
  419. else ohshit(_("unexpected EOF in diversions [ii]"));
  420. }
  421. l= strlen(linebuf);
  422. if (l == 0) ohshit(_("fgets gave an empty string from diversions [ii]"));
  423. if (linebuf[--l] != '\n') ohshit(_("diversions file has too-long line or EOF [ii]"));
  424. linebuf[l]= 0;
  425. oicontest->useinstead= findnamenode(linebuf, 0);
  426. oicontest->camefrom= 0;
  427. if (!fgets(linebuf,sizeof(linebuf),file)) {
  428. if (ferror(file)) ohshite(_("read error in diversions [iii]"));
  429. else ohshit(_("unexpected EOF in diversions [iii]"));
  430. }
  431. l= strlen(linebuf);
  432. if (l == 0) ohshit(_("fgets gave an empty string from diversions [iii]"));
  433. if (linebuf[--l] != '\n') ohshit(_("diversions file has too-long line or EOF [ii]"));
  434. linebuf[l]= 0;
  435. oicontest->pkg= oialtname->pkg=
  436. strcmp(linebuf,":") ? findpackage(linebuf) : 0;
  437. if (oialtname->camefrom->divert || oicontest->useinstead->divert)
  438. ohshit(_("conflicting diversions involving `%.250s' or `%.250s'"),
  439. oialtname->camefrom->name, oicontest->useinstead->name);
  440. oialtname->camefrom->divert= oicontest;
  441. oicontest->useinstead->divert= oialtname;
  442. oicontest->next= diversions;
  443. diversions= oicontest;
  444. }
  445. if (ferror(file)) ohshite(_("read error in diversions [i]"));
  446. onerr_abort--;
  447. }
  448. struct fileiterator {
  449. struct filenamenode *namenode;
  450. int nbinn;
  451. };
  452. #define BINS (1 << 13)
  453. /* This must always be a power of two. If you change it
  454. * consider changing the per-character hashing factor (currently
  455. * 1785 = 137*13) too.
  456. */
  457. static struct filenamenode *bins[BINS];
  458. struct fileiterator *iterfilestart(void) {
  459. struct fileiterator *i;
  460. i= m_malloc(sizeof(struct fileiterator));
  461. i->namenode= 0;
  462. i->nbinn= 0;
  463. return i;
  464. }
  465. struct filenamenode *iterfilenext(struct fileiterator *i) {
  466. struct filenamenode *r= NULL;
  467. while (!i->namenode) {
  468. if (i->nbinn >= BINS) return 0;
  469. i->namenode= bins[i->nbinn++];
  470. }
  471. r= i->namenode;
  472. i->namenode= r->next;
  473. return r;
  474. }
  475. void iterfileend(struct fileiterator *i) {
  476. free(i);
  477. }
  478. void filesdbinit(void) {
  479. struct filenamenode *fnn;
  480. int i;
  481. for (i=0; i<BINS; i++)
  482. for (fnn= bins[i]; fnn; fnn= fnn->next) {
  483. fnn->flags= 0;
  484. fnn->oldhash= 0;
  485. fnn->filestat= 0;
  486. }
  487. }
  488. static int hash(const char *name) {
  489. int v= 0;
  490. while (*name) { v *= 1785; v += *name; name++; }
  491. return v;
  492. }
  493. struct filenamenode *findnamenode(const char *name, enum fnnflags flags) {
  494. struct filenamenode **pointerp, *newnode;
  495. const char *orig_name = name;
  496. /* We skip initial slashes and ./ pairs, and add our own single leading slash. */
  497. name= skip_slash_dotslash(name);
  498. pointerp= bins + (hash(name) & (BINS-1));
  499. while (*pointerp) {
  500. /* Why is this assert nescessary? It is checking already added entries. */
  501. assert((*pointerp)->name[0] == '/');
  502. if (!strcmp((*pointerp)->name+1,name)) break;
  503. pointerp= &(*pointerp)->next;
  504. }
  505. if (*pointerp) return *pointerp;
  506. newnode= nfmalloc(sizeof(struct filenamenode));
  507. newnode->packages= 0;
  508. if((flags & fnn_nocopy) && name > orig_name && name[-1] == '/')
  509. newnode->name = (char *)name - 1;
  510. else {
  511. newnode->name= nfmalloc(strlen(name)+2);
  512. newnode->name[0]= '/'; strcpy(newnode->name+1,name);
  513. }
  514. newnode->flags= 0;
  515. newnode->next= 0;
  516. newnode->divert= 0;
  517. newnode->statoverride= 0;
  518. newnode->filestat= 0;
  519. *pointerp= newnode;
  520. nfiles++;
  521. return newnode;
  522. }
  523. /* vi: ts=8 sw=2
  524. */