Annotation of 43BSDReno/sys/nfs/TEST/pcnfs-tests/testsuit.tar, revision 1.1
1.1 ! root 1: ./ 775 20115 11 0 4552136511 4214 ./basic/ 775 20115 11 0 4552136061 5275 ./basic/subr.c 664 20115 11 23750 4552130364 6530 /* @(#)subr.c 1.2 89/01/08 NFS Rev 2 Testsuite */
! 2: /*
! 3: * Useful subroutines shared by all tests
! 4: */
! 5:
! 6: #include "tests.h"
! 7:
! 8: char *Myname;
! 9:
! 10: #ifdef ANSI
! 11:
! 12: int unix_chdir(char * path);
! 13:
! 14:
! 15:
! 16: #ifdef DOS
! 17: char *getwd(char * path);
! 18: #endif
! 19:
! 20: #endif
! 21:
! 22: /*
! 23: * Build a directory tree "lev" levels deep
! 24: * with "files" number of files in each directory
! 25: * and "dirs" fan out. Starts at the current directory.
! 26: * "fname" and "dname" are the base of the names used for
! 27: * files and directories.
! 28: */
! 29: void
! 30: dirtree(lev, files, dirs, fname, dname, totfiles, totdirs)
! 31: int lev;
! 32: int files;
! 33: int dirs;
! 34: char *fname;
! 35: char *dname;
! 36: int *totfiles;
! 37: int *totdirs;
! 38: {
! 39: int fd;
! 40: int f, d;
! 41: char name[MAXPATHLEN];
! 42:
! 43: if (lev-- == 0) {
! 44: return;
! 45: }
! 46: for ( f = 0; f < files; f++) {
! 47: sprintf(name, "%s%d", fname, f);
! 48: if ((fd = creat(name, CHMOD_YES)) < 0) {
! 49: error("creat %s failed", name);
! 50: exit(1);
! 51: }
! 52: (*totfiles)++;
! 53: if (close(fd) < 0) {
! 54: error("close %d failed", fd);
! 55: exit(1);
! 56: }
! 57: }
! 58: for ( d = 0; d < dirs; d++) {
! 59: sprintf(name, "%s%d", dname, d);
! 60: #ifdef DOS
! 61: if (mkdir(name) < 0) {
! 62: #else
! 63: if (mkdir(name, 0777) < 0) {
! 64: #endif
! 65: error("mkdir %s failed", name);
! 66: exit(1);
! 67: }
! 68: (*totdirs)++;
! 69: if (unix_chdir(name) < 0) {
! 70: error("chdir %s failed", name);
! 71: exit(1);
! 72: }
! 73: dirtree(lev, files, dirs, fname, dname, totfiles, totdirs);
! 74: if (unix_chdir("..") < 0) {
! 75: error("chdir .. failed");
! 76: exit(1);
! 77: }
! 78: }
! 79: }
! 80:
! 81: /*
! 82: * Remove a directory tree starting at the current directory.
! 83: * "fname" and "dname" are the base of the names used for
! 84: * files and directories to be removed - don't remove anything else!
! 85: * "files" and "dirs" are used with fname and dname to generate
! 86: * the file names to remove.
! 87: *
! 88: * This routine will fail if, say after removing known files,
! 89: * the directory is not empty.
! 90: *
! 91: * This is used to test the unlink function and to clean up after tests.
! 92: */
! 93: void
! 94: rmdirtree(lev, files, dirs, fname, dname, totfiles, totdirs, ignore)
! 95: int lev;
! 96: int files;
! 97: int dirs;
! 98: char *fname;
! 99: char *dname;
! 100: int *totfiles; /* total removed */
! 101: int *totdirs; /* total removed */
! 102: int ignore;
! 103: {
! 104: int f, d;
! 105: char name[MAXPATHLEN];
! 106:
! 107: if (lev-- == 0) {
! 108: return;
! 109: }
! 110: for ( f = 0; f < files; f++) {
! 111: sprintf(name, "%s%d", fname, f);
! 112: if (unlink(name) < 0 && !ignore) {
! 113: error("unlink %s failed", name);
! 114: exit(1);
! 115: }
! 116: (*totfiles)++;
! 117: }
! 118: for ( d = 0; d < dirs; d++) {
! 119: sprintf(name, "%s%d", dname, d);
! 120: if (unix_chdir(name) < 0) {
! 121: if (ignore)
! 122: continue;
! 123: error("chdir %s failed", name);
! 124: exit(1);
! 125: }
! 126: rmdirtree(lev, files, dirs, fname, dname, totfiles, totdirs, ignore);
! 127: if (unix_chdir("..") < 0) {
! 128: error("chdir .. failed");
! 129: exit(1);
! 130: }
! 131: if (rmdir(name) < 0) {
! 132: error("rmdir %s failed", name);
! 133: exit(1);
! 134: }
! 135: (*totdirs)++;
! 136: }
! 137: }
! 138:
! 139: /* VARARGS */
! 140: void
! 141: error(str, ar1, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9)
! 142: char *str;
! 143: long ar1, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9;
! 144: {
! 145: char *ret;
! 146:
! 147: char path[MAXPATHLEN];
! 148:
! 149: if ((ret = getwd(path)) == NULL)
! 150:
! 151: fprintf(stderr, "%s: getwd failed\n", Myname);
! 152: else
! 153: fprintf(stderr, "\t%s: (%s) ", Myname, path);
! 154:
! 155: fprintf(stderr, str, ar1, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9);
! 156: if (errno)
! 157: perror(" ");
! 158: else
! 159: fprintf(stderr, "\n");
! 160: fflush(stderr);
! 161: if (ret == NULL)
! 162: exit(1);
! 163: }
! 164:
! 165: static struct timeval ts, te;
! 166:
! 167: /*
! 168: * save current time in struct ts
! 169: */
! 170: void
! 171: starttime()
! 172: {
! 173: gettimeofday(&ts, (struct timezone *)0);
! 174: }
! 175:
! 176: /*
! 177: * sets the struct tv to the difference in time between
! 178: * current time and the time in struct ts.
! 179: */
! 180: void
! 181: endtime(tv)
! 182: struct timeval *tv;
! 183: {
! 184:
! 185: gettimeofday(&te, (struct timezone *)0);
! 186: if (te.tv_usec < ts.tv_usec) {
! 187: te.tv_sec--;
! 188: te.tv_usec += 1000000;
! 189: }
! 190: tv->tv_usec = te.tv_usec - ts.tv_usec;
! 191: tv->tv_sec = te.tv_sec - ts.tv_sec;
! 192: }
! 193:
! 194: void
! 195: printtimes(tv, nbytes)
! 196: struct timeval *tv; /* contains the elapsed time */
! 197: long nbytes; /* size * count */
! 198: {
! 199: fprintf(stdout, " in %ld.%-2ld seconds",
! 200: tv->tv_sec, tv->tv_usec / 10000L);
! 201: if (nbytes > 0 && tv->tv_sec != 0)
! 202: fprintf(stdout, " (%ld bytes/sec)", nbytes/tv->tv_sec);
! 203: }
! 204:
! 205: /*
! 206: * Set up and move to a test directory
! 207: */
! 208: void
! 209: testdir(dir)
! 210: char *dir;
! 211: {
! 212: struct stat statb;
! 213: char str[MAXPATHLEN];
! 214: char *getenv();
! 215:
! 216: /*
! 217: * If dir is non-NULL, use that dir. If NULL, first
! 218: * check for env variable NFSTESTDIR. If that is not
! 219: * set, use the compiled-in TESTDIR.
! 220: */
! 221: if (dir == NULL)
! 222: if ((dir = getenv("NFSTESTDIR")) == NULL)
! 223: dir = TESTDIR;
! 224:
! 225: if (stat(dir, &statb) == 0) {
! 226: sprintf(str, "rm -r %s", dir);
! 227: if (system(str) != 0) {
! 228: error("can't remove old test directory %s", dir);
! 229: exit(1);
! 230: }
! 231: }
! 232:
! 233: #ifdef DOS
! 234: if (mkdir(dir) < 0) {
! 235: #else
! 236: if (mkdir(dir, 0777) < 0) {
! 237: #endif
! 238: error("can't create test directory %s", dir);
! 239: exit(1);
! 240: }
! 241: if (unix_chdir(dir) < 0) {
! 242: error("can't chdir to test directory %s", dir);
! 243: exit(1);
! 244: }
! 245: }
! 246:
! 247: /*
! 248: * Move to a test directory
! 249: */
! 250: int
! 251: mtestdir(dir)
! 252: char *dir;
! 253: {
! 254: char *getenv();
! 255:
! 256: /*
! 257: * If dir is non-NULL, use that dir. If NULL, first
! 258: * check for env variable NFSTESTDIR. If that is not
! 259: * set, use the compiled-in TESTDIR.
! 260: */
! 261: if (dir == NULL)
! 262: if ((dir = getenv("NFSTESTDIR")) == NULL)
! 263: dir = TESTDIR;
! 264:
! 265: if (unix_chdir(dir) < 0) {
! 266: error("can't chdir to test directory %s", dir);
! 267: return -1;
! 268: }
! 269: return 0;
! 270: }
! 271:
! 272: /*
! 273: * get parameter at parm, convert to int, and make sure that
! 274: * it is at least min.
! 275: */
! 276: long
! 277: getparm(parm, min, label)
! 278: char *parm, *label;
! 279: long min;
! 280: {
! 281: long val = atol(parm);
! 282: if (val < min) {
! 283: error("Illegal %s parameter %ld, must be at least %ld",
! 284: label, val, min);
! 285: exit(1);
! 286: }
! 287: return val;
! 288: }
! 289:
! 290: #ifdef DOS
! 291:
! 292: #ifdef ANSI
! 293: void chdrive(char * path);
! 294: #endif
! 295:
! 296: /*
! 297: * Change to drive specified in path
! 298: */
! 299:
! 300: void
! 301: chdrive(path)
! 302: char *path;
! 303: {
! 304: int desireddrive, drive;
! 305: if (path[1] == ':')
! 306: {
! 307: desireddrive = toupper(path[0]) - ('A' - 1);
! 308: _dos_setdrive(desireddrive, &drive);
! 309: _dos_getdrive(&drive);
! 310: if (drive != desireddrive)
! 311: {
! 312: error("can't change to drive %c:", path[0]);
! 313: exit(1);
! 314: }
! 315: }
! 316: }
! 317:
! 318: /*
! 319: * exit point for successful test
! 320: */
! 321: void
! 322: complete()
! 323: {
! 324: fprintf(stdout, "\t%s ok.\n", Myname);
! 325: #ifdef DOS
! 326: chdrive(Myname);
! 327: #endif
! 328: exit(0);
! 329: }
! 330:
! 331:
! 332: int
! 333: unix_chdir(path)
! 334: char *path;
! 335: {
! 336: #ifdef DOS
! 337: chdrive(path);
! 338: #endif
! 339: return chdir(path);
! 340: }
! 341:
! 342: char *
! 343: getwd(path)
! 344: char * path;
! 345: {
! 346: return getcwd(path, MAXPATHLEN);
! 347: }
! 348:
! 349: int
! 350: unix_chmod(path, mode)
! 351: char *path;
! 352: int mode;
! 353: {
! 354: int dosmode = (mode&0500 ? S_IREAD : 0) | (mode&0200 ? S_IWRITE : 0);
! 355: return chmod(path, dosmode);
! 356: }
! 357:
! 358: int
! 359: lstat(path, buf)
! 360: char *path;
! 361: struct stat *buf;
! 362: {
! 363: return stat(path, buf);
! 364: }
! 365:
! 366: void
! 367: gettimeofday(struct timeval *TV, struct timezone *TimeZone)
! 368: {
! 369: struct dostime_t dostime;
! 370: _dos_gettime(&dostime);
! 371: TV->tv_sec = dostime.hour * 3600L
! 372: + dostime.minute * 60L
! 373: + dostime.second;
! 374: TV->tv_usec = dostime.hsecond * 10000L;
! 375: TimeZone = TimeZone; /* shut up compiler/lint */
! 376: }
! 377:
! 378: int
! 379: statfs(path, buf)
! 380: char *path;
! 381: struct statfs *buf;
! 382: {
! 383: char *p = (char *) buf;
! 384: int i;
! 385: unsigned drive;
! 386: struct diskfree_t diskspace;
! 387:
! 388: for (i = 0; i < sizeof(*buf); i++)
! 389: *p++ = (char) -1;
! 390: buf->f_type = 0; /* that's what the man page says */
! 391: if (path[1] == ':')
! 392: drive = toupper(path[0]) - ('A' - 1);
! 393: else
! 394: _dos_getdrive(&drive);
! 395: if (_dos_getdiskfree(drive, &diskspace))
! 396: return -1;
! 397: buf->f_bsize = diskspace.bytes_per_sector;
! 398: buf->f_blocks = (long) diskspace.total_clusters
! 399: * diskspace.sectors_per_cluster;
! 400: buf->f_bfree = (long) diskspace.avail_clusters
! 401: * diskspace.sectors_per_cluster;
! 402: buf->f_bavail = buf->f_bfree;
! 403: return 0;
! 404: }
! 405:
! 406: /***************************************************************
! 407: DIRENT EMULATION FOR DOS
! 408: ***************************************************************/
! 409: char pattern[MAXNAMLEN];
! 410: struct find_t findtst;
! 411: int maxentry;
! 412: int currententry;
! 413: int diropen = 0;
! 414: struct dirent *dirlist;
! 415: DIR dirst;
! 416:
! 417: #ifdef ANSI
! 418: static void copynametolower(char *dest, char *src);
! 419: static void findt_to_dirent(struct find_t *f, struct dirent *d);
! 420: #endif
! 421:
! 422: DIR *
! 423: opendir(dirname)
! 424: char *dirname;
! 425: {
! 426: int i;
! 427: unsigned attributes = _A_NORMAL|_A_RDONLY|_A_HIDDEN|_A_SUBDIR;
! 428: strcpy(pattern, dirname);
! 429: strcat(pattern, "\\*.*");
! 430: if (diropen)
! 431: return NULL;
! 432: diropen = 1;
! 433: dirlist = (struct dirent *) malloc(512 * sizeof(struct dirent));
! 434: if (dirlist == NULL)
! 435: return NULL;
! 436: if (_dos_findfirst(pattern, attributes, &findtst))
! 437: return NULL;
! 438: findt_to_dirent(&findtst, &dirlist[0]);
! 439: for (i = 1; ! _dos_findnext(&findtst); i++) {
! 440: findt_to_dirent(&findtst, &dirlist[i]);
! 441: }
! 442: maxentry = i - 1;
! 443: currententry = 0;
! 444: return &dirst;
! 445: }
! 446:
! 447: void
! 448: rewinddir(dirp)
! 449: DIR *dirp;
! 450: {
! 451: int i;
! 452: unsigned attributes = _A_NORMAL|_A_RDONLY|_A_HIDDEN|_A_SUBDIR;
! 453: dirp = dirp; /* shut up compiler */
! 454: if (_dos_findfirst(pattern, attributes, &findtst)) {
! 455: error("rewind failed");
! 456: exit(1);
! 457: }
! 458: findt_to_dirent(&findtst, &dirlist[0]);
! 459: for (i = 1; ! _dos_findnext(&findtst); i++) {
! 460: findt_to_dirent(&findtst, &dirlist[i]);
! 461: }
! 462: maxentry = i - 1;
! 463: currententry = 0;
! 464: }
! 465:
! 466: long
! 467: telldir(dirp)
! 468: DIR *dirp;
! 469: {
! 470: dirp = dirp; /* keep compiler happy */
! 471: return (long) currententry;
! 472: }
! 473:
! 474: void
! 475: seekdir(dirp, loc)
! 476: DIR *dirp;
! 477: long loc;
! 478: {
! 479: dirp = dirp; /* keep compiler happy */
! 480: if (loc <= (long) maxentry)
! 481: currententry = (int) loc;
! 482: /* else seekdir silently fails */
! 483: }
! 484:
! 485: struct dirent *
! 486: readdir(dirp)
! 487: DIR *dirp;
! 488: {
! 489: dirp = dirp; /* shut up compiler */
! 490: if (currententry > maxentry)
! 491: return (struct dirent *) NULL;
! 492: else {
! 493: return &dirlist[currententry++];
! 494: }
! 495: }
! 496:
! 497: void
! 498: findt_to_dirent(f, d)
! 499: struct find_t *f;
! 500: struct dirent *d;
! 501: {
! 502: copynametolower(d->d_name, f->name);
! 503: }
! 504:
! 505: static void
! 506: copynametolower(dest, src)
! 507: char *dest;
! 508: char *src;
! 509: {
! 510: int i;
! 511: for (i = 0; dest[i] = (char) tolower((int) src[i]); i++) {
! 512: /* null body */
! 513: }
! 514: }
! 515:
! 516: void
! 517: closedir(dirp)
! 518: DIR *dirp;
! 519: {
! 520: dirp = dirp; /* keep compiler happy */
! 521: diropen = 0;
! 522: }
! 523:
! 524: #endif /* DOS */
! 525:
! 526:
! 527: * sets the struct tv ./basic/test5a.c 664 20115 11 6656 4552130373 6750 /* @(#)test5a.c 1.2 89/01/10 NFS Rev 2 Testsuite */
! 528: /*
! 529: * Test write - DOES NOT VERIFY WRITE CONTENTS
! 530: *
! 531: * Uses the following important system calls against the server:
! 532: *
! 533: * chdir()
! 534: * mkdir() (for initial directory creation if not -m)
! 535: * creat()
! 536: * write()
! 537: * stat()
! 538: * fstat()
! 539: */
! 540:
! 541: #include "tests.h"
! 542:
! 543: #define BUFSZ 8192
! 544: #define DSIZE 1048576L
! 545:
! 546: int Tflag = 0; /* print timing */
! 547: int Hflag = 0; /* print help message */
! 548: int Fflag = 0; /* test function only; set count to 1, negate -t */
! 549: int Nflag = 0; /* Suppress directory operations */
! 550:
! 551: void usage(void);
! 552:
! 553: void
! 554: usage()
! 555: {
! 556: fprintf(stdout, "usage: %s [-htfn] [size count fname]\n", Myname);
! 557: fprintf(stdout, " Flags: h Help - print this usage info\n");
! 558: fprintf(stdout, " t Print execution time statistics\n");
! 559: fprintf(stdout, " f Test function only (negate -t)\n");
! 560: fprintf(stdout, " n Suppress test directory create operations\n");
! 561: }
! 562:
! 563: void main(int argc,char *argv[]);
! 564:
! 565: void
! 566: main(argc, argv)
! 567: int argc;
! 568: char *argv[];
! 569: {
! 570: int count = DCOUNT; /* times to do each file */
! 571: int ct;
! 572: long size = DSIZE;
! 573: long si;
! 574: long i;
! 575: int fd;
! 576: int bytes;
! 577: char *bigfile = "bigfile";
! 578: struct timeval time;
! 579: struct stat statb;
! 580: char *opts;
! 581: char buf[BUFSZ];
! 582:
! 583: umask(0);
! 584: setbuf(stdout, NULL);
! 585: Myname = *argv++;
! 586: argc--;
! 587: while (argc && **argv == '-') {
! 588: for (opts = &argv[0][1]; *opts; opts++) {
! 589: switch (*opts) {
! 590: case 'h': /* help */
! 591: usage();
! 592: exit(1);
! 593:
! 594: case 't': /* time */
! 595: Tflag++;
! 596: break;
! 597:
! 598: case 'f': /* funtionality */
! 599: Fflag++;
! 600: break;
! 601:
! 602: case 'n': /* No Test Directory create */
! 603: Nflag++;
! 604: break;
! 605:
! 606: default:
! 607: error("unknown option '%c'", *opts);
! 608: usage();
! 609: exit(1);
! 610: }
! 611: }
! 612: argc--;
! 613: argv++;
! 614: }
! 615:
! 616: if (argc) {
! 617: size = getparm(*argv, 1L, "size");
! 618: argv++;
! 619: argc--;
! 620: }
! 621: if (argc) {
! 622: count = (int) getparm(*argv, 1L, "count");
! 623: argv++;
! 624: argc--;
! 625: }
! 626: if (argc) {
! 627: bigfile = *argv;
! 628: argv++;
! 629: argc--;
! 630: }
! 631: if (argc) {
! 632: usage();
! 633: exit(1);
! 634: }
! 635:
! 636: if (Fflag) {
! 637: Tflag = 0;
! 638: count = 1;
! 639: }
! 640:
! 641: fprintf(stdout, "%s: write\n", Myname);
! 642:
! 643: if (!Nflag)
! 644: testdir(NULL);
! 645: else
! 646: mtestdir(NULL);
! 647:
! 648: /* Set up contents, however we won't verify. */
! 649: for (i=0; i < BUFSZ / sizeof(long); i++) {
! 650: ((long *)buf)[i] = i;
! 651: }
! 652:
! 653: if (Tflag) {
! 654: starttime();
! 655: }
! 656:
! 657: for (ct = 0; ct < count; ct++) {
! 658: if ((fd = creat(bigfile, CHMOD_YES)) < 0) {
! 659: error("can't create '%s'", bigfile);
! 660: exit(1);
! 661: }
! 662: if (fstat(fd, &statb) < 0) {
! 663: error("can't stat '%s'", bigfile);
! 664: exit(1);
! 665: }
! 666: if (statb.st_size != 0) {
! 667: error("'%s' has size %ld, should be 0",
! 668: bigfile, statb.st_size);
! 669: exit(1);
! 670: }
! 671: for (si = size; si > 0; si -= BUFSZ) {
! 672: bytes = (int) MIN((long) BUFSZ, si);
! 673: if (write(fd, buf, bytes) != bytes) {
! 674: error("'%s' write failed", bigfile);
! 675: exit(1);
! 676: }
! 677: }
! 678: close(fd);
! 679: if (stat(bigfile, &statb) < 0) {
! 680: error("can't stat '%s'", bigfile);
! 681: exit(1);
! 682: }
! 683: if (statb.st_size != size) {
! 684: error("'%s' has size %ld, should be %ld",
! 685: bigfile, statb.st_size, size);
! 686: exit(1);
! 687: }
! 688: }
! 689:
! 690: if (Tflag) {
! 691: endtime(&time);
! 692: }
! 693:
! 694: fprintf(stdout, "\twrote %ld byte file %d times", size, count);
! 695: if (Tflag) {
! 696: printtimes(&time, size * (long) count);
! 697: }
! 698: fprintf(stdout, "\n");
! 699:
! 700: complete();
! 701: }
! 702: mpiler happy */
! 703: diropen = 0;
! 704: }
! 705:
! 706: #endif /* DOS */
! 707:
! 708:
! 709: * sets the struct tv ./basic/tests.h 664 20115 11 2773 4552130402 6677 /* @(#)tests.h 1.2 89/01/08 NFS Rev 2 Testsuite */
! 710:
! 711: /* Do all includes here so you don't have to mess with each file */
! 712:
! 713: #ifndef DOS
! 714: #include <sys/param.h>
! 715: #endif
! 716: #ifndef major
! 717: #include <sys/types.h>
! 718: #endif
! 719: #include <sys/stat.h>
! 720: #include <stdio.h>
! 721: #include <errno.h>
! 722: #ifdef DOS
! 723: #include <fcntl.h>
! 724: #include <dos.h>
! 725: #include <time.h>
! 726: #include "unixdos.h"
! 727: #include <direct.h>
! 728: #include <io.h>
! 729: #include <stdlib.h>
! 730: #include <string.h>
! 731: #include <ctype.h>
! 732: #endif
! 733:
! 734: #define TESTDIR "o:\\nfstestd"
! 735: #define DNAME "dir."
! 736: #define FNAME "file."
! 737: #define DCOUNT 10
! 738: #define DDIRS 2
! 739: #define DLEVS 5
! 740: #define DFILS 5
! 741:
! 742: #ifdef DOS
! 743: #define CHMOD_MASK (S_IREAD | S_IWRITE)
! 744: #define CHMOD_YES CHMOD_MASK
! 745: #define CHMOD_NO S_IREAD
! 746: #else
! 747: #define CHMOD_MASK 0777
! 748: #define CHMOD_YES 0666
! 749: #define CHMOD_NO 0
! 750: #endif
! 751:
! 752: #ifdef ANSI
! 753: void error(char *str,...);
! 754: void starttime(void);
! 755: void endtime(struct timeval *tv);
! 756: void printtimes(struct timeval *tv, long nbytes);
! 757: void testdir(char *dir);
! 758: int mtestdir(char *dir);
! 759: long getparm(char *parm, long min, char *label);
! 760: void complete(void);
! 761: int unix_chdir(char *path);
! 762: void dirtree(int lev, int files, int dirs, char *fname, char *dname, int *totfiles, int *totdirs);
! 763: void rmdirtree(int lev, int files, int dirs, char *fname, char *dname, int *totfiles, int *totdirs, int ignore);
! 764: #ifdef DOS
! 765: char *getwd(char *path);
! 766: #endif
! 767: int unix_chmod(char *path, int mode);
! 768: #endif
! 769:
! 770: extern int errno;
! 771:
! 772: extern char *Myname; /* name I was invoked with (for error msgs) */
! 773:
! 774: e 't'./basic/unixdos.h 664 20115 11 6727 4552130404 7233 struct timeval
! 775: {
! 776: long tv_sec; /* seconds since midnight (unlike Unix) */
! 777: long tv_usec; /* and microseconds */
! 778: };
! 779:
! 780: typedef unsigned char u_char;
! 781:
! 782: #define MAXPATHLEN 256 /* tune later */
! 783: #define MIN(a, b) (((a) < (b)) ? (a) : (b))
! 784:
! 785: void gettimeofday(struct timeval *TV, struct timezone *TimeZone);
! 786: int unix_chdir(char * path);
! 787: char * getwd(char * path);
! 788: int unix_chmod(char * path, int mode);
! 789: int lstat(char *path, struct stat *buf);
! 790:
! 791: /************************************************************
! 792: statfs stuff
! 793: ************************************************************/
! 794:
! 795: typedef struct {
! 796: long val[2];
! 797: } fsid_t;
! 798: struct statfs {
! 799: long f_type; /* type of info, zero for now */
! 800: long f_bsize; /* fundamental file system block size */
! 801: long f_blocks; /* total blocks in file system */
! 802: long f_bfree; /* free blocks */
! 803: long f_bavail; /* free blocks available to non-super-user */
! 804: long f_files; /* total file nodes in file system */
! 805: long f_ffree; /* free file nodes in fs */
! 806: fsid_t f_fsid; /* file system id */
! 807: long f_spare[7]; /* spare for later */
! 808: };
! 809:
! 810: int statfs(char *path, struct statfs *buf);
! 811:
! 812: /************************************************************
! 813: From /usr/include/directory.h, simplified:
! 814: ************************************************************/
! 815:
! 816: #ifndef __dirent_h
! 817: #define __dirent_h
! 818:
! 819: /*
! 820: * Definitions for library routines operating on directories.
! 821: */
! 822: typedef int DIR; /* just a dummy */
! 823:
! 824: DIR *opendir(char *dirname);
! 825: struct dirent *readdir(DIR *dirp);
! 826: void rewinddir(DIR *dirp);
! 827: void closedir(DIR *dirp);
! 828: #ifndef _POSIX_SOURCE
! 829: void seekdir(DIR *dirp, long loc);
! 830: long telldir(DIR *dirp);
! 831: #endif /* POSIX_SOURCE */
! 832:
! 833: #endif /* !__dirent_h */
! 834:
! 835: /*************************************************************
! 836: From /usr/include/sys/dirent.h:
! 837: *************************************************************/
! 838:
! 839: /*
! 840: * Filesystem-independent directory information.
! 841: * Directory entry structures are of variable length.
! 842: * Each directory entry is a struct dirent containing its file number, the
! 843: * offset of the next entry (a cookie interpretable only the filesystem
! 844: * type that generated it), the length of the entry, and the length of the
! 845: * name contained in the entry. These are followed by the name. The
! 846: * entire entry is padded with null bytes to a 4 byte boundary. All names
! 847: * are guaranteed null terminated. The maximum length of a name in a
! 848: * directory is MAXNAMLEN, plus a null byte.
! 849: */
! 850:
! 851: #ifndef __sys_dirent_h
! 852: #define __sys_dirent_h
! 853:
! 854: struct dirent {
! 855: /* just need d_name field for Cthon tests */
! 856: char d_name[13]; /* name (up to MAXNAMLEN + 1) */
! 857: };
! 858:
! 859: #ifndef _POSIX_SOURCE
! 860: /*
! 861: * It's unlikely to change, but make sure that sizeof d_name above is
! 862: * at least MAXNAMLEN + 1 (more may be added for padding).
! 863: */
! 864: #define MAXNAMLEN 255
! 865: /*
! 866: * The macro DIRSIZ(dp) gives the minimum amount of space required to represent
! 867: * a directory entry. For any directory entry dp->d_reclen >= DIRSIZ(dp).
! 868: * Specific filesystem types may use this macro to construct the value
! 869: * for d_reclen.
! 870: */
! 871: #undef DIRSIZ
! 872: #define DIRSIZ(dp) \
! 873: (((sizeof(struct dirent) - (MAXNAMLEN+1) + ((dp)->d_namlen+1)) +3) & ~3)
! 874:
! 875: #endif /* !_POSIX_SOURCE */
! 876: #endif /* !__sys_dirent_h */
! 877: if /* DOS */
! 878:
! 879:
! 880: * sets the struct tv ./basic/subr.obj 777 20115 11 35434 4552136064 7072 � subr.c%� MS Cn� �SLIBCE� �0s3� �&CV7�N DGROUP_TEXTCODE_DATADATACONST_BSSBSS$$TYPESDEBTYP $$SYMBOLSDEBSYM)� H&� H&�� H &
! 881: � H &�� o
&��
! 882: &� ���V�
&&@&E&��
&
! 883: __acrtused _statfs _fflush _opendir _atol _readdir __ctype
! 884: _rewinddir _exit _fprintf _error _closedir
! 885: _starttime _endtime _seekdir _getenv _telldir _printtimes _chdir _testdir _getcwd _mtestdir _mkdir _malloc _rmdir _chmod _perror _getparm �� _pattern�b�� n� _complete _close $� _findtst�hb,g� _creat ��. _maxentry��b
_currententry��b_dirlist��b�� __chkstk � _dirst��bT� __aNldiv E� copynametolower Ì _dirtree _sprintf _system �� findt_to_dirent __dos_findfirst
_gettimeofday __dos_findnext _unlink __aNulmul _unix_chdir __dos_getdrive _getwd
! 886: _rmdirtree __dos_getdiskfree _unix_chmod _strcat
__dos_gettime ��
_Myname��b�B _lstat _chdrive _stat _errno _strcpy __dos_setdrive __iob ϐ� &_statfsg�_opendir] �_readdir5�'
! 887: _rewinddir?
! 888: �_error��� _closedir��.
! 889: _starttime���_endtime���_seekdir�
! 890: �$_telldir�
! 891: �"_printtimesl��_testdir��� _mtestdir���_getparm"�� _complete
��Ґ &_diropen���� ©nametolower��,d� &_dirtree ��� &findt_to_dirent{�)��g &
_gettimeofday���_unix_chdirD��_getwdj��
! 892: _rmdirtree�&��_unix_chmod���_lstat���_chdrive��枈 �&Ѡ %s%d creat %s failed close %d failed %s%d mkdir %s failed chdir %s failed .. chdir .. failed %s%d unlink %s failed %s%d chdir %s failed .. chdir .. failed rmdir %s failed %s: getwd failed
! 893: