vac.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "stdinc.h"
  10. #include "vac.h"
  11. #include "dat.h"
  12. #include "fns.h"
  13. // TODO: qids
  14. void
  15. usage(void)
  16. {
  17. fprint(2, "vac [-imqsv] [-a archive.vac] [-b bsize] [-d old.vac] [-f new.vac] [-e exclude]... [-h host] file...\n");
  18. threadexitsall("usage");
  19. }
  20. enum
  21. {
  22. BlockSize = 8*1024,
  23. };
  24. struct
  25. {
  26. int nfile;
  27. int ndir;
  28. int64_t data;
  29. int64_t skipdata;
  30. int skipfiles;
  31. } stats;
  32. int qdiff;
  33. int merge;
  34. int verbose;
  35. char *host;
  36. VtConn *z;
  37. VacFs *fs;
  38. char *archivefile;
  39. char *vacfile;
  40. int vacmerge(VacFile*, char*);
  41. void vac(VacFile*, VacFile*, char*, Dir*);
  42. void vacstdin(VacFile*, char*);
  43. VacFile *recentarchive(VacFs*, char*);
  44. static uint64_t unittoull(char*);
  45. static void warn(char *fmt, ...);
  46. static void removevacfile(void);
  47. void
  48. threadmain(int argc, char **argv)
  49. {
  50. int i, j, fd, n, printstats;
  51. Dir *d;
  52. char *s;
  53. uvlong u;
  54. VacFile *f, *fdiff;
  55. VacFs *fsdiff;
  56. int blocksize;
  57. int outfd;
  58. char *stdinname;
  59. char *diffvac;
  60. uvlong qid;
  61. fmtinstall('F', vtfcallfmt);
  62. fmtinstall('H', encodefmt);
  63. fmtinstall('V', vtscorefmt);
  64. blocksize = BlockSize;
  65. stdinname = nil;
  66. printstats = 0;
  67. fsdiff = nil;
  68. diffvac = nil;
  69. ARGBEGIN{
  70. case 'V':
  71. chattyventi++;
  72. break;
  73. case 'a':
  74. archivefile = EARGF(usage());
  75. break;
  76. case 'b':
  77. u = unittoull(EARGF(usage()));
  78. if(u < 512)
  79. u = 512;
  80. if(u > VtMaxLumpSize)
  81. u = VtMaxLumpSize;
  82. blocksize = u;
  83. break;
  84. case 'd':
  85. diffvac = EARGF(usage());
  86. break;
  87. case 'e':
  88. excludepattern(EARGF(usage()));
  89. break;
  90. case 'f':
  91. vacfile = EARGF(usage());
  92. break;
  93. case 'h':
  94. host = EARGF(usage());
  95. break;
  96. case 'i':
  97. stdinname = EARGF(usage());
  98. break;
  99. case 'm':
  100. merge++;
  101. break;
  102. case 'q':
  103. qdiff++;
  104. break;
  105. case 's':
  106. printstats++;
  107. break;
  108. case 'v':
  109. verbose++;
  110. break;
  111. case 'x':
  112. loadexcludefile(EARGF(usage()));
  113. break;
  114. default:
  115. usage();
  116. }ARGEND
  117. if(argc == 0 && !stdinname)
  118. usage();
  119. if(archivefile && (vacfile || diffvac)){
  120. fprint(2, "cannot use -a with -f, -d\n");
  121. usage();
  122. }
  123. z = vtdial(host);
  124. if(z == nil)
  125. sysfatal("could not connect to server: %r");
  126. if(vtconnect(z) < 0)
  127. sysfatal("vtconnect: %r");
  128. // Setup:
  129. // fs is the output vac file system
  130. // f is directory in output vac to write new files
  131. // fdiff is corresponding directory in existing vac
  132. if(archivefile){
  133. VacFile *fp;
  134. char yyyy[5];
  135. char mmdd[10];
  136. char oldpath[40];
  137. Tm tm;
  138. fdiff = nil;
  139. if((outfd = open(archivefile, ORDWR)) < 0){
  140. if(access(archivefile, 0) >= 0)
  141. sysfatal("open %s: %r", archivefile);
  142. if((outfd = create(archivefile, OWRITE, 0666)) < 0)
  143. sysfatal("create %s: %r", archivefile);
  144. atexit(removevacfile); // because it is new
  145. if((fs = vacfscreate(z, blocksize, 512)) == nil)
  146. sysfatal("vacfscreate: %r");
  147. }else{
  148. if((fs = vacfsopen(z, archivefile, VtORDWR, 512)) == nil)
  149. sysfatal("vacfsopen %s: %r", archivefile);
  150. if((fdiff = recentarchive(fs, oldpath)) != nil){
  151. if(verbose)
  152. fprint(2, "diff %s\n", oldpath);
  153. }else
  154. if(verbose)
  155. fprint(2, "no recent archive to diff against\n");
  156. }
  157. // Create yyyy/mmdd.
  158. tm = *localtime(time(0));
  159. snprint(yyyy, sizeof yyyy, "%04d", tm.year+1900);
  160. fp = vacfsgetroot(fs);
  161. if((f = vacfilewalk(fp, yyyy)) == nil
  162. && (f = vacfilecreate(fp, yyyy, ModeDir|0555)) == nil)
  163. sysfatal("vacfscreate %s: %r", yyyy);
  164. vacfiledecref(fp);
  165. fp = f;
  166. snprint(mmdd, sizeof mmdd, "%02d%02d", tm.mon+1, tm.mday);
  167. n = 0;
  168. while((f = vacfilewalk(fp, mmdd)) != nil){
  169. vacfiledecref(f);
  170. n++;
  171. snprint(mmdd+4, sizeof mmdd-4, ".%d", n);
  172. }
  173. f = vacfilecreate(fp, mmdd, ModeDir|0555);
  174. if(f == nil)
  175. sysfatal("vacfscreate %s/%s: %r", yyyy, mmdd);
  176. vacfiledecref(fp);
  177. if(verbose)
  178. fprint(2, "archive %s/%s\n", yyyy, mmdd);
  179. }else{
  180. if(vacfile == nil)
  181. outfd = 1;
  182. else if((outfd = create(vacfile, OWRITE, 0666)) < 0)
  183. sysfatal("create %s: %r", vacfile);
  184. atexit(removevacfile);
  185. if((fs = vacfscreate(z, blocksize, 512)) == nil)
  186. sysfatal("vacfscreate: %r");
  187. f = vacfsgetroot(fs);
  188. fdiff = nil;
  189. if(diffvac){
  190. if((fsdiff = vacfsopen(z, diffvac, VtOREAD, 128)) == nil)
  191. warn("vacfsopen %s: %r", diffvac);
  192. else
  193. fdiff = vacfsgetroot(fsdiff);
  194. }
  195. }
  196. if(stdinname)
  197. vacstdin(f, stdinname);
  198. for(i=0; i<argc; i++){
  199. // We can't use / and . and .. and ../.. as valid archive
  200. // names, so expand to the list of files in the directory.
  201. if(argv[i][0] == 0){
  202. warn("empty string given as command-line argument");
  203. continue;
  204. }
  205. cleanname(argv[i]);
  206. if(strcmp(argv[i], "/") == 0
  207. || strcmp(argv[i], ".") == 0
  208. || strcmp(argv[i], "..") == 0
  209. || (strlen(argv[i]) > 3 && strcmp(argv[i]+strlen(argv[i])-3, "/..") == 0)){
  210. if((fd = open(argv[i], OREAD)) < 0){
  211. warn("open %s: %r", argv[i]);
  212. continue;
  213. }
  214. while((n = dirread(fd, &d)) > 0){
  215. for(j=0; j<n; j++){
  216. s = vtmalloc(strlen(argv[i])+1+strlen(d[j].name)+1);
  217. strcpy(s, argv[i]);
  218. strcat(s, "/");
  219. strcat(s, d[j].name);
  220. cleanname(s);
  221. vac(f, fdiff, s, &d[j]);
  222. }
  223. free(d);
  224. }
  225. close(fd);
  226. continue;
  227. }
  228. if((d = dirstat(argv[i])) == nil){
  229. warn("stat %s: %r", argv[i]);
  230. continue;
  231. }
  232. vac(f, fdiff, argv[i], d);
  233. free(d);
  234. }
  235. if(fdiff)
  236. vacfiledecref(fdiff);
  237. /*
  238. * Record the maximum qid so that vacs can be merged
  239. * without introducing overlapping qids. Older versions
  240. * of vac arranged that the root would have the largest
  241. * qid in the file system, but we can't do that anymore
  242. * (the root gets created first!).
  243. */
  244. if(_vacfsnextqid(fs, &qid) >= 0)
  245. vacfilesetqidspace(f, 0, qid);
  246. vacfiledecref(f);
  247. /*
  248. * Copy fsdiff's root block score into fs's slot for that,
  249. * so that vacfssync will copy it into root.prev for us.
  250. * Just nice documentation, no effect.
  251. */
  252. if(fsdiff)
  253. memmove(fs->score, fsdiff->score, VtScoreSize);
  254. if(vacfssync(fs) < 0)
  255. fprint(2, "vacfssync: %r\n");
  256. fprint(outfd, "vac:%V\n", fs->score);
  257. atexitdont(removevacfile);
  258. vacfsclose(fs);
  259. vthangup(z);
  260. if(printstats){
  261. fprint(2,
  262. "%d files, %d files skipped, %d directories\n"
  263. "%lld data bytes written, %lld data bytes skipped\n",
  264. stats.nfile, stats.skipfiles, stats.ndir, stats.data, stats.skipdata);
  265. dup(2, 1);
  266. packetstats();
  267. }
  268. threadexitsall(0);
  269. }
  270. VacFile*
  271. recentarchive(VacFs *fs, char *path)
  272. {
  273. VacFile *fp, *f;
  274. VacDirEnum *de;
  275. VacDir vd;
  276. char buf[10];
  277. int year, mmdd, nn, n, n1;
  278. char *p;
  279. fp = vacfsgetroot(fs);
  280. de = vdeopen(fp);
  281. year = 0;
  282. if(de){
  283. for(; vderead(de, &vd) > 0; vdcleanup(&vd)){
  284. if(strlen(vd.elem) != 4)
  285. continue;
  286. if((n = strtol(vd.elem, &p, 10)) < 1900 || *p != 0)
  287. continue;
  288. if(year < n)
  289. year = n;
  290. }
  291. }
  292. vdeclose(de);
  293. if(year == 0){
  294. vacfiledecref(fp);
  295. return nil;
  296. }
  297. snprint(buf, sizeof buf, "%04d", year);
  298. if((f = vacfilewalk(fp, buf)) == nil){
  299. fprint(2, "warning: dirread %s but cannot walk", buf);
  300. vacfiledecref(fp);
  301. return nil;
  302. }
  303. fp = f;
  304. de = vdeopen(fp);
  305. mmdd = 0;
  306. nn = 0;
  307. if(de){
  308. for(; vderead(de, &vd) > 0; vdcleanup(&vd)){
  309. if(strlen(vd.elem) < 4)
  310. continue;
  311. if((n = strtol(vd.elem, &p, 10)) < 100 || n > 1231 || p != vd.elem+4)
  312. continue;
  313. if(*p == '.'){
  314. if(p[1] == '0' || (n1 = strtol(p+1, &p, 10)) == 0 || *p != 0)
  315. continue;
  316. }else{
  317. if(*p != 0)
  318. continue;
  319. n1 = 0;
  320. }
  321. if(n < mmdd || (n == mmdd && n1 < nn))
  322. continue;
  323. mmdd = n;
  324. nn = n1;
  325. }
  326. }
  327. vdeclose(de);
  328. if(mmdd == 0){
  329. vacfiledecref(fp);
  330. return nil;
  331. }
  332. if(nn == 0)
  333. snprint(buf, sizeof buf, "%04d", mmdd);
  334. else
  335. snprint(buf, sizeof buf, "%04d.%d", mmdd, nn);
  336. if((f = vacfilewalk(fp, buf)) == nil){
  337. fprint(2, "warning: dirread %s but cannot walk", buf);
  338. vacfiledecref(fp);
  339. return nil;
  340. }
  341. vacfiledecref(fp);
  342. sprint(path, "%04d/%s", year, buf);
  343. return f;
  344. }
  345. static void
  346. removevacfile(void)
  347. {
  348. if(vacfile)
  349. remove(vacfile);
  350. }
  351. void
  352. plan9tovacdir(VacDir *vd, Dir *dir)
  353. {
  354. memset(vd, 0, sizeof *vd);
  355. vd->elem = dir->name;
  356. vd->uid = dir->uid;
  357. vd->gid = dir->gid;
  358. vd->mid = dir->muid;
  359. if(vd->mid == nil)
  360. vd->mid = "";
  361. vd->mtime = dir->mtime;
  362. vd->mcount = 0;
  363. vd->ctime = dir->mtime; /* ctime: not available on plan 9 */
  364. vd->atime = dir->atime;
  365. vd->size = dir->length;
  366. vd->mode = dir->mode & 0777;
  367. if(dir->mode & DMDIR)
  368. vd->mode |= ModeDir;
  369. if(dir->mode & DMAPPEND)
  370. vd->mode |= ModeAppend;
  371. if(dir->mode & DMEXCL)
  372. vd->mode |= ModeExclusive;
  373. vd->plan9 = 1;
  374. vd->p9path = dir->qid.path;
  375. vd->p9version = dir->qid.vers;
  376. }
  377. /*
  378. * Archive the file named name, which has stat info d,
  379. * into the vac directory fp (p = parent).
  380. *
  381. * If we're doing a vac -d against another archive, the
  382. * equivalent directory to fp in that archive is diffp.
  383. */
  384. void
  385. vac(VacFile *fp, VacFile *diffp, char *name, Dir *d)
  386. {
  387. char *elem, *s;
  388. static char buf[65536];
  389. int fd, i, n, bsize;
  390. int64_t off;
  391. Dir *dk; // kids
  392. VacDir vd, vddiff;
  393. VacFile *f, *fdiff;
  394. VtEntry e;
  395. if(!includefile(name)){
  396. warn("excluding %s%s", name, (d->mode&DMDIR) ? "/" : "");
  397. return;
  398. }
  399. if(d->mode&DMDIR)
  400. stats.ndir++;
  401. else
  402. stats.nfile++;
  403. if(merge && vacmerge(fp, name) >= 0)
  404. return;
  405. if(verbose)
  406. fprint(2, "%s%s\n", name, (d->mode&DMDIR) ? "/" : "");
  407. if((fd = open(name, OREAD)) < 0){
  408. warn("open %s: %r", name);
  409. return;
  410. }
  411. elem = strrchr(name, '/');
  412. if(elem)
  413. elem++;
  414. else
  415. elem = name;
  416. plan9tovacdir(&vd, d);
  417. if((f = vacfilecreate(fp, elem, vd.mode)) == nil){
  418. warn("vacfilecreate %s: %r", name);
  419. return;
  420. }
  421. if(diffp)
  422. fdiff = vacfilewalk(diffp, elem);
  423. else
  424. fdiff = nil;
  425. if(vacfilesetdir(f, &vd) < 0)
  426. warn("vacfilesetdir %s: %r", name);
  427. if(d->mode&DMDIR){
  428. while((n = dirread(fd, &dk)) > 0){
  429. for(i=0; i<n; i++){
  430. s = vtmalloc(strlen(name)+1+strlen(dk[i].name)+1);
  431. strcpy(s, name);
  432. strcat(s, "/");
  433. strcat(s, dk[i].name);
  434. vac(f, fdiff, s, &dk[i]);
  435. free(s);
  436. }
  437. free(dk);
  438. }
  439. }else{
  440. off = 0;
  441. bsize = fs->bsize;
  442. if(fdiff){
  443. /*
  444. * Copy fdiff's contents into f by moving the score.
  445. * We'll diff and update below.
  446. */
  447. if(vacfilegetentries(fdiff, &e, nil) >= 0)
  448. if(vacfilesetentries(f, &e, nil) >= 0){
  449. bsize = e.dsize;
  450. /*
  451. * Or if -q is set, and the metadata looks the same,
  452. * don't even bother reading the file.
  453. */
  454. if(qdiff && vacfilegetdir(fdiff, &vddiff) >= 0){
  455. if(vddiff.mtime == vd.mtime)
  456. if(vddiff.size == vd.size)
  457. if(!vddiff.plan9 || (/* vddiff.p9path == vd.p9path && */ vddiff.p9version == vd.p9version)){
  458. stats.skipfiles++;
  459. stats.nfile--;
  460. vdcleanup(&vddiff);
  461. goto Out;
  462. }
  463. /*
  464. * Skip over presumably-unchanged prefix
  465. * of an append-only file.
  466. */
  467. if(vd.mode&ModeAppend)
  468. if(vddiff.size < vd.size)
  469. if(vddiff.plan9 && vd.plan9)
  470. if(vddiff.p9path == vd.p9path){
  471. off = vd.size/bsize*bsize;
  472. if(seek(fd, off, 0) >= 0)
  473. stats.skipdata += off;
  474. else{
  475. seek(fd, 0, 0); // paranoia
  476. off = 0;
  477. }
  478. }
  479. vdcleanup(&vddiff);
  480. // XXX different verbose chatty prints for kaminsky?
  481. }
  482. }
  483. }
  484. if(qdiff && verbose)
  485. fprint(2, "+%s\n", name);
  486. while((n = readn(fd, buf, bsize)) > 0){
  487. if(fdiff && sha1matches(f, off/bsize, (uint8_t*)buf, n)){
  488. off += n;
  489. stats.skipdata += n;
  490. continue;
  491. }
  492. if(vacfilewrite(f, buf, n, off) < 0){
  493. warn("venti write %s: %r", name);
  494. goto Out;
  495. }
  496. stats.data += n;
  497. off += n;
  498. }
  499. /*
  500. * Since we started with fdiff's contents,
  501. * set the size in case fdiff was bigger.
  502. */
  503. if(fdiff && vacfilesetsize(f, off) < 0)
  504. warn("vtfilesetsize %s: %r", name);
  505. }
  506. Out:
  507. vacfileflush(f, 1);
  508. vacfiledecref(f);
  509. if(fdiff)
  510. vacfiledecref(fdiff);
  511. close(fd);
  512. }
  513. void
  514. vacstdin(VacFile *fp, char *name)
  515. {
  516. int64_t off;
  517. VacFile *f;
  518. static char buf[8192];
  519. int n;
  520. if((f = vacfilecreate(fp, name, 0666)) == nil){
  521. warn("vacfilecreate %s: %r", name);
  522. return;
  523. }
  524. off = 0;
  525. while((n = read(0, buf, sizeof buf)) > 0){
  526. if(vacfilewrite(f, buf, n, off) < 0){
  527. warn("venti write %s: %r", name);
  528. vacfiledecref(f);
  529. return;
  530. }
  531. off += n;
  532. }
  533. vacfileflush(f, 1);
  534. vacfiledecref(f);
  535. }
  536. /*
  537. * fp is the directory we're writing.
  538. * mp is the directory whose contents we're merging in.
  539. * d is the directory entry of the file from mp that we want to add to fp.
  540. * vacfile is the name of the .vac file, for error messages.
  541. * offset is the qid that qid==0 in mp should correspond to.
  542. * max is the maximum qid we expect to see (not really needed).
  543. */
  544. int
  545. vacmergefile(VacFile *fp, VacFile *mp, VacDir *d, char *vacfile,
  546. int64_t offset, int64_t max)
  547. {
  548. VtEntry ed, em;
  549. VacFile *mf;
  550. VacFile *f;
  551. mf = vacfilewalk(mp, d->elem);
  552. if(mf == nil){
  553. warn("could not walk %s in %s", d->elem, vacfile);
  554. return -1;
  555. }
  556. if(vacfilegetentries(mf, &ed, &em) < 0){
  557. warn("could not get entries for %s in %s", d->elem, vacfile);
  558. vacfiledecref(mf);
  559. return -1;
  560. }
  561. if((f = vacfilecreate(fp, d->elem, d->mode)) == nil){
  562. warn("vacfilecreate %s: %r", d->elem);
  563. vacfiledecref(mf);
  564. return -1;
  565. }
  566. if(d->qidspace){
  567. d->qidoffset += offset;
  568. d->qidmax += offset;
  569. }else{
  570. d->qidspace = 1;
  571. d->qidoffset = offset;
  572. d->qidmax = max;
  573. }
  574. if(vacfilesetdir(f, d) < 0
  575. || vacfilesetentries(f, &ed, &em) < 0
  576. || vacfilesetqidspace(f, d->qidoffset, d->qidmax) < 0){
  577. warn("vacmergefile %s: %r", d->elem);
  578. vacfiledecref(mf);
  579. vacfiledecref(f);
  580. return -1;
  581. }
  582. vacfiledecref(mf);
  583. vacfiledecref(f);
  584. return 0;
  585. }
  586. int
  587. vacmerge(VacFile *fp, char *name)
  588. {
  589. VacFs *mfs;
  590. VacDir vd;
  591. VacDirEnum *de;
  592. VacFile *mp;
  593. uint64_t maxqid, offset;
  594. if(strlen(name) < 4 || strcmp(name+strlen(name)-4, ".vac") != 0)
  595. return -1;
  596. if((mfs = vacfsopen(z, name, VtOREAD, 100)) == nil)
  597. return -1;
  598. if(verbose)
  599. fprint(2, "merging %s\n", name);
  600. mp = vacfsgetroot(mfs);
  601. de = vdeopen(mp);
  602. if(de){
  603. offset = 0;
  604. if(vacfsgetmaxqid(mfs, &maxqid) >= 0){
  605. _vacfsnextqid(fs, &offset);
  606. vacfsjumpqid(fs, maxqid+1);
  607. }
  608. while(vderead(de, &vd) > 0){
  609. if(vd.qid > maxqid){
  610. warn("vacmerge %s: maxqid=%lld but %s has %lld",
  611. name, maxqid, vd.elem, vd.qid);
  612. vacfsjumpqid(fs, vd.qid - maxqid);
  613. maxqid = vd.qid;
  614. }
  615. vacmergefile(fp, mp, &vd, name,
  616. offset, maxqid);
  617. vdcleanup(&vd);
  618. }
  619. vdeclose(de);
  620. }
  621. vacfiledecref(mp);
  622. vacfsclose(mfs);
  623. return 0;
  624. }
  625. #define TWID64 ((uint64_t)~(uint64_t)0)
  626. static uint64_t
  627. unittoull(char *s)
  628. {
  629. char *es;
  630. uint64_t n;
  631. if(s == nil)
  632. return TWID64;
  633. n = strtoul(s, &es, 0);
  634. if(*es == 'k' || *es == 'K'){
  635. n *= 1024;
  636. es++;
  637. }else if(*es == 'm' || *es == 'M'){
  638. n *= 1024*1024;
  639. es++;
  640. }else if(*es == 'g' || *es == 'G'){
  641. n *= 1024*1024*1024;
  642. es++;
  643. }
  644. if(*es != '\0')
  645. return TWID64;
  646. return n;
  647. }
  648. static void
  649. warn(char *fmt, ...)
  650. {
  651. va_list arg;
  652. va_start(arg, fmt);
  653. fprint(2, "vac: ");
  654. vfprint(2, fmt, arg);
  655. fprint(2, "\n");
  656. va_end(arg);
  657. }