filesdb.c 18 KB

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