home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume41 / wwfs / part15 < prev    next >
Encoding:
Text File  |  1994-01-17  |  89.3 KB  |  3,757 lines

  1. Newsgroups: comp.sources.misc
  2. From: youki-k@is.aist-nara.ac.jp (Youki Kadobayashi)
  3. Subject: v41i100:  wwfs - WorldWide File System, Part15/22
  4. Message-ID: <1994Jan17.202428.20278@sparky.sterling.com>
  5. X-Md4-Signature: ecda4c6b83f01eed6179fcbd84d3c10a
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Nara Institute of Science and Technology, Japan
  8. Date: Mon, 17 Jan 1994 20:24:28 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: youki-k@is.aist-nara.ac.jp (Youki Kadobayashi)
  12. Posting-number: Volume 41, Issue 100
  13. Archive-name: wwfs/part15
  14. Environment: UNIX, inet
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  csd/crc32.c csd/cs_subr.c csd/main.c csd/sched.c
  21. #   doc/overview.eps mosaic/ftplib.pl mosaic/gget.pl rpc/cs_prot_xdr.c
  22. #   rpc/nfs_prot.x rpc/nfs_prot_xdr.c saps/crontab-add.sh
  23. # Wrapped by kent@sparky on Sun Jan 16 17:48:37 1994
  24. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 15 (of 22)."'
  27. if test -f 'csd/crc32.c' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'csd/crc32.c'\"
  29. else
  30.   echo shar: Extracting \"'csd/crc32.c'\" \(7866 characters\)
  31.   sed "s/^X//" >'csd/crc32.c' <<'END_OF_FILE'
  32. X/*
  33. X * In WWFS we occasionally need crc to map filename to/from fileid,
  34. X * since some storage systems (e.g. FTP) doesn't support fileid.
  35. X *
  36. X * Minor modification for 32bit crc by Youki Kadobayashi, Osaka University
  37. X */
  38. Xstatic char *AtFSid = "$Header: crc32.c[109.0] Wed Nov 24 03:47:04 1993 youki-k@is.aist-nara.ac.jp saved $";
  39. X/* updcrc(3), crc(1) - calculate crc polynomials
  40. X *
  41. X * Calculate, intelligently, the CRC of a dataset incrementally given a
  42. X * buffer full at a time.
  43. X *
  44. X * Usage:
  45. X *      newcrc = updcrc( oldcrc, bufadr, buflen )
  46. X *              unsigned long oldcrc;
  47. X *        unsigned int buflen;
  48. X *              char *bufadr;
  49. X *
  50. X * Compiling with -DTEST creates a program to print the CRC of stdin to stdout.
  51. X * Compile with -DMAKETAB to print values for crctab to stdout.  If you change
  52. X *      the CRC polynomial parameters, be sure to do this and change
  53. X *      crctab's initial value.
  54. X *
  55. X * Notes:
  56. X *  Regards the data stream as an integer whose MSB is the MSB of the first
  57. X *  byte recieved.  This number is 'divided' (using xor instead of subtraction)
  58. X *  by the crc-polynomial P.
  59. X *  XMODEM does things a little differently, essentially treating the LSB of
  60. X * the first data byte as the MSB of the integer. Define SWAPPED to make
  61. X * things behave in this manner.
  62. X *
  63. X * Author:      Mark G. Mendel, 7/86
  64. X *              UUCP: ihnp4!umn-cs!hyper!mark, GEnie: mgm
  65. X */
  66. X/* The CRC polynomial.
  67. X * These 4 values define the crc-polynomial.
  68. X * If you change them, you must change crctab[]'s initial value to what is
  69. X * printed by initcrctab() [see 'compile with -DMAKETAB' above].
  70. X */
  71. X    /* Value used by:                   CITT    XMODEM  ARC     */
  72. X#define P        0xA0000001L  /* the poly:   0x1021  0x1021  A001    */
  73. X#define INIT_CRC 0L      /* init value: -1      0       0       */
  74. X#define SWAPPED          /* bit order:  undef   defined defined */
  75. X#define W       32       /* bits in CRC:16      16      16      */
  76. X    /* data type that holds a W-bit unsigned integer */
  77. X#if W <= 16
  78. X#  define WTYPE unsigned short
  79. X#else
  80. X#  define WTYPE   unsigned long
  81. X#endif
  82. X    /* the number of bits per char: don't change it. */
  83. X#define B       8
  84. Xstatic WTYPE crctab[1<<B] = /* as calculated by initcrctab() */ {
  85. X0x0L,  0xc0c00001L,  0xc1800001L,  0x1400000L,  0xc3000001L,  0x3c00000L,  0x2800000L,  0xc2400001L,
  86. X0xc6000001L,  0x6c00000L,  0x7800000L,  0xc7400001L,  0x5000000L,  0xc5c00001L,  0xc4800001L,  0x4400000L,
  87. X0xcc000001L,  0xcc00000L,  0xd800000L,  0xcd400001L,  0xf000000L,  0xcfc00001L,  0xce800001L,  0xe400000L,
  88. X0xa000000L,  0xcac00001L,  0xcb800001L,  0xb400000L,  0xc9000001L,  0x9c00000L,  0x8800000L,  0xc8400001L,
  89. X0xd8000001L,  0x18c00000L,  0x19800000L,  0xd9400001L,  0x1b000000L,  0xdbc00001L,  0xda800001L,  0x1a400000L,
  90. X0x1e000000L,  0xdec00001L,  0xdf800001L,  0x1f400000L,  0xdd000001L,  0x1dc00000L,  0x1c800000L,  0xdc400001L,
  91. X0x14000000L,  0xd4c00001L,  0xd5800001L,  0x15400000L,  0xd7000001L,  0x17c00000L,  0x16800000L,  0xd6400001L,
  92. X0xd2000001L,  0x12c00000L,  0x13800000L,  0xd3400001L,  0x11000000L,  0xd1c00001L,  0xd0800001L,  0x10400000L,
  93. X0xf0000001L,  0x30c00000L,  0x31800000L,  0xf1400001L,  0x33000000L,  0xf3c00001L,  0xf2800001L,  0x32400000L,
  94. X0x36000000L,  0xf6c00001L,  0xf7800001L,  0x37400000L,  0xf5000001L,  0x35c00000L,  0x34800000L,  0xf4400001L,
  95. X0x3c000000L,  0xfcc00001L,  0xfd800001L,  0x3d400000L,  0xff000001L,  0x3fc00000L,  0x3e800000L,  0xfe400001L,
  96. X0xfa000001L,  0x3ac00000L,  0x3b800000L,  0xfb400001L,  0x39000000L,  0xf9c00001L,  0xf8800001L,  0x38400000L,
  97. X0x28000000L,  0xe8c00001L,  0xe9800001L,  0x29400000L,  0xeb000001L,  0x2bc00000L,  0x2a800000L,  0xea400001L,
  98. X0xee000001L,  0x2ec00000L,  0x2f800000L,  0xef400001L,  0x2d000000L,  0xedc00001L,  0xec800001L,  0x2c400000L,
  99. X0xe4000001L,  0x24c00000L,  0x25800000L,  0xe5400001L,  0x27000000L,  0xe7c00001L,  0xe6800001L,  0x26400000L,
  100. X0x22000000L,  0xe2c00001L,  0xe3800001L,  0x23400000L,  0xe1000001L,  0x21c00000L,  0x20800000L,  0xe0400001L,
  101. X0xa0000001L,  0x60c00000L,  0x61800000L,  0xa1400001L,  0x63000000L,  0xa3c00001L,  0xa2800001L,  0x62400000L,
  102. X0x66000000L,  0xa6c00001L,  0xa7800001L,  0x67400000L,  0xa5000001L,  0x65c00000L,  0x64800000L,  0xa4400001L,
  103. X0x6c000000L,  0xacc00001L,  0xad800001L,  0x6d400000L,  0xaf000001L,  0x6fc00000L,  0x6e800000L,  0xae400001L,
  104. X0xaa000001L,  0x6ac00000L,  0x6b800000L,  0xab400001L,  0x69000000L,  0xa9c00001L,  0xa8800001L,  0x68400000L,
  105. X0x78000000L,  0xb8c00001L,  0xb9800001L,  0x79400000L,  0xbb000001L,  0x7bc00000L,  0x7a800000L,  0xba400001L,
  106. X0xbe000001L,  0x7ec00000L,  0x7f800000L,  0xbf400001L,  0x7d000000L,  0xbdc00001L,  0xbc800001L,  0x7c400000L,
  107. X0xb4000001L,  0x74c00000L,  0x75800000L,  0xb5400001L,  0x77000000L,  0xb7c00001L,  0xb6800001L,  0x76400000L,
  108. X0x72000000L,  0xb2c00001L,  0xb3800001L,  0x73400000L,  0xb1000001L,  0x71c00000L,  0x70800000L,  0xb0400001L,
  109. X0x50000000L,  0x90c00001L,  0x91800001L,  0x51400000L,  0x93000001L,  0x53c00000L,  0x52800000L,  0x92400001L,
  110. X0x96000001L,  0x56c00000L,  0x57800000L,  0x97400001L,  0x55000000L,  0x95c00001L,  0x94800001L,  0x54400000L,
  111. X0x9c000001L,  0x5cc00000L,  0x5d800000L,  0x9d400001L,  0x5f000000L,  0x9fc00001L,  0x9e800001L,  0x5e400000L,
  112. X0x5a000000L,  0x9ac00001L,  0x9b800001L,  0x5b400000L,  0x99000001L,  0x59c00000L,  0x58800000L,  0x98400001L,
  113. X0x88000001L,  0x48c00000L,  0x49800000L,  0x89400001L,  0x4b000000L,  0x8bc00001L,  0x8a800001L,  0x4a400000L,
  114. X0x4e000000L,  0x8ec00001L,  0x8f800001L,  0x4f400000L,  0x8d000001L,  0x4dc00000L,  0x4c800000L,  0x8c400001L,
  115. X0x44000000L,  0x84c00001L,  0x85800001L,  0x45400000L,  0x87000001L,  0x47c00000L,  0x46800000L,  0x86400001L,
  116. X0x82000001L,  0x42c00000L,  0x43800000L,  0x83400001L,  0x41000000L,  0x81c00001L,  0x80800001L,  0x40400000L,
  117. X} ;
  118. XWTYPE
  119. Xupdcrc( icrc, icp, icnt )
  120. X    WTYPE icrc;
  121. X    unsigned char *icp;
  122. X    int icnt;
  123. X{
  124. X    register WTYPE crc = icrc;
  125. X    register unsigned char *cp = icp;
  126. X    register int cnt = icnt;
  127. X    while( cnt-- ) {
  128. X#ifndef SWAPPED
  129. X        crc = (crc<<B) ^ crctab[(crc>>(W-B)) ^ *cp++];
  130. X#else
  131. X        crc = (crc>>B) ^ crctab[(crc & ((1<<B)-1)) ^ *cp++];
  132. X#endif SWAPPED
  133. X    }
  134. X    return( crc );
  135. X}
  136. X#ifdef MAKETAB
  137. X#include <stdio.h>
  138. X#include <limits.h>
  139. Xmain()
  140. X{
  141. X    initcrctab();
  142. X}
  143. Xinitcrctab()
  144. X{
  145. X    register  int b, i;
  146. X    WTYPE v;
  147. X    for( b = 0; b <= (1<<B)-1; ++b ) {
  148. X#ifndef SWAPPED
  149. X        for( v = b<<(W-B), i = B; --i >= 0; )
  150. X            v = v & ((WTYPE)1<<(W-1)) ? (v<<1)^P : v<<1;
  151. X#else
  152. X        for( v = b, i = B; --i >= 0; )
  153. X            v = v & 1 ? (v>>1)^P : v>>1;
  154. X#endif
  155. X        crctab[b] = v;
  156. X#if W <= 31
  157. X        printf( "0x%lx,", v & ((1L<<W)-1L));
  158. X#else
  159. X        printf( "0x%lxL,", v & ULONG_MAX);
  160. X#endif
  161. X        if( (b&7) == 7 )
  162. X            printf("\n" );
  163. X        else
  164. X            printf("  ");
  165. X    }
  166. X}
  167. X#endif
  168. X#ifdef TEST
  169. X#include <stdio.h>
  170. X#include <fcntl.h>
  171. X#define MAXBUF  4096
  172. Xmain( ac, av )
  173. X    int ac; char **av;
  174. X{
  175. X    int fd;
  176. X    int nr;
  177. X    int i;
  178. X    char buf[MAXBUF];
  179. X    WTYPE crc, crc2;
  180. X    fd = 0;
  181. X    if( ac > 1 )
  182. X        if( (fd = open( av[1], O_RDONLY )) < 0 ) {
  183. X            perror( av[1] );
  184. X            exit( -1 );
  185. X        }
  186. X    crc = crc2 = INIT_CRC;
  187. X    while( (nr = read( fd, buf, MAXBUF )) > 0 ) {
  188. X        crc = updcrc( crc, buf, nr );
  189. X    }
  190. X    if( nr != 0 )
  191. X        perror( "reading" );
  192. X    else {
  193. X        printf( "%lx\n", crc );
  194. X    }
  195. X#ifdef MAGICCHECK
  196. X    /* tack one's complement of crc onto data stream, and
  197. X       continue crc calculation.  Should get a constant (magic number)
  198. X       dependent only on P, not the data.
  199. X     */
  200. X    crc2 = crc ^ -1L;
  201. X    for( nr = W-B; nr >= 0; nr -= B ) {
  202. X        buf[0] = (crc2 >> nr);
  203. X        crc = updcrc(crc, buf, 1);
  204. X    }
  205. X    /* crc should now equal magic */
  206. X    buf[0] = buf[1] = buf[2] = buf[3] = 0;
  207. X    printf( "magic test: %lx =?= %lx\n", crc, updcrc(-1, buf, W/B));
  208. X#endif MAGICCHECK
  209. X}
  210. X#endif
  211. END_OF_FILE
  212.   if test 7866 -ne `wc -c <'csd/crc32.c'`; then
  213.     echo shar: \"'csd/crc32.c'\" unpacked with wrong size!
  214.   fi
  215.   # end of 'csd/crc32.c'
  216. fi
  217. if test -f 'csd/cs_subr.c' -a "${1}" != "-c" ; then 
  218.   echo shar: Will not clobber existing file \"'csd/cs_subr.c'\"
  219. else
  220.   echo shar: Extracting \"'csd/cs_subr.c'\" \(8626 characters\)
  221.   sed "s/^X//" >'csd/cs_subr.c' <<'END_OF_FILE'
  222. X/* 
  223. X * WorldWide File System
  224. X * Copyright (c) 1992,1993 Youki Kadobayashi
  225. X * Copyright (c) 1992,1993 Osaka University
  226. X * All rights reserved.
  227. X *
  228. X * Permission to use, copy, modify and distribute this software and its
  229. X * documentation is hereby granted, provided that the following conditions
  230. X * are met:
  231. X * 1. Both the copyright notice and this permission notice appear in
  232. X *    all copies of the software, derivative works or modified versions,
  233. X *    and any portions thereof, and that both notices appear in
  234. X *    supporting documentation.
  235. X * 2. All advertising materials mentioning features or use of this software
  236. X *    must display the following acknowledgement:
  237. X *      This product includes software developed by the Osaka University
  238. X *      and its contributors.
  239. X * 3. Neither the name of the University nor the names of its contributors
  240. X *    may be used to endorse or promote products derived from this software
  241. X *    without specific prior written permission.
  242. X *
  243. X * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND OSAKA
  244. X * UNIVERSITY DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  245. X * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  246. X *
  247. X * Osaka University requests users of this software to return to
  248. X *
  249. X *  Youki Kadobayashi
  250. X *  Department of Information and Computer Sciences
  251. X *  Osaka University, Toyonaka 560, Osaka, Japan
  252. X *
  253. X * any improvements or extensions that they make and grant Osaka
  254. X * University the rights to redistribute these changes.
  255. X */
  256. X/*
  257. X * RPC stubs for CS (WWFS Cluster Server) protocol.
  258. X *
  259. X * Darn. it would be far easier if I could write filesystems in Haskell.
  260. X */
  261. Xstatic char *AtFSid = "$Header: cs_subr.c[109.0] Wed Nov 24 03:47:06 1993 youki-k@is.aist-nara.ac.jp saved $";
  262. X
  263. X#include "wfs.h"
  264. X#include "global.h"
  265. X#include "util.h"
  266. X
  267. Xvoid *
  268. Xcs_proc_null_1(argp, rqstp)    /* CS RPC keepalive */
  269. Xvoid *argp;
  270. Xsvc_req *rqstp;
  271. X{
  272. X    static char res;
  273. X    return (void *) &res;
  274. X}
  275. X
  276. Xint *
  277. Xcs_proc_getport_1(argp, rqstp)    /* XXX get NFS port - obsolete */
  278. Xvoid *argp;
  279. Xsvc_req *rqstp;
  280. X{
  281. X    static int res;
  282. X
  283. X#ifdef DEBUG_CSPROC
  284. X    dlog("cs_proc_getport_1");
  285. X#endif
  286. X    bzero((char *)&res, sizeof(res));
  287. X    res = cs_nfsport;
  288. X    return &res;
  289. X}
  290. X
  291. Xcs_fhres *
  292. Xcs_proc_register_1(argp, rqstp)
  293. Xvoid *argp;
  294. Xsvc_req *rqstp;
  295. X{
  296. X    static cs_fhres res;
  297. X    static wf_fh *fhp = (wf_fh *) &res.cs_fhres_u.file;
  298. X
  299. X    /* Establish relationship with csd by initial filehandle. */
  300. X    bzero((char *)&res, sizeof(res));
  301. X    res.status = CS_OK;
  302. X    fhp->world_id = cs_world;
  303. X    fhp->parent_vol = fhp->child_vol = WF_ROOT_VOL_ID;
  304. X    fhp->dir_id = fhp->file_id = WF_ROOT_DIR_ID;
  305. X    return &res;
  306. X}
  307. X
  308. Xcs_res *
  309. Xcs_proc_unregister_1(argp, rqstp)
  310. Xvoid *argp;
  311. Xsvc_req *rqstp;
  312. X{
  313. X    static cs_res res;
  314. X
  315. X    /* Purge relationship with csd. Just for "showmount" function. */
  316. X    res.status = CS_OK;
  317. X    bzero((char *)&res, sizeof(res));
  318. X    return &res;
  319. X}
  320. X
  321. Xstatic int
  322. Xis_cluster_root(rqstp)
  323. Xsvc_req *rqstp;
  324. X{
  325. X    sockaddr_in *sin;
  326. X    struct authunix_parms *unix_cred;
  327. X
  328. X    sin = svc_getcaller(rqstp->rq_xprt);
  329. X    if (rqstp->rq_cred.oa_flavor == AUTH_UNIX) {
  330. X        unix_cred = (struct authunix_parms *) rqstp->rq_clntcred;
  331. X        if (unix_cred->aup_uid == 0
  332. X            && bcmp(&sin->sin_addr, &cs_ipaddr,
  333. X                sizeof(struct in_addr)) == 0) {
  334. X            return 1;
  335. X        }
  336. X    }
  337. X    return 0;
  338. X}
  339. X
  340. X/* volname -> Bool */
  341. Xcs_res *
  342. Xcs_proc_mount_1(argp, rqstp)
  343. Xcs_volargs *argp;
  344. Xsvc_req *rqstp;
  345. X{
  346. X    static cs_res res;
  347. X    wf_thrd *c;
  348. X
  349. X#ifdef DEBUG_CSPROC
  350. X    dlog("cs_proc_mount_1");
  351. X#endif
  352. X    if (!is_cluster_root(rqstp)) {
  353. X        bzero((char *)&res, sizeof(res));
  354. X        res.status = CSERR_ACCES;
  355. X        return &res;
  356. X    }
  357. X    c = thrd_alloc();
  358. X    c->rqstp = CLONE(rqstp);
  359. X    c->fname = argp->vol;
  360. X    c->reply = cs_mount_done;
  361. X    cs_mount(c);
  362. X    return (cs_res *)0;
  363. X}
  364. X
  365. X/* volname -> Bool */
  366. Xcs_res *
  367. Xcs_proc_umount_1(argp, rqstp)
  368. Xcs_volargs *argp;
  369. Xsvc_req *rqstp;
  370. X{
  371. X    static cs_res res;
  372. X
  373. X#ifdef DEBUG_CSPROC
  374. X    dlog("cs_proc_umount_1");
  375. X#endif
  376. X    bzero((char *)&res, sizeof(res));
  377. X    if (!is_cluster_root(rqstp)) {
  378. X        res.status = CSERR_ACCES;
  379. X        return &res;
  380. X    }
  381. X    res.status = cs_umount(argp->vol);
  382. X    return &res;
  383. X}
  384. X
  385. X/* pathname -> filename -> [nfs_fh, fattr] */
  386. Xcs_diropres *
  387. Xcs_proc_lookup_1(argp, rqstp)
  388. Xcs_diropargs *argp;
  389. Xsvc_req *rqstp;
  390. X{
  391. X    static cs_diropres res;
  392. X    wf_fh fh;
  393. X    wf_vol *volp;
  394. X    int ret;
  395. X
  396. X#ifdef DEBUG_CSPROC
  397. X    dlog("cs_proc_lookup_1");
  398. X#endif
  399. X
  400. X    ret = cs_namei(argp->pname, &fh);
  401. X    if (ret != CS_OK) {
  402. X        bzero(&res, sizeof(res));
  403. X        res.status = ret;
  404. X        return &res;
  405. X    }
  406. X    volp = vol_findid(fh.child_vol);
  407. X    if (volp == NULL) {
  408. X        bzero(&res, sizeof(res));
  409. X        res.status = CSERR_STALE;
  410. X        return &res;
  411. X    }
  412. X    cs_lookup(rqstp, volp, &fh, argp->fname);
  413. X    return (cs_diropres *)0;
  414. X}
  415. X
  416. X/* nfs_fh -> cookie -> count -> [[file id, filename, fattr]] */
  417. Xcs_readdirres *
  418. Xcs_proc_readdir_1(argp, rqstp)
  419. Xcs_readdirargs *argp;
  420. Xsvc_req *rqstp;
  421. X{
  422. X    static cs_readdirres res;
  423. X    wf_fh *fhp = (wf_fh *) &argp->dir;
  424. X    wf_vol *volp;
  425. X
  426. X#ifdef DEBUG_CSPROC
  427. X    dlog("cs_proc_readdir_1");
  428. X#endif
  429. X    bzero(&res, sizeof(res));
  430. X    /* auth */
  431. X    if (fhp->world_id != cs_world) {
  432. X        res.status = CSERR_ACCES;
  433. X        return &res;
  434. X    }
  435. X
  436. X    volp = vol_findid(fhp->child_vol);
  437. X    if (volp == NULL) {
  438. X        res.status = CSERR_STALE;
  439. X        return &res;
  440. X    }
  441. X    cs_readdir(rqstp, volp, fhp, argp->cookie, argp->count);
  442. X    return (cs_readdirres *)0;
  443. X}
  444. X
  445. Xcs_readres *
  446. Xcs_proc_read_1(argp, rqstp)
  447. Xcs_readargs *argp;
  448. Xsvc_req *rqstp;
  449. X{
  450. X    static cs_readres res;
  451. X    wf_fh *fhp = (wf_fh *) &argp->file;
  452. X    wf_vol *volp;
  453. X
  454. X#ifdef DEBUG_CSPROC
  455. X    dlog("cs_proc_read_1");
  456. X#endif
  457. X    bzero(&res, sizeof(res));
  458. X    /* auth */
  459. X    if (fhp->world_id != cs_world) {
  460. X        res.status = CSERR_ACCES;
  461. X        return &res;
  462. X    }
  463. X
  464. X    volp = vol_findid(fhp->child_vol);
  465. X    if (volp == NULL) {
  466. X        res.status = CSERR_STALE;
  467. X        return &res;
  468. X    }
  469. X    cs_read(rqstp, volp, fhp, argp->offset, argp->count, argp->totalcount);
  470. X    return (cs_readres *)0;
  471. X}
  472. X
  473. Xcs_volres *
  474. Xcs_proc_getvol_1(argp, rqstp)
  475. Xcs_volargs *argp;
  476. Xsvc_req *rqstp;
  477. X{
  478. X    static cs_volres res;
  479. X    cs_volokres *p;
  480. X    wf_vol *volp;
  481. X
  482. X#ifdef DEBUG_CSPROC
  483. X    dlog("cs_proc_getvol_1");
  484. X#endif
  485. X    bzero((char *)&res, sizeof(res));
  486. X    volp = vol_findname(".", argp->vol);    /* XXX must support subdirs */
  487. X    if (volp == NULL) {
  488. X        res.status = CSERR_NOENT;
  489. X        return &res;
  490. X    }
  491. X    p = &res.cs_volres_u.volok;
  492. X    p->volume_id = volp->id;
  493. X    p->bytes_to_server = volp->stats.bytes_to_server;
  494. X    p->bytes_from_server = volp->stats.bytes_from_server;
  495. X    p->bytes_to_client = volp->stats.bytes_from_server;
  496. X    p->bytes_from_client = volp->stats.bytes_from_client;
  497. X    p->n_request_readdir = volp->stats.n_request_readdir;
  498. X    p->n_request_lookup = volp->stats.n_request_lookup;
  499. X    p->n_request_read = volp->stats.n_request_read;
  500. X    p->n_request_readdir_miss = volp->stats.n_request_readdir_miss;
  501. X    p->n_request_lookup_miss = volp->stats.n_request_lookup_miss;
  502. X    p->n_request_read_miss = volp->stats.n_request_read_miss;
  503. X    return &res;
  504. X}
  505. X
  506. Xcs_xferres *
  507. Xcs_proc_getxfer_1(fhp, rqstp)
  508. Xwf_fh *fhp;
  509. Xsvc_req *rqstp;
  510. X{
  511. X    static cs_xferres res;
  512. X    wf_vol *volp;
  513. X    wf_dir *dirp;
  514. X    wf_file *filep;
  515. X    wf_thrd *thrdp;
  516. X    sockaddr_in *sin;
  517. X
  518. X#ifdef DEBUG_CSPROC
  519. X    dlog("cs_proc_getxfer_1");
  520. X#endif
  521. X    bzero(&res, sizeof(res));
  522. X    volp = vol_findid(fhp->child_vol);
  523. X    if (!volp) {
  524. X        res.status = CSERR_STALE;
  525. X        return &res;
  526. X    }
  527. X    dirp = dir_findcache(volp, fhp->dir_id);
  528. X    if (!dirp) {
  529. X        res.status = CSERR_STALE;
  530. X        return &res;
  531. X    }
  532. X    filep = file_findid(dirp, fhp->child_vol, fhp->file_id);
  533. X    if (!filep) {
  534. X        res.status = CSERR_STALE;
  535. X        return &res;
  536. X    }
  537. X    if (!filep->thrdp) {
  538. X        /* not transferring this file */
  539. X        res.status = CSERR_NOENT;
  540. X        return &res;
  541. X    }
  542. X    thrdp = filep->thrdp;
  543. X    res.status = CS_OK;
  544. X    if (thrdp->rqstp->rq_cred.oa_flavor == AUTH_UNIX) {
  545. X                struct authunix_parms *unix_cred;
  546. X        unix_cred = (struct authunix_parms *) thrdp->rqstp->rq_clntcred;
  547. X        res.cs_xferres_u.xfer.uid = unix_cred->aup_uid;
  548. X        res.cs_xferres_u.xfer.gid = unix_cred->aup_gid;
  549. X    } else {
  550. X        res.cs_xferres_u.xfer.uid = 54321;    /* TNFS? yittch. */
  551. X        res.cs_xferres_u.xfer.gid = 54321;
  552. X    }
  553. X    sin = svc_getcaller(thrdp->rqstp->rq_xprt);
  554. X    res.cs_xferres_u.xfer.ip_address = sin->sin_addr.s_addr;
  555. X    res.cs_xferres_u.xfer.bytes = thrdp->bytes;
  556. X    res.cs_xferres_u.xfer.idle = thrdp->idle;
  557. X    res.cs_xferres_u.xfer.server.server_len = strlen(thrdp->cp->srv->name);
  558. X    res.cs_xferres_u.xfer.server.server_val = thrdp->cp->srv->name;
  559. X    return &res;
  560. X}
  561. X
  562. Xcs_udares *
  563. Xcs_proc_getuda_1(argp, rqstp)
  564. Xcs_udaargs *argp;
  565. Xsvc_req *rqstp;
  566. X{
  567. X    static cs_udares res;
  568. X
  569. X#ifdef DEBUG_CSPROC
  570. X    dlog("cs_proc_getuda_1");
  571. X#endif
  572. X    bzero((char *)&res, sizeof(res));
  573. X    cs_getuda(rqstp, (wf_fh *) &argp->file, argp->attrname);
  574. X    return &res;
  575. X}
  576. X
  577. Xcs_geterrres *
  578. Xcs_proc_geterr_1(argp, rqstp)
  579. Xcs_geterrargs *argp;
  580. Xsvc_req *rqstp;
  581. X{
  582. X    static cs_geterrres res;
  583. X
  584. X#ifdef DEBUG_CSPROC
  585. X    dlog("cs_proc_geterr_1");
  586. X#endif
  587. X    bzero((char *)&res, sizeof(res));
  588. X    cs_geterr(rqstp, argp->err_context);
  589. X    return &res;
  590. X}
  591. X
  592. END_OF_FILE
  593.   if test 8626 -ne `wc -c <'csd/cs_subr.c'`; then
  594.     echo shar: \"'csd/cs_subr.c'\" unpacked with wrong size!
  595.   fi
  596.   # end of 'csd/cs_subr.c'
  597. fi
  598. if test -f 'csd/main.c' -a "${1}" != "-c" ; then 
  599.   echo shar: Will not clobber existing file \"'csd/main.c'\"
  600. else
  601.   echo shar: Extracting \"'csd/main.c'\" \(8762 characters\)
  602.   sed "s/^X//" >'csd/main.c' <<'END_OF_FILE'
  603. X/* 
  604. X * WorldWide File System
  605. X * Copyright (c) 1992,1993 Youki Kadobayashi
  606. X * Copyright (c) 1992,1993 Osaka University
  607. X * All rights reserved.
  608. X *
  609. X * Permission to use, copy, modify and distribute this software and its
  610. X * documentation is hereby granted, provided that the following conditions
  611. X * are met:
  612. X * 1. Both the copyright notice and this permission notice appear in
  613. X *    all copies of the software, derivative works or modified versions,
  614. X *    and any portions thereof, and that both notices appear in
  615. X *    supporting documentation.
  616. X * 2. All advertising materials mentioning features or use of this software
  617. X *    must display the following acknowledgement:
  618. X *      This product includes software developed by the Osaka University
  619. X *      and its contributors.
  620. X * 3. Neither the name of the University nor the names of its contributors
  621. X *    may be used to endorse or promote products derived from this software
  622. X *    without specific prior written permission.
  623. X *
  624. X * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND OSAKA
  625. X * UNIVERSITY DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  626. X * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  627. X *
  628. X * Osaka University requests users of this software to return to
  629. X *
  630. X *  Youki Kadobayashi
  631. X *  Department of Information and Computer Sciences
  632. X *  Osaka University, Toyonaka 560, Osaka, Japan
  633. X *
  634. X * any improvements or extensions that they make and grant Osaka
  635. X * University the rights to redistribute these changes.
  636. X */
  637. X/* Cluster Server; part of Worldwide File System */
  638. Xstatic char *AtFSid = "$Header: main.c[109.0] Wed Nov 24 03:47:11 1993 youki-k@is.aist-nara.ac.jp saved $";
  639. X
  640. X#include <sys/types.h>
  641. X#include <sys/signal.h>
  642. X#include <sys/file.h>        /* for R_OK */
  643. X#ifndef R_OK
  644. X#include <unistd.h>
  645. X#endif
  646. X#include <fcntl.h>        /* for O_RDWR */
  647. X#include <netdb.h>        /* for hostent */
  648. X#include <setjmp.h>        /* for jmp_buf */
  649. X#include <string.h>        /* for strchr */
  650. X#include <pwd.h>        /* for getpwnam */
  651. X#include "wfs.h"
  652. X#include "util.h"
  653. X#include "global.h"
  654. X#include <arpa/nameser.h>
  655. X#include <resolv.h>
  656. X
  657. X/* configurable parameters */
  658. Xchar        *cs_domain;        /* my domain name */
  659. Xchar        *cs_topdir;        /* top directory of entire system */
  660. Xunsigned long    cs_minfree;        /* minimum free space to be left */
  661. X
  662. X/* network related information */
  663. Xchar        cs_hostname[MAXHOSTNAMELEN];    /* my hostname */
  664. Xstruct in_addr    cs_ipaddr;            /* my IP address */
  665. Xint        cs_nfsport;            /* my NFS port */
  666. X
  667. X/* for messages */
  668. Xchar        *cs_progname;            /* my program name */
  669. Xint        cs_world = 0xC0FFEE;        /* my world id */
  670. Xint        cs_pid;                /* my process id */
  671. Xint        cs_uid;                /* my user id */
  672. Xint        cs_gid;                /* my group id */
  673. Xchar        *cs_conf = "/etc/csd.conf";    /* daemon configuration file */
  674. X
  675. X/* internal state */
  676. Xserv_state    cs_state;            /* my state */
  677. Xjmp_buf        select_intr;
  678. Xint        select_intr_valid;
  679. Xtime_t        now;
  680. Xint        foreground = 1;
  681. Xint        immediate_abort;
  682. X
  683. Xstatic void
  684. Xsigterm(sig)
  685. Xint sig;
  686. X{
  687. X    switch (sig) {
  688. X    case SIGINT:
  689. X        immediate_abort = 15;
  690. X        break;
  691. X    case SIGTERM:
  692. X        immediate_abort = -1;
  693. X        break;
  694. X    }
  695. X    syslog(LOG_WARNING, "going down on signal %d", sig);
  696. X    if (select_intr_valid)
  697. X        longjmp(select_intr, sig);
  698. X}
  699. X
  700. Xstatic void
  701. Xsighup(sig)
  702. Xint sig;
  703. X{
  704. X}
  705. X
  706. Xstatic void
  707. Xcsd_getnames()
  708. X{
  709. X    /* get identifiers: [gup]id, IP address, and hostname */
  710. X    struct sockaddr_in sin;
  711. X    struct passwd *pw;
  712. X
  713. X    /*
  714. X     * get uid, gid, pid
  715. X     */
  716. X    pw = getpwnam("wwfs");
  717. X    if (!pw) {
  718. X        syslog(LOG_CRIT, "Password entry for user \"wwfs\" not set");
  719. X        csd_abort(1);
  720. X    }
  721. X    cs_uid = pw->pw_uid;
  722. X    cs_gid = pw->pw_gid;
  723. X    cs_pid = getpid();
  724. X
  725. X    /*
  726. X     * get IP address
  727. X     */
  728. X    get_myaddress(&sin);        /* rpc(3N) */
  729. X    cs_ipaddr.s_addr = sin.sin_addr.s_addr;
  730. X
  731. X    /*
  732. X     * get hostname
  733. X     */
  734. X    if (gethostname(cs_hostname, sizeof(cs_hostname)) < 0) {
  735. X        syslog(LOG_CRIT, "gethostname: %m");
  736. X        csd_abort(1);
  737. X    }
  738. X    if (!*cs_hostname) {
  739. X        syslog(LOG_CRIT, "host name is not set");
  740. X        csd_abort(1);
  741. X    }
  742. X}
  743. X
  744. Xstatic void
  745. Xcsd_getdomain()
  746. X{
  747. X    /*
  748. X     * get network name
  749. X     */
  750. X    char *domdot;
  751. X
  752. X    if (domdot = strchr(cs_hostname, '.')) {
  753. X        /*
  754. X         * Hostname already contains domainname.
  755. X         * Split out hostname and domainname components
  756. X         */
  757. X        *domdot++ = '\0';
  758. X        cs_domain = domdot;
  759. X    } else if (! cs_domain) {
  760. X        /* LIBS=-lresolv and proper DNS configuration required */
  761. X        struct hostent *hp;
  762. X        hp = gethostbyname(cs_hostname);
  763. X        assert(hp != NULL);
  764. X        strcpy(cs_hostname, hp->h_name);
  765. X        domdot = strchr(cs_hostname, '.');
  766. X        if (domdot) {
  767. X            *domdot++ = '\0';
  768. X            cs_domain = domdot;
  769. X        } else {
  770. X            int i;
  771. X            for (i = 0; hp->h_aliases[i]; ++i) {
  772. X                strcpy(cs_hostname, hp->h_aliases[i]);
  773. X                domdot = strchr(cs_hostname, '.');
  774. X                if (domdot) {
  775. X                    *domdot++ = '\0';
  776. X                    cs_domain = domdot;
  777. X                    break;
  778. X                }
  779. X            }
  780. X        }
  781. X        assert(cs_domain != NULL);
  782. X    }
  783. X}
  784. X
  785. Xmain(argc, argv)
  786. Xint argc;
  787. Xchar **argv;
  788. X{
  789. X    int error;
  790. X
  791. X    /*
  792. X     * initial status
  793. X     */
  794. X    cs_state = Start;
  795. X    openlog("csd", LOG_PID, LOG_DAEMON);
  796. X
  797. X    /*
  798. X     * sanity check
  799. X     */
  800. X    assert(sizeof(nfscookie) >= sizeof (unsigned int));
  801. X    assert(sizeof(int) >= 4);
  802. X    if (geteuid() != 0) {
  803. X        syslog(LOG_WARNING, "Must be root to run WWFS");
  804. X        csd_abort(1);
  805. X    }
  806. X
  807. X    /*
  808. X     * get program name
  809. X     */
  810. X    if (argv[0]) {
  811. X        cs_progname = strrchr(argv[0], '/');
  812. X        if (cs_progname && cs_progname[1])
  813. X            cs_progname++;
  814. X        else
  815. X            cs_progname = argv[0];
  816. X    }
  817. X    if (!cs_progname)
  818. X        cs_progname = "csd";
  819. X
  820. X    /*
  821. X     * get initial time
  822. X     */
  823. X    realtime();
  824. X
  825. X    /*
  826. X     * hook signal
  827. X     */
  828. X    /* Trap interrupts for shutdowns. */
  829. X    (void) signal(SIGINT, sigterm);
  830. X
  831. X    /* Hangups tell us to reload the cache */
  832. X    (void) signal(SIGHUP, sighup);
  833. X
  834. X    /* Trap Terminate so that we can shutdown gracefully (some chance) */
  835. X    (void) signal(SIGTERM, sigterm);
  836. X
  837. X    /* ICMP is much informative than SIGPIPE */
  838. X    (void) signal(SIGPIPE, SIG_IGN);
  839. X
  840. X    /*
  841. X     * get identifiers
  842. X     */
  843. X    csd_getnames();
  844. X    if (parse_conf(cs_conf, csd_tailor) < 0) {
  845. X        dlog("error reading config file %s", cs_conf);
  846. X        csd_abort(1);        /* Fatal error in configuration file */
  847. X    }
  848. X    csd_getdomain();
  849. X
  850. X    /*
  851. X     * get arguments
  852. X     */
  853. X    /* XXX */
  854. X    /* get_args(argc, argv); */;
  855. X
  856. X    if (argc == 1    /* XXX */
  857. X        && getppid() != 1) {    /* I'm not started by init. */
  858. X        int fd;
  859. X
  860. X        /* portions of this code came from
  861. X         * "UNIX Network Programming", W. Richard Stevens
  862. X         */
  863. X        if (background() > 0)
  864. X            exit(0);    /* parent process */
  865. X        
  866. X#ifdef TIOCNOTTY
  867. X        /* BSDism here. */
  868. X        setpgrp(0, getpid());
  869. X        if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
  870. X            ioctl(fd, TIOCNOTTY, 0);
  871. X            close(fd);
  872. X        }
  873. X#else
  874. X        /* SysV anyone? */
  875. X        setpgrp();
  876. X#endif
  877. X        closelog();
  878. X        for (fd = 0; fd < NOFILE; ++fd)
  879. X            close(fd);
  880. X        errno = 0;
  881. X        openlog("csd", LOG_PID, LOG_DAEMON);    /* itch. */
  882. X    }
  883. X
  884. X    /*
  885. X     * initialize other module as uid=root
  886. X     */
  887. X    csd_start_1();
  888. X
  889. X    /*
  890. X     * change user and group id
  891. X     */
  892. X    setuid(cs_uid);
  893. X    setgid(cs_gid);
  894. X
  895. X    /*
  896. X     * initialize other module as uid=wwfs
  897. X     */
  898. X    csd_start_2();
  899. X
  900. X    /*
  901. X     * other unix environments
  902. X     */
  903. X    umask(022);
  904. X    chdir(cs_topdir);
  905. X
  906. X    /*
  907. X     * DNS should not freeze csd
  908. X     */
  909. X    _res.retrans = 1;
  910. X    _res.retry   = 5;
  911. X
  912. X    /*
  913. X     * RPC binding
  914. X     */
  915. X    error = csd_rpc();
  916. X
  917. X    /*
  918. X     * start the server
  919. X     */
  920. X    if (!error && csd_run() != Done) {
  921. X        syslog(LOG_CRIT, "csd_run failed");
  922. X        cs_state = Done;
  923. X    }
  924. X
  925. X    /*
  926. X     * going down
  927. X     */
  928. X    csd_abort(error);
  929. X
  930. X    abort();
  931. X}
  932. X
  933. X/* initialize other modules as root */
  934. Xvoid
  935. Xcsd_start_1()
  936. X{
  937. X    dlog_start();
  938. X    icmp_start();
  939. X}
  940. X
  941. X/* initialize other modules as wwfs */
  942. Xvoid
  943. Xcsd_start_2()
  944. X{
  945. X    getdate();
  946. X    alloc_start();
  947. X    root_start();
  948. X    bfs_start();
  949. X    dir_start();
  950. X    conn_start();
  951. X    thrd_start();
  952. X    uip_start();
  953. X    talk_start();
  954. X#ifdef TRACE
  955. X    trace_start();
  956. X#endif
  957. X}
  958. X
  959. Xvoid
  960. Xcsd_stop()
  961. X{
  962. X    thrd_stop();
  963. X    conn_stop();
  964. X    dlog_stop();
  965. X}
  966. X
  967. Xstatic int
  968. Xcsd_set_domain(name)
  969. Xchar *name;
  970. X{
  971. X    if (! strchr(name, '.')) {
  972. X        syslog(LOG_ERR, "%s: DOMAIN: invalid domain name", cs_conf);
  973. X        return -1;
  974. X    }
  975. X    cs_domain = name;
  976. X    return 0;
  977. X}
  978. X
  979. Xstatic int
  980. Xcsd_set_topdir(topdir)
  981. Xchar *topdir;
  982. X{
  983. X    if (validate_dir(topdir) < 0) {
  984. X        syslog(LOG_ERR, "%s: WWFSDIR (%s): %m", cs_conf, topdir);
  985. X        return -1;
  986. X    }
  987. X    /*
  988. X     * now that topdir exists, check if it is writable by "wwfs"
  989. X     */
  990. X    if (access(topdir, R_OK|W_OK|X_OK) < 0) {
  991. X        syslog(LOG_ERR, "%s: WWFSDIR (%s): permission denied",
  992. X               cs_conf, topdir);
  993. X        return -1;
  994. X    }
  995. X    cs_topdir = topdir;
  996. X    return 0;
  997. X}
  998. X
  999. Xstatic int
  1000. Xcsd_set_minfree(capacity)
  1001. Xchar *capacity;
  1002. X{
  1003. X    switch (capacity[strlen(capacity)-1]) {
  1004. X    case 'G':
  1005. X    case 'g':
  1006. X        cs_minfree = atoi(capacity) * 1024 * 1024 * 1024;
  1007. X        break;
  1008. X    case 'M':
  1009. X    case 'm':
  1010. X        cs_minfree = atoi(capacity) * 1024 * 1024;
  1011. X        break;
  1012. X    case 'K':
  1013. X    case 'k':
  1014. X        cs_minfree = atoi(capacity) * 1024;
  1015. X        break;
  1016. X    default:
  1017. X        syslog(LOG_ERR, "%s: MINFREE: Ambiguous storage unit", cs_conf);
  1018. X        return -1;
  1019. X    }
  1020. X    return 0;
  1021. X}
  1022. X
  1023. Xstatic wf_tailor cs_tailor[] = {
  1024. X    { "DOMAIN", csd_set_domain },
  1025. X    { "MINFREE", csd_set_minfree },
  1026. X    { "WWFSDIR", csd_set_topdir },
  1027. X    { NULL, (int (*)())0 }
  1028. X};
  1029. X
  1030. Xint
  1031. Xcsd_tailor(name, value)
  1032. Xchar *name;
  1033. Xchar *value;
  1034. X{
  1035. X    return parse_tailor(cs_tailor, name, value);
  1036. X}
  1037. X
  1038. END_OF_FILE
  1039.   if test 8762 -ne `wc -c <'csd/main.c'`; then
  1040.     echo shar: \"'csd/main.c'\" unpacked with wrong size!
  1041.   fi
  1042.   # end of 'csd/main.c'
  1043. fi
  1044. if test -f 'csd/sched.c' -a "${1}" != "-c" ; then 
  1045.   echo shar: Will not clobber existing file \"'csd/sched.c'\"
  1046. else
  1047.   echo shar: Extracting \"'csd/sched.c'\" \(7458 characters\)
  1048.   sed "s/^X//" >'csd/sched.c' <<'END_OF_FILE'
  1049. Xstatic char *AtFSid = "$Header: sched.c[109.0] Wed Nov 24 03:47:16 1993 youki-k@is.aist-nara.ac.jp saved $";
  1050. X/*
  1051. X * Copyright (c) 1990 Jan-Simon Pendry
  1052. X * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  1053. X * Copyright (c) 1990 The Regents of the University of California.
  1054. X * All rights reserved.
  1055. X *
  1056. X * This code is derived from software contributed to Berkeley by
  1057. X * Jan-Simon Pendry at Imperial College, London.
  1058. X *
  1059. X * Redistribution and use in source and binary forms, with or without
  1060. X * modification, are permitted provided that the following conditions
  1061. X * are met:
  1062. X * 1. Redistributions of source code must retain the above copyright
  1063. X *    notice, this list of conditions and the following disclaimer.
  1064. X * 2. Redistributions in binary form must reproduce the above copyright
  1065. X *    notice, this list of conditions and the following disclaimer in the
  1066. X *    documentation and/or other materials provided with the distribution.
  1067. X * 3. All advertising materials mentioning features or use of this software
  1068. X *    must display the following acknowledgement:
  1069. X *      This product includes software developed by the University of
  1070. X *      California, Berkeley and its contributors.
  1071. X * 4. Neither the name of the University nor the names of its contributors
  1072. X *    may be used to endorse or promote products derived from this software
  1073. X *    without specific prior written permission.
  1074. X *
  1075. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1076. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1077. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1078. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1079. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1080. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1081. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1082. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1083. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1084. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1085. X * SUCH DAMAGE.
  1086. X *
  1087. X *    %W% (Berkeley) %G%
  1088. X *
  1089. X * $Id: sched.c,v 5.2.2.1 1992/02/09 15:09:02 jsp beta $
  1090. X *
  1091. X */
  1092. X
  1093. X/*
  1094. X * Process scheduler
  1095. X */
  1096. X/* #define DEBUG_SLEEP */
  1097. X
  1098. X#include <sys/signal.h>
  1099. X#include <sys/wait.h>
  1100. X#include <setjmp.h>
  1101. X#include "wfs.h"
  1102. X#include "util.h"
  1103. Xextern jmp_buf select_intr;
  1104. Xextern int select_intr_valid;
  1105. X
  1106. Xtypedef struct pjob pjob;
  1107. Xstruct pjob {
  1108. X    qelem hdr;            /* Linked list */
  1109. X    int pid;            /* Process ID of job */
  1110. X    func cb_fun;            /* Callback function */
  1111. X    void *cb_closure;        /* Closure for callback */
  1112. X    void *wchan;            /* Wait channel */
  1113. X};
  1114. X
  1115. Xextern qelem proc_list_head;
  1116. Xqelem proc_list_head = { &proc_list_head, &proc_list_head };
  1117. Xextern qelem proc_wait_list;
  1118. Xqelem proc_wait_list = { &proc_wait_list, &proc_wait_list };
  1119. X
  1120. Xint task_notify_todo;
  1121. X
  1122. Xstatic pjob *sched_job(cf, ca)
  1123. Xfunc cf;
  1124. Xvoid *ca;
  1125. X{
  1126. X    pjob *p = ALLOC(pjob);
  1127. X
  1128. X    p->cb_fun = cf;
  1129. X    p->cb_closure = ca;
  1130. X
  1131. X    /* Now append on wait queue */
  1132. X    q_insert(p, LAST(pjob, &proc_wait_list));
  1133. X
  1134. X    return p;
  1135. X}
  1136. X
  1137. Xstatic pjob *sched_job_atop(cf, ca)
  1138. Xfunc cf;
  1139. Xvoid *ca;
  1140. X{
  1141. X    pjob *p = ALLOC(pjob);
  1142. X
  1143. X    p->cb_fun = cf;
  1144. X    p->cb_closure = ca;
  1145. X
  1146. X    /* Now place on top of wait queue */
  1147. X    q_insert(p, &proc_wait_list);
  1148. X
  1149. X    return p;
  1150. X}
  1151. X
  1152. Xvoid run_task(tf, ta, cf, ca)
  1153. Xint (*tf)();
  1154. Xvoid *ta;
  1155. Xfunc cf;
  1156. Xvoid *ca;
  1157. X{
  1158. X    pjob *p = sched_job(cf, ca);
  1159. X    int mask;
  1160. X
  1161. X    p->wchan = (void *) p;
  1162. X
  1163. X    mask = sigblock(sigmask(SIGCHLD));
  1164. X
  1165. X    if (p->pid = background()) {
  1166. X        sigsetmask(mask);
  1167. X        return;
  1168. X    }
  1169. X
  1170. X    exit((*tf)(ta));
  1171. X    /* firewall... */
  1172. X    abort();
  1173. X}
  1174. X
  1175. X/*
  1176. X * Schedule a task to be run when woken up
  1177. X */
  1178. Xvoid sched_task(cf, ca, wchan)
  1179. Xfunc cf;
  1180. Xvoid *ca;
  1181. Xvoid *wchan;
  1182. X{
  1183. X    /*
  1184. X     * Allocate a new task
  1185. X     */
  1186. X    pjob *p = sched_job(cf, ca);
  1187. X    p->wchan = wchan;
  1188. X    p->pid = 0;
  1189. X#ifdef DEBUG_SLEEP
  1190. X    dlog("SLEEP on %x", wchan);
  1191. X#endif
  1192. X}
  1193. X
  1194. X/*
  1195. X * On some specific situation, the order of wakeupjob() calls
  1196. X * lead to a problem, since every resource manipulation functions
  1197. X * should be bracketed between resource-allocation functions and
  1198. X * resource-freeing functions; incorrect ordering of wakeupjob()
  1199. X * will violate this rule.
  1200. X *
  1201. X * sched_task_atop() was devised for this purpose; i.e. to avoid
  1202. X * freeing resources before they are accessed.
  1203. X */
  1204. Xvoid sched_task_atop(cf, ca, wchan)
  1205. Xfunc cf;
  1206. Xvoid *ca;
  1207. Xvoid *wchan;
  1208. X{
  1209. X    /*
  1210. X     * Allocate a new task
  1211. X     */
  1212. X    pjob *p = sched_job_atop(cf, ca);
  1213. X    p->wchan = wchan;
  1214. X    p->pid = 0;
  1215. X#ifdef DEBUG_SLEEP
  1216. X    dlog("SLEEP on %x", wchan);
  1217. X#endif
  1218. X}
  1219. X
  1220. Xstatic void wakeupjob(p)
  1221. Xpjob *p;
  1222. X{
  1223. X    q_remove(p);
  1224. X    q_insert(p, &proc_list_head);
  1225. X    task_notify_todo++;
  1226. X#ifdef DEBUG_SLEEP
  1227. X    dlog("task_notify_todo = %d", task_notify_todo);
  1228. X#endif
  1229. X}
  1230. X
  1231. Xvoid wakeup(wchan)
  1232. Xvoid *wchan;
  1233. X{
  1234. X    pjob *p, *p2;
  1235. X#ifdef DEBUG_SLEEP
  1236. X    int done = 0;
  1237. X#endif
  1238. X
  1239. X#ifdef DEBUG_SLEEP
  1240. X    dlog("wakeup(%x)", wchan);
  1241. X#endif
  1242. X    /* Use ITER2() here because wakeupjob() juggles the list. */
  1243. X    ITER2(p, p2, pjob, &proc_wait_list) {
  1244. X        if (p->wchan == wchan) {
  1245. X#ifdef DEBUG_SLEEP
  1246. X            done = 1;
  1247. X#endif
  1248. X            wakeupjob(p);
  1249. X        }
  1250. X    }
  1251. X
  1252. X#ifdef DEBUG_SLEEP
  1253. X    if (!done)
  1254. X        dlog("Nothing SLEEPing on %x", wchan);
  1255. X#endif
  1256. X}
  1257. X
  1258. X/*ARGSUSED*/
  1259. X
  1260. Xvoid sigchld(sig)
  1261. Xint sig;
  1262. X{
  1263. X    union wait w;
  1264. X    int pid;
  1265. X
  1266. X#ifdef SYS5_SIGNALS
  1267. X    if ((pid = wait(&w)) > 0) {
  1268. X#else
  1269. X    while ((pid = wait3((int *) &w, WNOHANG, (struct rusage *) 0)) > 0) {
  1270. X#endif /* SYS5_SIGNALS */
  1271. X        pjob *p, *p2;
  1272. X
  1273. X        if (WIFSIGNALED(w))
  1274. X            syslog(LOG_ERR, "Process %d exited with signal %d",
  1275. X                pid, w.w_termsig);
  1276. X#ifdef DEBUG
  1277. X        else
  1278. X            dlog("Process %d exited with status %d",
  1279. X                pid, w.w_retcode);
  1280. X#endif /* DEBUG */
  1281. X
  1282. X        ITER2(p, p2, pjob, &proc_wait_list) {
  1283. X            if (p->pid == pid) {
  1284. X                wakeupjob(p);
  1285. X                break;
  1286. X            }
  1287. X        }
  1288. X
  1289. X#ifdef DEBUG
  1290. X        if (p) ; else dlog("can't locate task block for pid %d", pid);
  1291. X#endif /* DEBUG */
  1292. X    }
  1293. X
  1294. X#ifdef SYS5_SIGNALS
  1295. X    signal(sig, sigchld);
  1296. X#endif /* SYS5_SIGNALS */
  1297. X    if (select_intr_valid)
  1298. X        longjmp(select_intr, sig);
  1299. X}
  1300. X
  1301. X/*
  1302. X * Run any pending tasks.
  1303. X * This must be called with SIGCHLD disabled
  1304. X */
  1305. Xvoid do_task_notify()
  1306. X{
  1307. X    /*
  1308. X     * Keep taking the first item off the list and processing it.
  1309. X     *
  1310. X     * Done this way because the the callback can, quite reasonably,
  1311. X     * queue a new task, so no local reference into the list can be
  1312. X     * held here.
  1313. X     */
  1314. X#ifdef DEBUG_SLEEP
  1315. X    dlog("do_task_notify");
  1316. X#endif
  1317. X    while (MORE(&proc_list_head)) {
  1318. X        pjob *p = FIRST(pjob, &proc_list_head);
  1319. X        q_remove(p);
  1320. X        /*
  1321. X         * This job has completed
  1322. X         */
  1323. X        --task_notify_todo;
  1324. X#ifdef DEBUG_SLEEP
  1325. X        dlog("task_notify_todo = %d", task_notify_todo);
  1326. X#endif
  1327. X
  1328. X        /*
  1329. X         * Do callback if it exists
  1330. X         */
  1331. X        if (p->cb_fun) {
  1332. X            (*p->cb_fun)(p->cb_closure);
  1333. X        }
  1334. X
  1335. X        FREE((void *) p);
  1336. X    }
  1337. X}
  1338. X
  1339. X#ifdef HAS_SVR3_SIGNALS
  1340. X/*
  1341. X * 4.2 signal library based on svr3 (4.1+ bsd) interface
  1342. X * From Stephen C. Pope <scp@acl.lanl.gov).
  1343. X */
  1344. X
  1345. Xstatic int current_mask = 0;
  1346. X
  1347. Xint sigblock(mask)
  1348. Xint mask;
  1349. X{
  1350. X    int sig;
  1351. X    int m;
  1352. X    int oldmask;
  1353. X
  1354. X    oldmask = current_mask;
  1355. X    for ( sig = 1, m = 1; sig <= MAXSIG; sig++, m <<= 1 ) {
  1356. X        if (mask & m)  {
  1357. X        sighold(sig);
  1358. X            current_mask |= m;
  1359. X        }
  1360. X    }
  1361. X    return oldmask;
  1362. X}
  1363. X
  1364. Xint sigsetmask(mask)
  1365. Xint mask;
  1366. X{
  1367. X    int sig;
  1368. X    int m;
  1369. X    int oldmask;
  1370. X
  1371. X    oldmask = current_mask;
  1372. X    for ( sig = 1, m = 1; sig <= MAXSIG; sig++, m <<= 1 ) {
  1373. X        if (mask & m)  {
  1374. X            sighold(sig);
  1375. X            current_mask |= m;
  1376. X        }
  1377. X        else  {
  1378. X            sigrelse(sig);
  1379. X            current_mask &= ~m;
  1380. X        }
  1381. X    }
  1382. X    return oldmask;
  1383. X}
  1384. X
  1385. X#endif /* HAS_SVR3_SIGNALS */
  1386. END_OF_FILE
  1387.   if test 7458 -ne `wc -c <'csd/sched.c'`; then
  1388.     echo shar: \"'csd/sched.c'\" unpacked with wrong size!
  1389.   fi
  1390.   # end of 'csd/sched.c'
  1391. fi
  1392. if test -f 'doc/overview.eps' -a "${1}" != "-c" ; then 
  1393.   echo shar: Will not clobber existing file \"'doc/overview.eps'\"
  1394. else
  1395.   echo shar: Extracting \"'doc/overview.eps'\" \(7624 characters\)
  1396.   sed "s/^X//" >'doc/overview.eps' <<'END_OF_FILE'
  1397. X%!PS-Adobe-2.0 EPSF-2.0
  1398. X%%Title: /tmp/xfig-fig006468
  1399. X%%Creator: fig2dev
  1400. X%%CreationDate: Sat Aug 14 02:16:47 1993
  1401. X%%For: youki-k@dec413 (Youki Kadobayashi)
  1402. X%%BoundingBox: -1 0 617 233
  1403. X%%Pages: 0
  1404. X%%EndComments
  1405. X/$F2psDict 200 dict def 
  1406. X$F2psDict begin
  1407. X$F2psDict /mtrx matrix put
  1408. X/l {lineto} bind def
  1409. X/m {moveto} bind def
  1410. X/s {stroke} bind def
  1411. X/n {newpath} bind def
  1412. X/gs {gsave} bind def
  1413. X/gr {grestore} bind def
  1414. X/clp {closepath} bind def
  1415. X/graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
  1416. X4 -2 roll mul setrgbcolor} bind def
  1417. X/col-1 {} def
  1418. X/col0 {0 0 0 setrgbcolor} bind def
  1419. X/col1 {0 0 1 setrgbcolor} bind def
  1420. X/col2 {0 1 0 setrgbcolor} bind def
  1421. X/col3 {0 1 1 setrgbcolor} bind def
  1422. X/col4 {1 0 0 setrgbcolor} bind def
  1423. X/col5 {1 0 1 setrgbcolor} bind def
  1424. X/col6 {1 1 0 setrgbcolor} bind def
  1425. X/col7 {1 1 1 setrgbcolor} bind def
  1426. X /DrawEllipse {
  1427. X    /endangle exch def
  1428. X    /startangle exch def
  1429. X    /yrad exch def
  1430. X    /xrad exch def
  1431. X    /y exch def
  1432. X    /x exch def
  1433. X    /savematrix mtrx currentmatrix def
  1434. X    x y translate xrad yrad scale 0 0 1 startangle endangle arc
  1435. X    savematrix setmatrix
  1436. X    } def
  1437. X
  1438. X    end
  1439. X/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
  1440. X/$F2psEnd {$F2psEnteredState restore end} def
  1441. X%%EndProlog
  1442. X
  1443. X$F2psBegin
  1444. X0 setlinecap 0 setlinejoin
  1445. X-40.0 288.0 translate 0.900 -0.900 scale
  1446. X0.500 setlinewidth
  1447. X% Polyline
  1448. Xn 66 204 m 59 204 59 237 7 arcto 4 {pop} repeat 59 244 102 244 7 arcto 4 {pop} repeat 109 244 109 211 7 arcto 4 {pop} repeat 109 204 66 204 7 arcto 4 {pop} repeat clp gs col-1 s gr
  1449. X% Polyline
  1450. Xn 114 249 m 114 199 l  54 199 l  54 249 l  clp gs col-1 s gr
  1451. X% Polyline
  1452. Xn 54 254 m 44 269 l  104 269 l  114 254 l  54 254 l gs col-1 s gr
  1453. X% Polyline
  1454. Xn 114 199 m 124 204 l  124 239 l  114 249 l gs col-1 s gr
  1455. X% Polyline
  1456. Xn 114 254 m 114 264 l  104 274 l  44 274 l  44 269 l gs col-1 s gr
  1457. X% Polyline
  1458. Xn 104 269 m 104 274 l gs col-1 s gr
  1459. X/Courier findfont 6.00 scalefont setfont
  1460. X64 214 m 
  1461. Xgs 1 -1 scale (cd /ww/fs) col-1 show gr
  1462. X/Courier findfont 6.00 scalefont setfont
  1463. X64 224 m 
  1464. Xgs 1 -1 scale (cat INDEX) col-1 show gr
  1465. X/Courier findfont 6.00 scalefont setfont
  1466. X64 234 m 
  1467. Xgs 1 -1 scale (cd RFC) col-1 show gr
  1468. X% Ellipse
  1469. Xn 74 186 5 2 0 360 DrawEllipse gs col-1 s gr
  1470. X% Ellipse
  1471. Xn 81 178 8 4 0 360 DrawEllipse gs col-1 s gr
  1472. X% Ellipse
  1473. Xn 96 155 28 17 0 360 DrawEllipse gs col-1 s gr
  1474. X/Helvetica-Bold findfont 16.00 scalefont setfont
  1475. X79 159 m 
  1476. Xgs 1 -1 scale ("     ") col-1 show gr
  1477. X% Polyline
  1478. Xn 394 259 m 394 174 l  329 174 l  329 259 l  clp gs col-1 s gr
  1479. X% Polyline
  1480. Xn 394 174 m 409 164 l  409 249 l  394 259 l gs col-1 s gr
  1481. X% Polyline
  1482. Xn 329 174 m 344 164 l  409 164 l gs col-1 s gr
  1483. X% Polyline
  1484. Xn 409 244 m 424 244 l  394 264 l  314 264 l  329 254 l gs col-1 s gr
  1485. X% Polyline
  1486. Xn 314 264 m 314 274 l  394 274 l  424 254 l  424 244 l gs col-1 s gr
  1487. X% Polyline
  1488. Xn 394 264 m 394 274 l gs col-1 s gr
  1489. X% Polyline
  1490. Xn 334 249 m 334 244 l  389 244 l  389 249 l  clp gs 0.75 setgray fill gr
  1491. Xgs col-1 s gr
  1492. X% Polyline
  1493. Xn 334 239 m 334 234 l  389 234 l  389 239 l  clp gs 0.75 setgray fill gr
  1494. Xgs col-1 s gr
  1495. X% Polyline
  1496. Xn 334 229 m 334 224 l  389 224 l  389 229 l  clp gs 0.75 setgray fill gr
  1497. Xgs col-1 s gr
  1498. X% Polyline
  1499. Xn 334 219 m 334 214 l  389 214 l  389 219 l  clp gs 0.75 setgray fill gr
  1500. Xgs col-1 s gr
  1501. X% Polyline
  1502. Xn 334 209 m 334 204 l  389 204 l  389 209 l  clp gs 0.75 setgray fill gr
  1503. Xgs col-1 s gr
  1504. X% Polyline
  1505. Xn 699 259 m 699 174 l  634 174 l  634 259 l  clp gs col-1 s gr
  1506. X% Polyline
  1507. Xn 699 174 m 714 164 l  714 249 l  699 259 l gs col-1 s gr
  1508. X% Polyline
  1509. Xn 634 174 m 649 164 l  714 164 l gs col-1 s gr
  1510. X% Polyline
  1511. Xn 714 244 m 729 244 l  699 264 l  619 264 l  634 254 l gs col-1 s gr
  1512. X% Polyline
  1513. Xn 619 264 m 619 274 l  699 274 l  729 254 l  729 244 l gs col-1 s gr
  1514. X% Polyline
  1515. Xn 699 264 m 699 274 l gs col-1 s gr
  1516. X% Polyline
  1517. Xn 639 249 m 639 244 l  694 244 l  694 249 l  clp gs 0.75 setgray fill gr
  1518. Xgs col-1 s gr
  1519. X% Polyline
  1520. Xn 639 239 m 639 234 l  694 234 l  694 239 l  clp gs 0.75 setgray fill gr
  1521. Xgs col-1 s gr
  1522. X% Polyline
  1523. Xn 639 229 m 639 224 l  694 224 l  694 229 l  clp gs 0.75 setgray fill gr
  1524. Xgs col-1 s gr
  1525. X% Polyline
  1526. Xn 639 219 m 639 214 l  694 214 l  694 219 l  clp gs 0.75 setgray fill gr
  1527. Xgs col-1 s gr
  1528. X% Polyline
  1529. Xn 639 209 m 639 204 l  694 204 l  694 209 l  clp gs 0.75 setgray fill gr
  1530. Xgs col-1 s gr
  1531. X% Polyline
  1532. Xn 261 204 m 254 204 254 237 7 arcto 4 {pop} repeat 254 244 297 244 7 arcto 4 {pop} repeat 304 244 304 211 7 arcto 4 {pop} repeat 304 204 261 204 7 arcto 4 {pop} repeat clp gs col-1 s gr
  1533. X% Polyline
  1534. Xn 309 249 m 309 199 l  249 199 l  249 249 l  clp gs col-1 s gr
  1535. X% Polyline
  1536. Xn 249 254 m 239 269 l  299 269 l  309 254 l  249 254 l gs col-1 s gr
  1537. X% Polyline
  1538. Xn 309 199 m 319 204 l  319 239 l  309 249 l gs col-1 s gr
  1539. X% Polyline
  1540. Xn 309 254 m 309 264 l  299 274 l  239 274 l  239 269 l gs col-1 s gr
  1541. X% Polyline
  1542. Xn 299 269 m 299 274 l gs col-1 s gr
  1543. X/Courier findfont 6.00 scalefont setfont
  1544. X259 214 m 
  1545. Xgs 1 -1 scale (csd &) col-1 show gr
  1546. X% Ellipse
  1547. Xn 356 114 32 32 0 360 DrawEllipse gs col-1 s gr
  1548. X% Ellipse
  1549. Xn 664 104 42 42 0 360 DrawEllipse gs col-1 s gr
  1550. X% Polyline
  1551. Xn 94 149 m 84 164 l  104 164 l  94 149 l gs col-1 s gr
  1552. X% Polyline
  1553. Xn 566 204 m 559 204 559 237 7 arcto 4 {pop} repeat 559 244 602 244 7 arcto 4 {pop} repeat 609 244 609 211 7 arcto 4 {pop} repeat 609 204 566 204 7 arcto 4 {pop} repeat clp gs col-1 s gr
  1554. X% Polyline
  1555. Xn 614 249 m 614 199 l  554 199 l  554 249 l  clp gs col-1 s gr
  1556. X% Polyline
  1557. Xn 554 254 m 544 269 l  604 269 l  614 254 l  554 254 l gs col-1 s gr
  1558. X% Polyline
  1559. Xn 614 199 m 624 204 l  624 239 l  614 249 l gs col-1 s gr
  1560. X% Polyline
  1561. Xn 614 254 m 614 264 l  604 274 l  544 274 l  544 269 l gs col-1 s gr
  1562. X% Polyline
  1563. Xn 604 269 m 604 274 l gs col-1 s gr
  1564. Xn 147.000 241.000 m 139.000 239.000 l 147.000 237.000 l gs 2 setlinejoin col-1 s gr
  1565. X% Polyline
  1566. Xn 139 239 m 239 239 l gs col-1 s gr
  1567. Xn 231.000 237.000 m 239.000 239.000 l 231.000 241.000 l gs 2 setlinejoin col-1 s gr
  1568. Xn 447.000 241.000 m 439.000 239.000 l 447.000 237.000 l gs 2 setlinejoin col-1 s gr
  1569. X% Polyline
  1570. Xn 439 239 m 539 239 l gs col-1 s gr
  1571. Xn 531.000 237.000 m 539.000 239.000 l 531.000 241.000 l gs 2 setlinejoin col-1 s gr
  1572. X% Polyline
  1573. Xn 359 149 m 369 169 l gs col-1 s gr
  1574. Xn 367.211 160.950 m 369.000 169.000 l 363.633 162.739 l gs 2 setlinejoin col-1 s gr
  1575. X% Polyline
  1576. Xn 664 149 m 674 169 l gs col-1 s gr
  1577. Xn 672.211 160.950 m 674.000 169.000 l 668.633 162.739 l gs 2 setlinejoin col-1 s gr
  1578. X% Polyline
  1579. Xn 349 124 m 339 139 l  359 139 l  349 124 l gs col-1 s gr
  1580. X% Polyline
  1581. Xn 654 124 m 644 139 l  664 139 l  654 124 l gs col-1 s gr
  1582. X% Polyline
  1583. Xn 671 104 m 664 104 664 112 7 arcto 4 {pop} repeat 664 119 677 119 7 arcto 4 {pop} repeat 684 119 684 111 7 arcto 4 {pop} repeat 684 104 671 104 7 arcto 4 {pop} repeat clp gs col-1 s gr
  1584. X% Polyline
  1585. Xn 669 94 m 673 80 l  663 70 l  649 74 l  645 88 l  655 98 l 
  1586. X clp gs col-1 s gr
  1587. X% Polyline
  1588. Xn 364 114 m 364 99 l  349 99 l  349 114 l  clp gs 0.50 setgray fill gr
  1589. Xgs col-1 s gr
  1590. X/Courier findfont 6.00 scalefont setfont
  1591. X564 214 m 
  1592. Xgs 1 -1 scale (cd /export) col-1 show gr
  1593. X/Times-Roman findfont 16.00 scalefont setfont
  1594. X174 234 m 
  1595. Xgs 1 -1 scale (NFS) col-1 show gr
  1596. X/Times-Roman findfont 16.00 scalefont setfont
  1597. X474 234 m 
  1598. Xgs 1 -1 scale (FTP) col-1 show gr
  1599. X/Helvetica-Bold findfont 16.00 scalefont setfont
  1600. X59 319 m 
  1601. Xgs 1 -1 scale (wwmount) col-1 show gr
  1602. X/Times-Roman findfont 16.00 scalefont setfont
  1603. X59 299 m 
  1604. Xgs 1 -1 scale (clients, with) col-1 show gr
  1605. X/Times-Roman findfont 16.00 scalefont setfont
  1606. X259 299 m 
  1607. Xgs 1 -1 scale (cluster server, running) col-1 show gr
  1608. X/Times-Roman findfont 16.00 scalefont setfont
  1609. X579 299 m 
  1610. Xgs 1 -1 scale (file servers, running) col-1 show gr
  1611. X/Helvetica-Bold findfont 16.00 scalefont setfont
  1612. X579 319 m 
  1613. Xgs 1 -1 scale (ftpd) col-1 show gr
  1614. X/Helvetica-Bold findfont 16.00 scalefont setfont
  1615. X259 319 m 
  1616. Xgs 1 -1 scale (csd) col-1 show gr
  1617. X$F2psEnd
  1618. END_OF_FILE
  1619.   if test 7624 -ne `wc -c <'doc/overview.eps'`; then
  1620.     echo shar: \"'doc/overview.eps'\" unpacked with wrong size!
  1621.   fi
  1622.   # end of 'doc/overview.eps'
  1623. fi
  1624. if test -f 'mosaic/ftplib.pl' -a "${1}" != "-c" ; then 
  1625.   echo shar: Will not clobber existing file \"'mosaic/ftplib.pl'\"
  1626. else
  1627.   echo shar: Extracting \"'mosaic/ftplib.pl'\" \(8343 characters\)
  1628.   sed "s/^X//" >'mosaic/ftplib.pl' <<'END_OF_FILE'
  1629. X#
  1630. X#   This is a set of ftp library routines using chat2.pl
  1631. X# 
  1632. X#   Return code information taken from RFC 959
  1633. X
  1634. X#   Written by Gene Spafford  <spaf@cs.purdue.edu>
  1635. X#       Last update: 10 April 92,   Version 0.9
  1636. X#
  1637. X
  1638. X#
  1639. X#   Most of these routines communicate over an open ftp channel
  1640. X#   The channel is opened with the "ftp'open" call.
  1641. X#
  1642. X
  1643. Xpackage ftp;
  1644. Xrequire "chat2.pl";
  1645. Xrequire "syscall.ph";
  1646. X
  1647. X
  1648. X###########################################################################
  1649. X#
  1650. X#  The following are the variables local to this package.
  1651. X#  I declare them all up front so I can remember what I called 'em. :-)
  1652. X#
  1653. X###########################################################################
  1654. X
  1655. XLOCAL_VARS: {    
  1656. X    $Control;
  1657. X    $Data_handle;
  1658. X    $Host;
  1659. X    $Myhost = "\0" x 65;
  1660. X    (syscall(&SYS_gethostname, $Myhost, 65) == 0) || 
  1661. X    die "Cannot 'gethostname' of local machine (in ftplib)\n";
  1662. X    $Myhost =~ s/\0*$//;
  1663. X    $NeedsCleanup;
  1664. X    $NeedsClose;
  1665. X    $ftp_error;
  1666. X    $ftp_matched;
  1667. X    $ftp_trans_flag;
  1668. X    @ftp_list;
  1669. X
  1670. X    local(@tmp) = getservbyname("ftp", "tcp");
  1671. X    ($FTP = $tmp[2]) || 
  1672. X    die "Unable to get service number for 'ftp' (in ftplib)!\n";
  1673. X
  1674. X    @std_actions = (
  1675. X        'TIMEOUT',
  1676. X        q($ftp_error = "Connection timed out for $Host!\n"; undef),
  1677. X        'EOF', 
  1678. X        q($ftp_error = "Connection to $Host timed out unexpectedly!\n"; undef)
  1679. X    );
  1680. X
  1681. X    @sigs = ('INT', 'HUP', 'TERM', 'QUIT');  # sigs we'll catch & terminate on
  1682. X}
  1683. X
  1684. X
  1685. X
  1686. X###########################################################################
  1687. X#
  1688. X#  The following are intended to be the user-callable routines.
  1689. X#  Each of these does one of the ftp keyword functions.
  1690. X#
  1691. X###########################################################################
  1692. X
  1693. Xsub error { ## Public
  1694. X    $ftp_error;
  1695. X}
  1696. X  
  1697. X#######################################################
  1698. X
  1699. X#   cd up a directory level
  1700. X
  1701. Xsub cdup { ## Public
  1702. X    &do_ftp_cmd(200, "cdup");
  1703. X}
  1704. X
  1705. X#######################################################
  1706. X
  1707. X# close an open ftp connection
  1708. X
  1709. Xsub close { ## Public
  1710. X    return unless $NeedsClose;
  1711. X    &do_ftp_cmd(221, "quit");
  1712. X    &chat'close($Control);
  1713. X    undef $NeedsClose;
  1714. X    &do_ftp_signals(0);
  1715. X}
  1716. X
  1717. X#######################################################
  1718. X
  1719. X# change remote directory
  1720. X
  1721. Xsub cwd { ## Public
  1722. X    &do_ftp_cmd(250, "cwd", @_);
  1723. X}
  1724. X  
  1725. X#######################################################
  1726. X
  1727. X#  delete a remote file
  1728. X
  1729. Xsub delete { ## Public
  1730. X     &do_ftp_cmd(250, "dele", @_); 
  1731. X}
  1732. X
  1733. X#######################################################
  1734. X
  1735. X#  get a directory listing of remote directory ("ls -l")
  1736. X
  1737. Xsub dir { ## Public
  1738. X    &do_ftp_listing("list", @_);
  1739. X}
  1740. X
  1741. X#######################################################
  1742. X
  1743. X#  get a remote file to a local file
  1744. X#    get(remote[, local])
  1745. X
  1746. Xsub get { ## Public
  1747. X    local($remote, $local) = @_;
  1748. X    ($local = $remote) unless $local;
  1749. X
  1750. X    unless (open(DFILE, ">$local")) {
  1751. X    $ftp_error =  "Open of local file $local failed: $!";
  1752. X    return undef;
  1753. X    } else {
  1754. X    $NeedsCleanup = $local;
  1755. X    }
  1756. X
  1757. X    return undef unless &do_open_dport;     # Open a data channel
  1758. X    unless (&do_ftp_cmd(150, "retr $remote")) {
  1759. X    $ftp_error .= "\nFile $remote not fetched from $Host\n";
  1760. X    close DFILE;
  1761. X    unlink $local;
  1762. X    undef $NeedsCleanup;
  1763. X    return;
  1764. X    }
  1765. X
  1766. X    $ftp_trans_flag = 0;
  1767. X
  1768. X    do {
  1769. X    &chat'expect($Data_handle, 60,
  1770. X             '.|\n', q{print DFILE ($chat'thisbuf) ||
  1771. X            ($ftp_trans_flag = 3); undef $chat'S},
  1772. X             'EOF',  '$ftp_trans_flag = 1',
  1773. X             'TIMEOUT', '$ftp_trans_flag = 2');
  1774. X    } until $ftp_trans_flag;
  1775. X
  1776. X    close DFILE;
  1777. X    &chat'close($Data_handle);        # Close the data channel
  1778. X
  1779. X    undef $NeedsCleanup;
  1780. X    if ($ftp_trans_flag > 1) {
  1781. X    unlink $local;
  1782. X    $ftp_error = "Unexpected " . ($ftp_trans_flag == 2 ? "timeout" :
  1783. X        ($ftp_trans_flag != 3 ? "failure" : "local write failure")) .
  1784. X                " getting $remote\n";
  1785. X    }
  1786. X    
  1787. X    &do_ftp_cmd(226);
  1788. X}
  1789. X
  1790. X#######################################################
  1791. X
  1792. X#  Do a simple name list ("ls")
  1793. X
  1794. Xsub list { ## Public
  1795. X    &do_ftp_listing("nlst", @_);
  1796. X}
  1797. X
  1798. X#######################################################
  1799. X
  1800. X#   Make a remote directory
  1801. X
  1802. Xsub mkdir { ## Public
  1803. X    &do_ftp_cmd(257, "mkd", @_);
  1804. X}
  1805. X
  1806. X#######################################################
  1807. X
  1808. X#  Open an ftp connection to remote host
  1809. X
  1810. Xsub open {  ## Public
  1811. X    if ($NeedsClose) {
  1812. X    $ftp_error = "Connection still open to $Host!";
  1813. X    return undef;
  1814. X    }
  1815. X
  1816. X    $Host = shift(@_);
  1817. X    local($User, $Password, $Acct) = @_;
  1818. X    $User = "anonymous" unless $User;
  1819. X    $Password = "-" . $main'ENV{'USER'} . "@$Myhost" unless $Password;
  1820. X    $ftp_error = '';
  1821. X
  1822. X    unless($Control = &chat'open_port($Host, $FTP)) {
  1823. X    $ftp_error = "Unable to connect to $Host ftp port: $!";
  1824. X    return undef;
  1825. X    }
  1826. X
  1827. X    unless(&chat'expect($Control, 60,
  1828. X                "^220 .*\n",     "1",
  1829. X                "^\d\d\d .*\n",  "undef")) {
  1830. X    $ftp_error = "Error establishing control connection to $Host";
  1831. X        &chat'close($Control);
  1832. X    return undef;
  1833. X    }
  1834. X    &do_ftp_signals($NeedsClose = 1);
  1835. X
  1836. X    unless (&do_ftp_cmd(331, "user $User")) {
  1837. X    $ftp_error .= "\nUser command failed establishing connection to $Host";
  1838. X    return undef;
  1839. X    }
  1840. X
  1841. X    unless (&do_ftp_cmd("(230|332|202)", "pass $Password")) {
  1842. X    $ftp_error .= "\nPassword command failed establishing connection to $Host";
  1843. X    return undef;
  1844. X    }
  1845. X
  1846. X    return 1 unless $Acct;
  1847. X
  1848. X    unless (&do_ftp_cmd("(230|202)", "pass $Password")) {
  1849. X    $ftp_error .= "\nAcct command failed establishing connection to $Host";
  1850. X    return undef;
  1851. X    }
  1852. X    1;
  1853. X}
  1854. X
  1855. X#######################################################
  1856. X
  1857. X#  Get name of current remote directory
  1858. X
  1859. Xsub pwd { ## Public
  1860. X    if (&do_ftp_cmd(257, "pwd")) {
  1861. X    $ftp_matched =~ m/^257 (.+)\r?\n/;
  1862. X    $1;
  1863. X    } else {
  1864. X    undef;
  1865. X    }    
  1866. X}
  1867. X
  1868. X#######################################################
  1869. X
  1870. X#  Rename a remote file
  1871. X
  1872. Xsub rename { ## Public
  1873. X    local($from, $to) = @_;
  1874. X
  1875. X    &do_ftp_cmd(350, "rnfr $from") && &do_ftp_cmd(250, "rnto $to");
  1876. X}
  1877. X
  1878. X#######################################################
  1879. X
  1880. X#  Set transfer type
  1881. X
  1882. Xsub type { ## Public
  1883. X    &do_ftp_cmd(200, "type", @_); 
  1884. X}
  1885. X
  1886. X
  1887. X###########################################################################
  1888. X#
  1889. X#  The following are intended to be utility routines used only locally.
  1890. X#  Users should not call these directly.
  1891. X#
  1892. X###########################################################################
  1893. X
  1894. Xsub do_ftp_cmd {  ## Private
  1895. X    local($okay, @commands, $val) = @_;
  1896. X
  1897. X    $commands[0] && 
  1898. X    &chat'print($Control, join(" ", @commands), "\r\n");
  1899. X
  1900. X    &chat'expect($Control, 60, 
  1901. X         "^$okay .*\\n",        '$ftp_matched = $&; 1',
  1902. X         '^(\d)\d\d .*\\n', '($String = $&) =~ y/\r\n//d; 
  1903. X             $ftp_error = qq{Unexpected reply for ' .
  1904. X             "@commands" . ': $String}; 
  1905. X             $1 > 3 ? undef : 1',
  1906. X         @std_actions
  1907. X        );
  1908. X}
  1909. X
  1910. X#######################################################
  1911. X
  1912. Xsub do_ftp_listing { ## Private
  1913. X    local(@lcmd) = @_;
  1914. X    @ftp_list = ();
  1915. X    $ftp_trans_flag = 0;
  1916. X
  1917. X    return undef unless &do_open_dport;
  1918. X
  1919. X    return undef unless &do_ftp_cmd(150, @lcmd);
  1920. X    do {            #  Following is grotty, but chat2 makes us do it
  1921. X        &chat'expect($Data_handle, 30,
  1922. X        "(.*)\r?\n",    'push(@ftp_list, $1)',
  1923. X        "EOF",     '$ftp_trans_flag = 1');
  1924. X    } until $ftp_trans_flag;
  1925. X
  1926. X    &chat'close($Data_handle);
  1927. X    return undef unless &do_ftp_cmd(226);
  1928. X
  1929. X    grep(y/\r\n//d, @ftp_list);
  1930. X    @ftp_list;
  1931. X}  
  1932. X
  1933. X#######################################################
  1934. X
  1935. Xsub do_open_dport { ## Private
  1936. X    local(@foo, $port) = &chat'open_listen;
  1937. X    ($port, $Data_handle) = splice(@foo, 4, 2);
  1938. X
  1939. X    unless ($Data_handle) {
  1940. X    $ftp_error =  "Unable to open data port: $!";
  1941. X    return undef;
  1942. X    }
  1943. X
  1944. X    push(@foo, $port >> 8, $port & 0xff);
  1945. X    local($myhost) = (join(',', @foo));
  1946. X    
  1947. X    &do_ftp_cmd(200, "port $myhost");
  1948. X}
  1949. X
  1950. X#######################################################
  1951. X#
  1952. X#  To cleanup after a problem
  1953. X#
  1954. X
  1955. Xsub do_ftp_abort {
  1956. X    die unless $NeedsClose;
  1957. X
  1958. X    &chat'print($Control, "abor", "\r\n");
  1959. X    &chat'close($Data_handle);
  1960. X    &chat'expect($Control, 10, '.', undef);
  1961. X    &chat'close($Control);
  1962. X
  1963. X    close DFILE;
  1964. X    unlink($NeedsCleanup) if $NeedsCleanup;
  1965. X    die;
  1966. X}
  1967. X
  1968. X#######################################################
  1969. X#
  1970. X#  To set signals to do the abort properly
  1971. X#
  1972. X
  1973. Xsub do_ftp_signals {
  1974. X    local($flag, $sig) = @_;
  1975. X
  1976. X    local ($old, $new) = ('DEFAULT', "ftp'do_ftp_abort");
  1977. X    $flag || (($old, $new) = ($new, $old));
  1978. X    foreach $sig (@sigs) {
  1979. X    ($SIG{$sig} == $old) && ($SIG{$sig} = $new);
  1980. X    }
  1981. X}
  1982. X
  1983. X1;
  1984. END_OF_FILE
  1985.   if test 8343 -ne `wc -c <'mosaic/ftplib.pl'`; then
  1986.     echo shar: \"'mosaic/ftplib.pl'\" unpacked with wrong size!
  1987.   fi
  1988.   # end of 'mosaic/ftplib.pl'
  1989. fi
  1990. if test -f 'mosaic/gget.pl' -a "${1}" != "-c" ; then 
  1991.   echo shar: Will not clobber existing file \"'mosaic/gget.pl'\"
  1992. else
  1993.   echo shar: Extracting \"'mosaic/gget.pl'\" \(8269 characters\)
  1994.   sed "s/^X//" >'mosaic/gget.pl' <<'END_OF_FILE'
  1995. X#!/usr/local/bin/perl
  1996. X#
  1997. X# gget               --- recursively get files starting at a given URL
  1998. X#
  1999. X# Given a starting URL, gget will recursively retrieve gopher files.
  2000. X# It will also generate "gget.log" -- a table of titles and hosts.
  2001. X# Tries to find as many new hosts as possible, and strictly
  2002. X# limits the number of pages it will request from any one server.
  2003. X#
  2004. X# gget will stop when $maxtotal pages are retrieved (1000!),
  2005. X# or when the all pages were retrieved,
  2006. X# or when SIGINT is received (^C).
  2007. X#
  2008. X# NB: to get all pages recursively, try:
  2009. X#       gget -ls <home-page>
  2010. X#
  2011. X# Author: Youki Kadobayashi <youki@wide.ad.jp>
  2012. X# derived from "explore" written by: Oscar Nierstrasz oscar@cui.unige.ch
  2013. X# This file is part of WWFS.
  2014. X#
  2015. X#v = '(v1.0)'; # August 30, 1993
  2016. X#v = '(v1.1)'; # August 31 -- added triggering of xmosaic
  2017. X#v = '(v1.2)'; # Sept 1 -- added various options; SIGINT handling
  2018. X#v = '(v1.3)'; # Oct 21 -- fixed counting of hosts; added -d
  2019. X#v = '(v1.4)'; # Oct 23 -- fixed sigint to allow <CR> to continue
  2020. X#                #       -- fixed printing of $hostsig
  2021. X$v = '(v1.0)'; # Nov 14, 1993 -- gget initial revision
  2022. X
  2023. Xrequire '/etc/csd.pl';
  2024. Xunshift(@INC, "$WWFSDIR/lib");
  2025. Xrequire 'url.pl';
  2026. Xrequire 'dirutil.pl';
  2027. X
  2028. X$usg = 'Usage: gget [<options>] <gopher-url>
  2029. X    <gopher-url>      -- URL to start with (no default)
  2030. X    <output file>   -- default is gget.log
  2031. X    -m <maxpages>   -- max pages to get per site (default 5)
  2032. X    -t <maxtotal>   -- max total pages to get (default 100)
  2033. X    -h <maxhosts>   -- max hosts to explore (default unlimited)
  2034. X    -s <savedir>    -- directory to save pages to (default current)
  2035. X    -ls             -- list all pages at starting site (use with care!)
  2036. X';
  2037. X$maxpages = 5;          # max pages to retrieve per site
  2038. X$maxtotal = 100;        # max pages to retrieve in total
  2039. X$maxhosts = undef;      # max hosts to visit
  2040. X
  2041. X$hosts = 1;             # hosts visited (always at least 1)
  2042. X
  2043. Xchop($date = `date +%d.%m.%y`);
  2044. X$sig = "This page was generated by gget $v on $date.\n";
  2045. X
  2046. X# A good default starting point:
  2047. X# $whatsnew = "http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/Docs/whats-new.html";
  2048. X# $start = "http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/StartingPoints/NetworkStartingPoints.html";
  2049. X
  2050. X# default log file:
  2051. X$deflog = "gget.log";
  2052. X
  2053. X# default save directory:
  2054. X$savedir = ".";
  2055. X
  2056. Xwhile ($#ARGV >= $[) {
  2057. X    $arg = shift @ARGV;
  2058. X
  2059. X    if ($arg eq "-m") {
  2060. X        $arg = shift @ARGV;
  2061. X        if ($arg =~ /^\d+$/){
  2062. X            print STDERR "maxpages = $arg (was $maxpages)\n";
  2063. X            $maxpages = $arg;
  2064. X            next;
  2065. X        }
  2066. X        else { die "Bad arg for -m\n$usg"; }
  2067. X    }
  2068. X
  2069. X    if ($arg eq "-t") {
  2070. X        $arg = shift @ARGV;
  2071. X        if ($arg =~ /^\d+$/){
  2072. X            print STDERR "maxtotal = $arg (was $maxtotal)\n";
  2073. X            $maxtotal = $arg;
  2074. X            next;
  2075. X        }
  2076. X        else { die "Bad arg for -t\n$usg"; }
  2077. X    }
  2078. X
  2079. X    if ($arg eq "-h") {
  2080. X        $arg = shift @ARGV;
  2081. X        if ($arg =~ /^\d+$/){
  2082. X            print STDERR "maxhosts = $arg (was $maxhosts)\n";
  2083. X            $maxhosts = $arg;
  2084. X            next;
  2085. X        }
  2086. X        else { die "Bad arg for -h\n$usg"; }
  2087. X    }
  2088. X
  2089. X    if ($arg eq "-s") {
  2090. X        $arg = shift @ARGV;
  2091. X        if (-d $arg) {
  2092. X            print STDERR "directory = $arg (was $savedir)\n";
  2093. X            $savedir = $arg;
  2094. X            next;
  2095. X        }
  2096. X        else { die "Bad arg for -s\n$usg"; }
  2097. X    }
  2098. X
  2099. X    if ($arg eq "-ls") {
  2100. X        $maxhosts = 1;
  2101. X        $maxtotal = $maxpages = 1000;
  2102. X        next;
  2103. X    }
  2104. X
  2105. X    if ($arg eq "-h") { die "$usg"; }
  2106. X    if ($arg =~ /^-/) { die "Invalid flag\n$usg"; }
  2107. X    if ($arg =~ /^gopher:/) {
  2108. X        if ($start) { die "Please give only one URL\n$usg"; }
  2109. X        $start = $arg;
  2110. X    }
  2111. X    else {
  2112. X        if ($log) { die "Please give only one output file\n$usg"; }
  2113. X        $log = $arg;
  2114. X    }
  2115. X}
  2116. X
  2117. Xunless ($start) { die "$usg"; }
  2118. Xunless ($log) { $log = $deflog; }
  2119. X(open(STDOUT,">$log")) || die "Can't create $log\n";
  2120. X$| = 1;
  2121. Xprint STDERR "Writing output to $log\n";
  2122. X&explore($start);
  2123. X
  2124. X# Explore the gopherspace, starting at $url.
  2125. X# Maintains a list @tocheck of URLs to try.
  2126. Xsub explore {
  2127. X    local($url) = @_;
  2128. X    if ($maxhosts == 1) {
  2129. X        print "Log of gopher transfer from $url\n$sig\n";
  2130. X    }
  2131. X    else {
  2132. X        print "Log of gopher transfer starting at $url\n";
  2133. X        if ($maxhosts) {
  2134. X            print "Maximum hosts to visit = $maxhosts.\n";
  2135. X        }
  2136. X        print "Max pages per site = $maxpages.\n",
  2137. X            "Max total pages = $maxtotal.\n$sig\n";
  2138. X    }
  2139. X
  2140. X    $SIG{'INT'} = 'sigint'; # Stop when SIGINT is received
  2141. X    push(@tocheck,$url);    # Initialize
  2142. X    $seen{$url} = 1;        # Remember that we've seen it
  2143. X    ($thistype,$thishost, $thisport, $thispath, $request) =
  2144. X        &url'parse(undef,undef,undef,undef,$url);
  2145. X    $seenhost{$thishost} = 1;
  2146. X
  2147. X    while ($#tocheck >= $[) {
  2148. X        $url = shift @tocheck;
  2149. X        # Remember current host, port and path:
  2150. X        ($thistype,$thishost, $thisport, $thispath, $request) =
  2151. X            &url'parse(undef,undef,undef,undef,$url);
  2152. X        print STDERR "Requesting $url\n";
  2153. X        unless ($page = &url'get($url)) {
  2154. X            print "Can't get $url\n";
  2155. X            next;
  2156. X        } ;
  2157. X
  2158. X        # Extract the title and detect errors
  2159. X        if ($page =~ /^0Server Error:/) {
  2160. X            print "Invalid page: $url\n";
  2161. X            next;
  2162. X        }
  2163. X
  2164. X        # Save URL and gopher output
  2165. X        &save_url($savedir . $request, $url);
  2166. X        if ($thispath =~ m:^/1/: || $thispath =~ m:^/$:) {
  2167. X            &savefile("/tmp/gget$$", $page);
  2168. X        } else {
  2169. X            &savefile($savedir . $request, $page);
  2170. X            next;
  2171. X        }
  2172. X
  2173. X        # Attempt to convert the gopher listing to an HTML
  2174. X        open(G, "/tmp/gget$$");
  2175. X        $html = "Select one of:<P>\n<UL>";
  2176. X        while (<G>) {
  2177. X            chop; chop;        # strip CRLF
  2178. X            ($host, $port, $path, $type, $title)
  2179. X               = &parse_gopher($_);
  2180. X            $href = "gopher://$host:$port/$path";
  2181. X            $html .= "<LI> <A HREF=\"$href\">$title</A>\n";
  2182. X
  2183. X            # Skip this host if invalid:
  2184. X            unless ($host) { next; }
  2185. X            # Skip if seen already:
  2186. X            if ($seen{$href}) { next; }
  2187. X            $seen{$href} = 1;
  2188. X            # Don't ask too many pages from a given host:
  2189. X            unless (++$count{$host} <= $maxpages) { next; }
  2190. X            if ($seenhost{$host}) {
  2191. X                # Seen this host, so add to end of queue:
  2192. X                print STDERR "Pushing $href\n";
  2193. X                push(@tocheck,$href);
  2194. X            }
  2195. X            else {
  2196. X                if ($maxhosts) {
  2197. X                    if (++$hosts > $maxhosts) { next; }
  2198. X                }
  2199. X                # New host, so add to front:
  2200. X                print STDERR "Queueing $href\n";
  2201. X                unshift(@tocheck,$href);
  2202. X                $seenhost{$host} = 1;
  2203. X            }
  2204. X        }
  2205. X        close(G);
  2206. X        $html .= "</UL>\n";
  2207. X        &savefile($savedir . $request . "/", $html);
  2208. X
  2209. X        if (!($maxhosts == 1)) { $hostsig = " ($thishost)"; }
  2210. X        # This page is ok, so log it:
  2211. X        print "$title$hostsig\n";
  2212. X        # from the last request
  2213. X        if (++$entries >= $maxtotal) { last; }
  2214. X    }
  2215. X
  2216. X    print "\nSearch completed.\n";
  2217. X    close(STDOUT);
  2218. X    print STDERR "Result of exploration in $log\n";
  2219. X}
  2220. X
  2221. Xsub parse_gopher {
  2222. X    local ($entry) = @_;
  2223. X    local ($type, $title, $path, $host, $port);
  2224. X
  2225. X    ($title, $path, $host, $port) = split("\t", $entry);
  2226. X    ($type, $title) = unpack("a1 a*", $title);
  2227. X#    print "$entry => $host, $port, $path, $type, $title\n";
  2228. X    return ($host, $port, $path, $type, $title);
  2229. X}
  2230. X
  2231. Xsub save_url {
  2232. X    # keep url-to-file mapping information
  2233. X    local ($path, $url) = @_;
  2234. X    local ($dir, $file);
  2235. X
  2236. X    ($dir, $file) = &basename($path);
  2237. X    ($url, $file) = &basename($url);
  2238. X    if (! -e "$dir/.url") {
  2239. X        open(URL, ">$dir/.url");
  2240. X        print URL "$url\n";
  2241. X        close(URL);
  2242. X    }
  2243. X}
  2244. X
  2245. Xsub savefile {
  2246. X    local ($path, $page) = @_;
  2247. X    local ($dir, $file);
  2248. X
  2249. X    ($dir, $file) = &basename($path);
  2250. X    # make directories if necessary, and write the page
  2251. X    if (! -d $dir) {
  2252. X        if (&mkdirhier($dir)) {
  2253. X            print "mkdir $dir\n";
  2254. X        } else {
  2255. X            print "Error in creating $dir: $!\n";
  2256. X        }
  2257. X    }
  2258. X    if ($path =~ m:/$:) {
  2259. X        # gopherd may have mapped directory to a page,
  2260. X        # e.g, "/" -> "/foo/Welcome.html".
  2261. X        # as a workaround, we save it under some name
  2262. X        # unlikely to conflict.
  2263. X        $path .= "urlget_dir.html";
  2264. X    }
  2265. X    if (open(FILE, ">$path")) {
  2266. X        print FILE $page;
  2267. X        close(FILE);
  2268. X        print "got $path: ";
  2269. X    } else {
  2270. X        print "Error in creating $path: $!: ";
  2271. X    }
  2272. X}
  2273. X
  2274. Xsub sigint {
  2275. X    local ($/) = "\n";
  2276. X    local ($res);
  2277. X    print STDERR "Enter <CR> to continue, \"q\" to quit\n";
  2278. X    chop ($res = <STDIN>);
  2279. X    return if ($res eq "");
  2280. X    if ($res ne "q") {
  2281. X        print STDERR "Invalid response -- continuing\n";
  2282. X        return;
  2283. X    }
  2284. X    print STDERR "Quitting\n";
  2285. X    # should dump @tocheck in a file?
  2286. X    print "\n\nInterrupted!\n";
  2287. X    close(STDOUT);
  2288. X    print STDERR "Result of exploration in $log\n";
  2289. X    exit(0);
  2290. X}
  2291. X
  2292. X# return a list of all the hrefs in a page
  2293. Xsub hrefs {
  2294. X    local($page) = @_;
  2295. X    $page =~ s/^[^<]+</</;
  2296. X    $page =~ s/>[^<]*</></g;
  2297. X    $page =~ s/<a[^>]*href\s*=\s*"([^"]+)"[^>]*>/$1\n/gi;
  2298. X    $page =~ s/<[^>]*>//g;
  2299. X    $page =~ s/\n+/\n/g;
  2300. X    split(/\n/,$page);
  2301. X}
  2302. X
  2303. X# Local Variables:
  2304. X# mode: cperl
  2305. X# cperl-indent-level: 8
  2306. X# cperl-continued-statement-offset: 8
  2307. X# End:
  2308. END_OF_FILE
  2309.   if test 8269 -ne `wc -c <'mosaic/gget.pl'`; then
  2310.     echo shar: \"'mosaic/gget.pl'\" unpacked with wrong size!
  2311.   fi
  2312.   # end of 'mosaic/gget.pl'
  2313. fi
  2314. if test -f 'rpc/cs_prot_xdr.c' -a "${1}" != "-c" ; then 
  2315.   echo shar: Will not clobber existing file \"'rpc/cs_prot_xdr.c'\"
  2316. else
  2317.   echo shar: Extracting \"'rpc/cs_prot_xdr.c'\" \(8068 characters\)
  2318.   sed "s/^X//" >'rpc/cs_prot_xdr.c' <<'END_OF_FILE'
  2319. X/*
  2320. X * Please do not edit this file.
  2321. X * It was generated using rpcgen.
  2322. X */
  2323. X
  2324. X#include <rpc/rpc.h>
  2325. X#include "cs_prot.h"
  2326. X
  2327. Xbool_t
  2328. Xxdr_cs_stat(xdrs, objp)
  2329. X    XDR *xdrs;
  2330. X    cs_stat *objp;
  2331. X{
  2332. X    if (!xdr_enum(xdrs, (enum_t *)objp)) {
  2333. X        return (FALSE);
  2334. X    }
  2335. X    return (TRUE);
  2336. X}
  2337. X
  2338. Xbool_t
  2339. Xxdr_cs_fhres(xdrs, objp)
  2340. X    XDR *xdrs;
  2341. X    cs_fhres *objp;
  2342. X{
  2343. X    if (!xdr_cs_stat(xdrs, &objp->status)) {
  2344. X        return (FALSE);
  2345. X    }
  2346. X    switch (objp->status) {
  2347. X    case CS_OK:
  2348. X        if (!xdr_nfs_fh(xdrs, &objp->cs_fhres_u.file)) {
  2349. X            return (FALSE);
  2350. X        }
  2351. X        break;
  2352. X    default:
  2353. X        if (!xdr_long(xdrs, &objp->cs_fhres_u.err_context)) {
  2354. X            return (FALSE);
  2355. X        }
  2356. X        break;
  2357. X    }
  2358. X    return (TRUE);
  2359. X}
  2360. X
  2361. Xbool_t
  2362. Xxdr_cs_res(xdrs, objp)
  2363. X    XDR *xdrs;
  2364. X    cs_res *objp;
  2365. X{
  2366. X    if (!xdr_cs_stat(xdrs, &objp->status)) {
  2367. X        return (FALSE);
  2368. X    }
  2369. X    switch (objp->status) {
  2370. X    case CS_OK:
  2371. X        break;
  2372. X    default:
  2373. X        if (!xdr_long(xdrs, &objp->cs_res_u.err_context)) {
  2374. X            return (FALSE);
  2375. X        }
  2376. X        break;
  2377. X    }
  2378. X    return (TRUE);
  2379. X}
  2380. X
  2381. Xbool_t
  2382. Xxdr_volname(xdrs, objp)
  2383. X    XDR *xdrs;
  2384. X    volname *objp;
  2385. X{
  2386. X    if (!xdr_string(xdrs, objp, CS_MAXNAMLEN)) {
  2387. X        return (FALSE);
  2388. X    }
  2389. X    return (TRUE);
  2390. X}
  2391. X
  2392. Xbool_t
  2393. Xxdr_cs_volargs(xdrs, objp)
  2394. X    XDR *xdrs;
  2395. X    cs_volargs *objp;
  2396. X{
  2397. X    if (!xdr_volname(xdrs, &objp->vol)) {
  2398. X        return (FALSE);
  2399. X    }
  2400. X    return (TRUE);
  2401. X}
  2402. X
  2403. Xbool_t
  2404. Xxdr_cs_volokres(xdrs, objp)
  2405. X    XDR *xdrs;
  2406. X    cs_volokres *objp;
  2407. X{
  2408. X    if (!xdr_long(xdrs, &objp->volume_id)) {
  2409. X        return (FALSE);
  2410. X    }
  2411. X    if (!xdr_long(xdrs, &objp->bytes_to_server)) {
  2412. X        return (FALSE);
  2413. X    }
  2414. X    if (!xdr_long(xdrs, &objp->bytes_from_server)) {
  2415. X        return (FALSE);
  2416. X    }
  2417. X    if (!xdr_long(xdrs, &objp->bytes_to_client)) {
  2418. X        return (FALSE);
  2419. X    }
  2420. X    if (!xdr_long(xdrs, &objp->bytes_from_client)) {
  2421. X        return (FALSE);
  2422. X    }
  2423. X    if (!xdr_long(xdrs, &objp->n_request_readdir)) {
  2424. X        return (FALSE);
  2425. X    }
  2426. X    if (!xdr_long(xdrs, &objp->n_request_lookup)) {
  2427. X        return (FALSE);
  2428. X    }
  2429. X    if (!xdr_long(xdrs, &objp->n_request_read)) {
  2430. X        return (FALSE);
  2431. X    }
  2432. X    if (!xdr_long(xdrs, &objp->n_request_readdir_miss)) {
  2433. X        return (FALSE);
  2434. X    }
  2435. X    if (!xdr_long(xdrs, &objp->n_request_lookup_miss)) {
  2436. X        return (FALSE);
  2437. X    }
  2438. X    if (!xdr_long(xdrs, &objp->n_request_read_miss)) {
  2439. X        return (FALSE);
  2440. X    }
  2441. X    return (TRUE);
  2442. X}
  2443. X
  2444. Xbool_t
  2445. Xxdr_cs_volres(xdrs, objp)
  2446. X    XDR *xdrs;
  2447. X    cs_volres *objp;
  2448. X{
  2449. X    if (!xdr_cs_stat(xdrs, &objp->status)) {
  2450. X        return (FALSE);
  2451. X    }
  2452. X    switch (objp->status) {
  2453. X    case CS_OK:
  2454. X        if (!xdr_cs_volokres(xdrs, &objp->cs_volres_u.volok)) {
  2455. X            return (FALSE);
  2456. X        }
  2457. X        break;
  2458. X    default:
  2459. X        if (!xdr_long(xdrs, &objp->cs_volres_u.err_context)) {
  2460. X            return (FALSE);
  2461. X        }
  2462. X        break;
  2463. X    }
  2464. X    return (TRUE);
  2465. X}
  2466. X
  2467. Xbool_t
  2468. Xxdr_cs_xferent(xdrs, objp)
  2469. X    XDR *xdrs;
  2470. X    cs_xferent *objp;
  2471. X{
  2472. X    if (!xdr_int(xdrs, &objp->status)) {
  2473. X        return (FALSE);
  2474. X    }
  2475. X    if (!xdr_int(xdrs, &objp->uid)) {
  2476. X        return (FALSE);
  2477. X    }
  2478. X    if (!xdr_int(xdrs, &objp->gid)) {
  2479. X        return (FALSE);
  2480. X    }
  2481. X    if (!xdr_long(xdrs, &objp->ip_address)) {
  2482. X        return (FALSE);
  2483. X    }
  2484. X    if (!xdr_long(xdrs, &objp->bytes)) {
  2485. X        return (FALSE);
  2486. X    }
  2487. X    if (!xdr_int(xdrs, &objp->idle)) {
  2488. X        return (FALSE);
  2489. X    }
  2490. X    if (!xdr_array(xdrs, (char **)&objp->server.server_val, (u_int *)&objp->server.server_len, CS_MAXHOSTLEN, sizeof(char), xdr_char)) {
  2491. X        return (FALSE);
  2492. X    }
  2493. X    return (TRUE);
  2494. X}
  2495. X
  2496. Xbool_t
  2497. Xxdr_cs_xferres(xdrs, objp)
  2498. X    XDR *xdrs;
  2499. X    cs_xferres *objp;
  2500. X{
  2501. X    if (!xdr_cs_stat(xdrs, &objp->status)) {
  2502. X        return (FALSE);
  2503. X    }
  2504. X    switch (objp->status) {
  2505. X    case CS_OK:
  2506. X        if (!xdr_cs_xferent(xdrs, &objp->cs_xferres_u.xfer)) {
  2507. X            return (FALSE);
  2508. X        }
  2509. X        break;
  2510. X    default:
  2511. X        if (!xdr_long(xdrs, &objp->cs_xferres_u.err_context)) {
  2512. X            return (FALSE);
  2513. X        }
  2514. X        break;
  2515. X    }
  2516. X    return (TRUE);
  2517. X}
  2518. X
  2519. Xbool_t
  2520. Xxdr_cs_udaargs(xdrs, objp)
  2521. X    XDR *xdrs;
  2522. X    cs_udaargs *objp;
  2523. X{
  2524. X    if (!xdr_nfs_fh(xdrs, &objp->file)) {
  2525. X        return (FALSE);
  2526. X    }
  2527. X    if (!xdr_string(xdrs, &objp->attrname, CS_MAXNAMLEN)) {
  2528. X        return (FALSE);
  2529. X    }
  2530. X    return (TRUE);
  2531. X}
  2532. X
  2533. Xbool_t
  2534. Xxdr_cs_udares(xdrs, objp)
  2535. X    XDR *xdrs;
  2536. X    cs_udares *objp;
  2537. X{
  2538. X    if (!xdr_cs_stat(xdrs, &objp->status)) {
  2539. X        return (FALSE);
  2540. X    }
  2541. X    switch (objp->status) {
  2542. X    case CS_OK:
  2543. X        if (!xdr_array(xdrs, (char **)&objp->cs_udares_u.attr.attr_val, (u_int *)&objp->cs_udares_u.attr.attr_len, CS_MAXDATA, sizeof(char), xdr_char)) {
  2544. X            return (FALSE);
  2545. X        }
  2546. X        break;
  2547. X    default:
  2548. X        if (!xdr_long(xdrs, &objp->cs_udares_u.err_context)) {
  2549. X            return (FALSE);
  2550. X        }
  2551. X        break;
  2552. X    }
  2553. X    return (TRUE);
  2554. X}
  2555. X
  2556. Xbool_t
  2557. Xxdr_cs_diropargs(xdrs, objp)
  2558. X    XDR *xdrs;
  2559. X    cs_diropargs *objp;
  2560. X{
  2561. X    if (!xdr_nfspath(xdrs, &objp->pname)) {
  2562. X        return (FALSE);
  2563. X    }
  2564. X    if (!xdr_filename(xdrs, &objp->fname)) {
  2565. X        return (FALSE);
  2566. X    }
  2567. X    return (TRUE);
  2568. X}
  2569. X
  2570. Xbool_t
  2571. Xxdr_cs_diropokres(xdrs, objp)
  2572. X    XDR *xdrs;
  2573. X    cs_diropokres *objp;
  2574. X{
  2575. X    if (!xdr_nfs_fh(xdrs, &objp->file)) {
  2576. X        return (FALSE);
  2577. X    }
  2578. X    if (!xdr_fattr(xdrs, &objp->attr)) {
  2579. X        return (FALSE);
  2580. X    }
  2581. X    return (TRUE);
  2582. X}
  2583. X
  2584. Xbool_t
  2585. Xxdr_cs_diropres(xdrs, objp)
  2586. X    XDR *xdrs;
  2587. X    cs_diropres *objp;
  2588. X{
  2589. X    if (!xdr_cs_stat(xdrs, &objp->status)) {
  2590. X        return (FALSE);
  2591. X    }
  2592. X    switch (objp->status) {
  2593. X    case CS_OK:
  2594. X        if (!xdr_cs_diropokres(xdrs, &objp->cs_diropres_u.diropok)) {
  2595. X            return (FALSE);
  2596. X        }
  2597. X        break;
  2598. X    default:
  2599. X        if (!xdr_long(xdrs, &objp->cs_diropres_u.err_context)) {
  2600. X            return (FALSE);
  2601. X        }
  2602. X        break;
  2603. X    }
  2604. X    return (TRUE);
  2605. X}
  2606. X
  2607. Xbool_t
  2608. Xxdr_cs_readdirargs(xdrs, objp)
  2609. X    XDR *xdrs;
  2610. X    cs_readdirargs *objp;
  2611. X{
  2612. X    if (!xdr_nfs_fh(xdrs, &objp->dir)) {
  2613. X        return (FALSE);
  2614. X    }
  2615. X    if (!xdr_long(xdrs, &objp->cookie)) {
  2616. X        return (FALSE);
  2617. X    }
  2618. X    if (!xdr_u_int(xdrs, &objp->count)) {
  2619. X        return (FALSE);
  2620. X    }
  2621. X    return (TRUE);
  2622. X}
  2623. X
  2624. Xbool_t
  2625. Xxdr_cs_dirent(xdrs, objp)
  2626. X    XDR *xdrs;
  2627. X    cs_dirent *objp;
  2628. X{
  2629. X    if (!xdr_u_int(xdrs, &objp->fileid)) {
  2630. X        return (FALSE);
  2631. X    }
  2632. X    if (!xdr_filename(xdrs, &objp->name)) {
  2633. X        return (FALSE);
  2634. X    }
  2635. X    if (!xdr_fattr(xdrs, &objp->attr)) {
  2636. X        return (FALSE);
  2637. X    }
  2638. X    if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof(cs_dirent), xdr_cs_dirent)) {
  2639. X        return (FALSE);
  2640. X    }
  2641. X    return (TRUE);
  2642. X}
  2643. X
  2644. Xbool_t
  2645. Xxdr_cs_readdirokres(xdrs, objp)
  2646. X    XDR *xdrs;
  2647. X    cs_readdirokres *objp;
  2648. X{
  2649. X    if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof(cs_dirent), xdr_cs_dirent)) {
  2650. X        return (FALSE);
  2651. X    }
  2652. X    if (!xdr_bool(xdrs, &objp->eof)) {
  2653. X        return (FALSE);
  2654. X    }
  2655. X    return (TRUE);
  2656. X}
  2657. X
  2658. Xbool_t
  2659. Xxdr_cs_readdirres(xdrs, objp)
  2660. X    XDR *xdrs;
  2661. X    cs_readdirres *objp;
  2662. X{
  2663. X    if (!xdr_cs_stat(xdrs, &objp->status)) {
  2664. X        return (FALSE);
  2665. X    }
  2666. X    switch (objp->status) {
  2667. X    case CS_OK:
  2668. X        if (!xdr_cs_readdirokres(xdrs, &objp->cs_readdirres_u.readdirok)) {
  2669. X            return (FALSE);
  2670. X        }
  2671. X        break;
  2672. X    default:
  2673. X        if (!xdr_long(xdrs, &objp->cs_readdirres_u.err_context)) {
  2674. X            return (FALSE);
  2675. X        }
  2676. X        break;
  2677. X    }
  2678. X    return (TRUE);
  2679. X}
  2680. X
  2681. Xbool_t
  2682. Xxdr_cs_readargs(xdrs, objp)
  2683. X    XDR *xdrs;
  2684. X    cs_readargs *objp;
  2685. X{
  2686. X    if (!xdr_nfs_fh(xdrs, &objp->file)) {
  2687. X        return (FALSE);
  2688. X    }
  2689. X    if (!xdr_u_int(xdrs, &objp->offset)) {
  2690. X        return (FALSE);
  2691. X    }
  2692. X    if (!xdr_u_int(xdrs, &objp->count)) {
  2693. X        return (FALSE);
  2694. X    }
  2695. X    if (!xdr_u_int(xdrs, &objp->totalcount)) {
  2696. X        return (FALSE);
  2697. X    }
  2698. X    if (!xdr_bool(xdrs, &objp->prefer_bulk)) {
  2699. X        return (FALSE);
  2700. X    }
  2701. X    return (TRUE);
  2702. X}
  2703. X
  2704. Xbool_t
  2705. Xxdr_cs_readokres(xdrs, objp)
  2706. X    XDR *xdrs;
  2707. X    cs_readokres *objp;
  2708. X{
  2709. X    if (!xdr_fattr(xdrs, &objp->attr)) {
  2710. X        return (FALSE);
  2711. X    }
  2712. X    if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, CS_MAXDATA)) {
  2713. X        return (FALSE);
  2714. X    }
  2715. X    return (TRUE);
  2716. X}
  2717. X
  2718. Xbool_t
  2719. Xxdr_cs_readbulkres(xdrs, objp)
  2720. X    XDR *xdrs;
  2721. X    cs_readbulkres *objp;
  2722. X{
  2723. X    if (!xdr_fattr(xdrs, &objp->attr)) {
  2724. X        return (FALSE);
  2725. X    }
  2726. X    if (!xdr_long(xdrs, &objp->sin_port)) {
  2727. X        return (FALSE);
  2728. X    }
  2729. X    return (TRUE);
  2730. X}
  2731. X
  2732. Xbool_t
  2733. Xxdr_cs_readres(xdrs, objp)
  2734. X    XDR *xdrs;
  2735. X    cs_readres *objp;
  2736. X{
  2737. X    if (!xdr_cs_stat(xdrs, &objp->status)) {
  2738. X        return (FALSE);
  2739. X    }
  2740. X    switch (objp->status) {
  2741. X    case CS_OK:
  2742. X        if (!xdr_cs_readokres(xdrs, &objp->cs_readres_u.readok)) {
  2743. X            return (FALSE);
  2744. X        }
  2745. X        break;
  2746. X    case CS_BULK:
  2747. X        if (!xdr_cs_readbulkres(xdrs, &objp->cs_readres_u.readbulk)) {
  2748. X            return (FALSE);
  2749. X        }
  2750. X        break;
  2751. X    default:
  2752. X        if (!xdr_long(xdrs, &objp->cs_readres_u.err_context)) {
  2753. X            return (FALSE);
  2754. X        }
  2755. X        break;
  2756. X    }
  2757. X    return (TRUE);
  2758. X}
  2759. X
  2760. Xbool_t
  2761. Xxdr_cs_geterrargs(xdrs, objp)
  2762. X    XDR *xdrs;
  2763. X    cs_geterrargs *objp;
  2764. X{
  2765. X    if (!xdr_long(xdrs, &objp->err_context)) {
  2766. X        return (FALSE);
  2767. X    }
  2768. X    return (TRUE);
  2769. X}
  2770. X
  2771. Xbool_t
  2772. Xxdr_cs_geterrres(xdrs, objp)
  2773. X    XDR *xdrs;
  2774. X    cs_geterrres *objp;
  2775. X{
  2776. X    if (!xdr_cs_stat(xdrs, &objp->status)) {
  2777. X        return (FALSE);
  2778. X    }
  2779. X    switch (objp->status) {
  2780. X    case CS_OK:
  2781. X        if (!xdr_string(xdrs, &objp->cs_geterrres_u.err_string, CS_MAXNAMLEN)) {
  2782. X            return (FALSE);
  2783. X        }
  2784. X        break;
  2785. X    }
  2786. X    return (TRUE);
  2787. X}
  2788. END_OF_FILE
  2789.   if test 8068 -ne `wc -c <'rpc/cs_prot_xdr.c'`; then
  2790.     echo shar: \"'rpc/cs_prot_xdr.c'\" unpacked with wrong size!
  2791.   fi
  2792.   # end of 'rpc/cs_prot_xdr.c'
  2793. fi
  2794. if test -f 'rpc/nfs_prot.x' -a "${1}" != "-c" ; then 
  2795.   echo shar: Will not clobber existing file \"'rpc/nfs_prot.x'\"
  2796. else
  2797.   echo shar: Extracting \"'rpc/nfs_prot.x'\" \(7830 characters\)
  2798.   sed "s/^X//" >'rpc/nfs_prot.x' <<'END_OF_FILE'
  2799. X/* @(#)nfs_prot.x    1.2 87/11/12 3.9 RPCSRC */
  2800. X
  2801. X/*
  2802. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  2803. X * unrestricted use provided that this legend is included on all tape
  2804. X * media and as a part of the software program in whole or part.  Users
  2805. X * may copy or modify Sun RPC without charge, but are not authorized
  2806. X * to license or distribute it to anyone else except as part of a product or
  2807. X * program developed by the user.
  2808. X * 
  2809. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  2810. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  2811. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  2812. X * 
  2813. X * Sun RPC is provided with no support and without any obligation on the
  2814. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  2815. X * modification or enhancement.
  2816. X * 
  2817. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  2818. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  2819. X * OR ANY PART THEREOF.
  2820. X * 
  2821. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  2822. X * or profits or other special, indirect and consequential damages, even if
  2823. X * Sun has been advised of the possibility of such damages.
  2824. X * 
  2825. X * Sun Microsystems, Inc.
  2826. X * 2550 Garcia Avenue
  2827. X * Mountain View, California  94043
  2828. X */
  2829. X
  2830. X/*
  2831. X * nfs_prot.x 1.2 87/10/12
  2832. X * Copyright 1987 Sun Microsystems, Inc.
  2833. X */
  2834. Xconst NFS_PORT          = 2049;
  2835. Xconst NFS_MAXDATA       = 8192;
  2836. Xconst NFS_MAXPATHLEN    = 1024;
  2837. Xconst NFS_MAXNAMLEN    = 255;
  2838. Xconst NFS_FHSIZE    = 32;
  2839. Xconst NFS_COOKIESIZE    = 4;
  2840. Xconst NFS_FIFO_DEV    = -1;    /* size kludge for named pipes */
  2841. X
  2842. X/*
  2843. X * File types
  2844. X */
  2845. Xconst NFSMODE_FMT  = 0170000;    /* type of file */
  2846. Xconst NFSMODE_DIR  = 0040000;    /* directory */
  2847. Xconst NFSMODE_CHR  = 0020000;    /* character special */
  2848. Xconst NFSMODE_BLK  = 0060000;    /* block special */
  2849. Xconst NFSMODE_REG  = 0100000;    /* regular */
  2850. Xconst NFSMODE_LNK  = 0120000;    /* symbolic link */
  2851. Xconst NFSMODE_SOCK = 0140000;    /* socket */
  2852. Xconst NFSMODE_FIFO = 0010000;    /* fifo */
  2853. X
  2854. X/*
  2855. X * Error status
  2856. X */
  2857. Xenum nfsstat {
  2858. X    NFS_OK= 0,        /* no error */
  2859. X    NFSERR_PERM=1,        /* Not owner */
  2860. X    NFSERR_NOENT=2,        /* No such file or directory */
  2861. X    NFSERR_IO=5,        /* I/O error */
  2862. X    NFSERR_NXIO=6,        /* No such device or address */
  2863. X    NFSERR_ACCES=13,    /* Permission denied */
  2864. X    NFSERR_EXIST=17,    /* File exists */
  2865. X    NFSERR_NODEV=19,    /* No such device */
  2866. X    NFSERR_NOTDIR=20,    /* Not a directory*/
  2867. X    NFSERR_ISDIR=21,    /* Is a directory */
  2868. X    NFSERR_FBIG=27,        /* File too large */
  2869. X    NFSERR_NOSPC=28,    /* No space left on device */
  2870. X    NFSERR_ROFS=30,        /* Read-only file system */
  2871. X    NFSERR_NAMETOOLONG=63,    /* File name too long */
  2872. X    NFSERR_NOTEMPTY=66,    /* Directory not empty */
  2873. X    NFSERR_DQUOT=69,    /* Disc quota exceeded */
  2874. X    NFSERR_STALE=70,    /* Stale NFS file handle */
  2875. X    NFSERR_WFLUSH=99    /* write cache flushed */
  2876. X};
  2877. X
  2878. X/*
  2879. X * File types
  2880. X */
  2881. Xenum ftype {
  2882. X    NFNON = 0,    /* non-file */
  2883. X    NFREG = 1,    /* regular file */
  2884. X    NFDIR = 2,    /* directory */
  2885. X    NFBLK = 3,    /* block special */
  2886. X    NFCHR = 4,    /* character special */
  2887. X    NFLNK = 5,    /* symbolic link */
  2888. X    NFSOCK = 6,    /* unix domain sockets */
  2889. X    NFBAD = 7,    /* unused */
  2890. X    NFFIFO = 8     /* named pipe */
  2891. X};
  2892. X
  2893. X#ifndef RPC_XDR
  2894. X%#ifndef NFS_FH_DEFINED    /* nfs_fh has been declared in cs_prot.h */
  2895. X#endif
  2896. X/*
  2897. X * File access handle
  2898. X */
  2899. Xstruct nfs_fh {
  2900. X    opaque data[NFS_FHSIZE];
  2901. X};
  2902. X#ifndef RPC_XDR
  2903. X%#define NFS_FH_DEFINED
  2904. X%#endif
  2905. X#endif
  2906. X
  2907. X/* 
  2908. X * Timeval
  2909. X */
  2910. Xstruct nfstime {
  2911. X    unsigned seconds;
  2912. X    unsigned useconds;
  2913. X};
  2914. X
  2915. X
  2916. X/*
  2917. X * File attributes
  2918. X */
  2919. Xstruct fattr {
  2920. X    ftype type;        /* file type */
  2921. X    unsigned mode;        /* protection mode bits */
  2922. X    unsigned nlink;        /* # hard links */
  2923. X    unsigned uid;        /* owner user id */
  2924. X    unsigned gid;        /* owner group id */
  2925. X    unsigned size;        /* file size in bytes */
  2926. X    unsigned blocksize;    /* prefered block size */
  2927. X    unsigned rdev;        /* special device # */
  2928. X    unsigned blocks;    /* Kb of disk used by file */
  2929. X    unsigned fsid;        /* device # */
  2930. X    unsigned fileid;    /* inode # */
  2931. X    nfstime    atime;        /* time of last access */
  2932. X    nfstime    mtime;        /* time of last modification */
  2933. X    nfstime    ctime;        /* time of last change */
  2934. X};
  2935. X
  2936. X/*
  2937. X * File attributes which can be set
  2938. X */
  2939. Xstruct sattr {
  2940. X    unsigned mode;    /* protection mode bits */
  2941. X    unsigned uid;    /* owner user id */
  2942. X    unsigned gid;    /* owner group id */
  2943. X    unsigned size;    /* file size in bytes */
  2944. X    nfstime    atime;    /* time of last access */
  2945. X    nfstime    mtime;    /* time of last modification */
  2946. X};
  2947. X
  2948. X
  2949. Xtypedef string filename<NFS_MAXNAMLEN>; 
  2950. Xtypedef string nfspath<NFS_MAXPATHLEN>;
  2951. X
  2952. X/*
  2953. X * Reply status with file attributes
  2954. X */
  2955. Xunion attrstat switch (nfsstat status) {
  2956. Xcase NFS_OK:
  2957. X    fattr attributes;
  2958. Xdefault:
  2959. X    void;
  2960. X};
  2961. X
  2962. Xstruct sattrargs {
  2963. X    nfs_fh file;
  2964. X    sattr attributes;
  2965. X};
  2966. X
  2967. X/*
  2968. X * Arguments for directory operations
  2969. X */
  2970. Xstruct diropargs {
  2971. X    nfs_fh    dir;    /* directory file handle */
  2972. X    filename name;        /* name (up to NFS_MAXNAMLEN bytes) */
  2973. X};
  2974. X
  2975. Xstruct diropokres {
  2976. X    nfs_fh file;
  2977. X    fattr attributes;
  2978. X};
  2979. X
  2980. X/*
  2981. X * Results from directory operation
  2982. X */
  2983. Xunion diropres switch (nfsstat status) {
  2984. Xcase NFS_OK:
  2985. X    diropokres diropres;
  2986. Xdefault:
  2987. X    void;
  2988. X};
  2989. X
  2990. Xunion readlinkres switch (nfsstat status) {
  2991. Xcase NFS_OK:
  2992. X    nfspath data;
  2993. Xdefault:
  2994. X    void;
  2995. X};
  2996. X
  2997. X/*
  2998. X * Arguments to remote read
  2999. X */
  3000. Xstruct readargs {
  3001. X    nfs_fh file;        /* handle for file */
  3002. X    unsigned offset;    /* byte offset in file */
  3003. X    unsigned count;        /* immediate read count */
  3004. X    unsigned totalcount;    /* total read count (from this offset)*/
  3005. X};
  3006. X
  3007. X/*
  3008. X * Status OK portion of remote read reply
  3009. X */
  3010. Xstruct readokres {
  3011. X    fattr    attributes;    /* attributes, need for pagin*/
  3012. X    opaque data<NFS_MAXDATA>;
  3013. X};
  3014. X
  3015. Xunion readres switch (nfsstat status) {
  3016. Xcase NFS_OK:
  3017. X    readokres reply;
  3018. Xdefault:
  3019. X    void;
  3020. X};
  3021. X
  3022. X/*
  3023. X * Arguments to remote write 
  3024. X */
  3025. Xstruct writeargs {
  3026. X    nfs_fh    file;        /* handle for file */
  3027. X    unsigned beginoffset;    /* beginning byte offset in file */
  3028. X    unsigned offset;    /* current byte offset in file */
  3029. X    unsigned totalcount;    /* total write count (to this offset)*/
  3030. X    opaque data<NFS_MAXDATA>;
  3031. X};
  3032. X
  3033. Xstruct createargs {
  3034. X    diropargs where;
  3035. X    sattr attributes;
  3036. X};
  3037. X
  3038. Xstruct renameargs {
  3039. X    diropargs from;
  3040. X    diropargs to;
  3041. X};
  3042. X
  3043. Xstruct linkargs {
  3044. X    nfs_fh from;
  3045. X    diropargs to;
  3046. X};
  3047. X
  3048. Xstruct symlinkargs {
  3049. X    diropargs from;
  3050. X    nfspath to;
  3051. X    sattr attributes;
  3052. X};
  3053. X
  3054. X
  3055. Xtypedef opaque nfscookie[NFS_COOKIESIZE];
  3056. X
  3057. X/*
  3058. X * Arguments to readdir
  3059. X */
  3060. Xstruct readdirargs {
  3061. X    nfs_fh dir;        /* directory handle */
  3062. X    nfscookie cookie;
  3063. X    unsigned count;        /* number of directory bytes to read */
  3064. X};
  3065. X
  3066. Xstruct entry {
  3067. X    unsigned fileid;
  3068. X    filename name;
  3069. X    nfscookie cookie;
  3070. X    entry *nextentry;
  3071. X};
  3072. X
  3073. Xstruct dirlist {
  3074. X    entry *entries;
  3075. X    bool eof;
  3076. X};
  3077. X
  3078. Xunion readdirres switch (nfsstat status) {
  3079. Xcase NFS_OK:
  3080. X    dirlist reply;
  3081. Xdefault:
  3082. X    void;
  3083. X};
  3084. X
  3085. Xstruct statfsokres {
  3086. X    unsigned tsize;    /* preferred transfer size in bytes */
  3087. X    unsigned bsize;    /* fundamental file system block size */
  3088. X    unsigned blocks;    /* total blocks in file system */
  3089. X    unsigned bfree;    /* free blocks in fs */
  3090. X    unsigned bavail;    /* free blocks avail to non-superuser */
  3091. X};
  3092. X
  3093. Xunion statfsres switch (nfsstat status) {
  3094. Xcase NFS_OK:
  3095. X    statfsokres reply;
  3096. Xdefault:
  3097. X    void;
  3098. X};
  3099. X
  3100. X/*
  3101. X * Remote file service routines
  3102. X */
  3103. Xprogram NFS_PROGRAM {
  3104. X    version NFS_VERSION {
  3105. X        void 
  3106. X        NFSPROC_NULL(void) = 0;
  3107. X
  3108. X        attrstat 
  3109. X        NFSPROC_GETATTR(nfs_fh) =    1;
  3110. X
  3111. X        attrstat 
  3112. X        NFSPROC_SETATTR(sattrargs) = 2;
  3113. X
  3114. X        void 
  3115. X        NFSPROC_ROOT(void) = 3;
  3116. X
  3117. X        diropres 
  3118. X        NFSPROC_LOOKUP(diropargs) = 4;
  3119. X
  3120. X        readlinkres 
  3121. X        NFSPROC_READLINK(nfs_fh) = 5;
  3122. X
  3123. X        readres 
  3124. X        NFSPROC_READ(readargs) = 6;
  3125. X
  3126. X        void 
  3127. X        NFSPROC_WRITECACHE(void) = 7;
  3128. X
  3129. X        attrstat
  3130. X        NFSPROC_WRITE(writeargs) = 8;
  3131. X
  3132. X        diropres
  3133. X        NFSPROC_CREATE(createargs) = 9;
  3134. X
  3135. X        nfsstat
  3136. X        NFSPROC_REMOVE(diropargs) = 10;
  3137. X
  3138. X        nfsstat
  3139. X        NFSPROC_RENAME(renameargs) = 11;
  3140. X
  3141. X        nfsstat
  3142. X        NFSPROC_LINK(linkargs) = 12;
  3143. X
  3144. X        nfsstat
  3145. X        NFSPROC_SYMLINK(symlinkargs) = 13;
  3146. X
  3147. X        diropres
  3148. X        NFSPROC_MKDIR(createargs) = 14;
  3149. X
  3150. X        nfsstat
  3151. X        NFSPROC_RMDIR(diropargs) = 15;
  3152. X
  3153. X        readdirres
  3154. X        NFSPROC_READDIR(readdirargs) = 16;
  3155. X
  3156. X        statfsres
  3157. X        NFSPROC_STATFS(nfs_fh) = 17;
  3158. X    } = 2;
  3159. X} = 100003;
  3160. X
  3161. END_OF_FILE
  3162.   if test 7830 -ne `wc -c <'rpc/nfs_prot.x'`; then
  3163.     echo shar: \"'rpc/nfs_prot.x'\" unpacked with wrong size!
  3164.   fi
  3165.   # end of 'rpc/nfs_prot.x'
  3166. fi
  3167. if test -f 'rpc/nfs_prot_xdr.c' -a "${1}" != "-c" ; then 
  3168.   echo shar: Will not clobber existing file \"'rpc/nfs_prot_xdr.c'\"
  3169. else
  3170.   echo shar: Extracting \"'rpc/nfs_prot_xdr.c'\" \(8059 characters\)
  3171.   sed "s/^X//" >'rpc/nfs_prot_xdr.c' <<'END_OF_FILE'
  3172. X/*
  3173. X * Please do not edit this file.
  3174. X * It was generated using rpcgen.
  3175. X */
  3176. X
  3177. X#include <rpc/rpc.h>
  3178. X#include "nfs_prot.h"
  3179. X
  3180. Xbool_t
  3181. Xxdr_nfsstat(xdrs, objp)
  3182. X    XDR *xdrs;
  3183. X    nfsstat *objp;
  3184. X{
  3185. X    if (!xdr_enum(xdrs, (enum_t *)objp)) {
  3186. X        return (FALSE);
  3187. X    }
  3188. X    return (TRUE);
  3189. X}
  3190. X
  3191. Xbool_t
  3192. Xxdr_ftype(xdrs, objp)
  3193. X    XDR *xdrs;
  3194. X    ftype *objp;
  3195. X{
  3196. X    if (!xdr_enum(xdrs, (enum_t *)objp)) {
  3197. X        return (FALSE);
  3198. X    }
  3199. X    return (TRUE);
  3200. X}
  3201. X
  3202. Xbool_t
  3203. Xxdr_nfs_fh(xdrs, objp)
  3204. X    XDR *xdrs;
  3205. X    nfs_fh *objp;
  3206. X{
  3207. X    if (!xdr_opaque(xdrs, objp->data, NFS_FHSIZE)) {
  3208. X        return (FALSE);
  3209. X    }
  3210. X    return (TRUE);
  3211. X}
  3212. X
  3213. Xbool_t
  3214. Xxdr_nfstime(xdrs, objp)
  3215. X    XDR *xdrs;
  3216. X    nfstime *objp;
  3217. X{
  3218. X    if (!xdr_u_int(xdrs, &objp->seconds)) {
  3219. X        return (FALSE);
  3220. X    }
  3221. X    if (!xdr_u_int(xdrs, &objp->useconds)) {
  3222. X        return (FALSE);
  3223. X    }
  3224. X    return (TRUE);
  3225. X}
  3226. X
  3227. Xbool_t
  3228. Xxdr_fattr(xdrs, objp)
  3229. X    XDR *xdrs;
  3230. X    fattr *objp;
  3231. X{
  3232. X    if (!xdr_ftype(xdrs, &objp->type)) {
  3233. X        return (FALSE);
  3234. X    }
  3235. X    if (!xdr_u_int(xdrs, &objp->mode)) {
  3236. X        return (FALSE);
  3237. X    }
  3238. X    if (!xdr_u_int(xdrs, &objp->nlink)) {
  3239. X        return (FALSE);
  3240. X    }
  3241. X    if (!xdr_u_int(xdrs, &objp->uid)) {
  3242. X        return (FALSE);
  3243. X    }
  3244. X    if (!xdr_u_int(xdrs, &objp->gid)) {
  3245. X        return (FALSE);
  3246. X    }
  3247. X    if (!xdr_u_int(xdrs, &objp->size)) {
  3248. X        return (FALSE);
  3249. X    }
  3250. X    if (!xdr_u_int(xdrs, &objp->blocksize)) {
  3251. X        return (FALSE);
  3252. X    }
  3253. X    if (!xdr_u_int(xdrs, &objp->rdev)) {
  3254. X        return (FALSE);
  3255. X    }
  3256. X    if (!xdr_u_int(xdrs, &objp->blocks)) {
  3257. X        return (FALSE);
  3258. X    }
  3259. X    if (!xdr_u_int(xdrs, &objp->fsid)) {
  3260. X        return (FALSE);
  3261. X    }
  3262. X    if (!xdr_u_int(xdrs, &objp->fileid)) {
  3263. X        return (FALSE);
  3264. X    }
  3265. X    if (!xdr_nfstime(xdrs, &objp->atime)) {
  3266. X        return (FALSE);
  3267. X    }
  3268. X    if (!xdr_nfstime(xdrs, &objp->mtime)) {
  3269. X        return (FALSE);
  3270. X    }
  3271. X    if (!xdr_nfstime(xdrs, &objp->ctime)) {
  3272. X        return (FALSE);
  3273. X    }
  3274. X    return (TRUE);
  3275. X}
  3276. X
  3277. Xbool_t
  3278. Xxdr_sattr(xdrs, objp)
  3279. X    XDR *xdrs;
  3280. X    sattr *objp;
  3281. X{
  3282. X    if (!xdr_u_int(xdrs, &objp->mode)) {
  3283. X        return (FALSE);
  3284. X    }
  3285. X    if (!xdr_u_int(xdrs, &objp->uid)) {
  3286. X        return (FALSE);
  3287. X    }
  3288. X    if (!xdr_u_int(xdrs, &objp->gid)) {
  3289. X        return (FALSE);
  3290. X    }
  3291. X    if (!xdr_u_int(xdrs, &objp->size)) {
  3292. X        return (FALSE);
  3293. X    }
  3294. X    if (!xdr_nfstime(xdrs, &objp->atime)) {
  3295. X        return (FALSE);
  3296. X    }
  3297. X    if (!xdr_nfstime(xdrs, &objp->mtime)) {
  3298. X        return (FALSE);
  3299. X    }
  3300. X    return (TRUE);
  3301. X}
  3302. X
  3303. Xbool_t
  3304. Xxdr_filename(xdrs, objp)
  3305. X    XDR *xdrs;
  3306. X    filename *objp;
  3307. X{
  3308. X    if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) {
  3309. X        return (FALSE);
  3310. X    }
  3311. X    return (TRUE);
  3312. X}
  3313. X
  3314. Xbool_t
  3315. Xxdr_nfspath(xdrs, objp)
  3316. X    XDR *xdrs;
  3317. X    nfspath *objp;
  3318. X{
  3319. X    if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) {
  3320. X        return (FALSE);
  3321. X    }
  3322. X    return (TRUE);
  3323. X}
  3324. X
  3325. Xbool_t
  3326. Xxdr_attrstat(xdrs, objp)
  3327. X    XDR *xdrs;
  3328. X    attrstat *objp;
  3329. X{
  3330. X    if (!xdr_nfsstat(xdrs, &objp->status)) {
  3331. X        return (FALSE);
  3332. X    }
  3333. X    switch (objp->status) {
  3334. X    case NFS_OK:
  3335. X        if (!xdr_fattr(xdrs, &objp->attrstat_u.attributes)) {
  3336. X            return (FALSE);
  3337. X        }
  3338. X        break;
  3339. X    }
  3340. X    return (TRUE);
  3341. X}
  3342. X
  3343. Xbool_t
  3344. Xxdr_sattrargs(xdrs, objp)
  3345. X    XDR *xdrs;
  3346. X    sattrargs *objp;
  3347. X{
  3348. X    if (!xdr_nfs_fh(xdrs, &objp->file)) {
  3349. X        return (FALSE);
  3350. X    }
  3351. X    if (!xdr_sattr(xdrs, &objp->attributes)) {
  3352. X        return (FALSE);
  3353. X    }
  3354. X    return (TRUE);
  3355. X}
  3356. X
  3357. Xbool_t
  3358. Xxdr_diropargs(xdrs, objp)
  3359. X    XDR *xdrs;
  3360. X    diropargs *objp;
  3361. X{
  3362. X    if (!xdr_nfs_fh(xdrs, &objp->dir)) {
  3363. X        return (FALSE);
  3364. X    }
  3365. X    if (!xdr_filename(xdrs, &objp->name)) {
  3366. X        return (FALSE);
  3367. X    }
  3368. X    return (TRUE);
  3369. X}
  3370. X
  3371. Xbool_t
  3372. Xxdr_diropokres(xdrs, objp)
  3373. X    XDR *xdrs;
  3374. X    diropokres *objp;
  3375. X{
  3376. X    if (!xdr_nfs_fh(xdrs, &objp->file)) {
  3377. X        return (FALSE);
  3378. X    }
  3379. X    if (!xdr_fattr(xdrs, &objp->attributes)) {
  3380. X        return (FALSE);
  3381. X    }
  3382. X    return (TRUE);
  3383. X}
  3384. X
  3385. Xbool_t
  3386. Xxdr_diropres(xdrs, objp)
  3387. X    XDR *xdrs;
  3388. X    diropres *objp;
  3389. X{
  3390. X    if (!xdr_nfsstat(xdrs, &objp->status)) {
  3391. X        return (FALSE);
  3392. X    }
  3393. X    switch (objp->status) {
  3394. X    case NFS_OK:
  3395. X        if (!xdr_diropokres(xdrs, &objp->diropres_u.diropres)) {
  3396. X            return (FALSE);
  3397. X        }
  3398. X        break;
  3399. X    }
  3400. X    return (TRUE);
  3401. X}
  3402. X
  3403. Xbool_t
  3404. Xxdr_readlinkres(xdrs, objp)
  3405. X    XDR *xdrs;
  3406. X    readlinkres *objp;
  3407. X{
  3408. X    if (!xdr_nfsstat(xdrs, &objp->status)) {
  3409. X        return (FALSE);
  3410. X    }
  3411. X    switch (objp->status) {
  3412. X    case NFS_OK:
  3413. X        if (!xdr_nfspath(xdrs, &objp->readlinkres_u.data)) {
  3414. X            return (FALSE);
  3415. X        }
  3416. X        break;
  3417. X    }
  3418. X    return (TRUE);
  3419. X}
  3420. X
  3421. Xbool_t
  3422. Xxdr_readargs(xdrs, objp)
  3423. X    XDR *xdrs;
  3424. X    readargs *objp;
  3425. X{
  3426. X    if (!xdr_nfs_fh(xdrs, &objp->file)) {
  3427. X        return (FALSE);
  3428. X    }
  3429. X    if (!xdr_u_int(xdrs, &objp->offset)) {
  3430. X        return (FALSE);
  3431. X    }
  3432. X    if (!xdr_u_int(xdrs, &objp->count)) {
  3433. X        return (FALSE);
  3434. X    }
  3435. X    if (!xdr_u_int(xdrs, &objp->totalcount)) {
  3436. X        return (FALSE);
  3437. X    }
  3438. X    return (TRUE);
  3439. X}
  3440. X
  3441. Xbool_t
  3442. Xxdr_readokres(xdrs, objp)
  3443. X    XDR *xdrs;
  3444. X    readokres *objp;
  3445. X{
  3446. X    if (!xdr_fattr(xdrs, &objp->attributes)) {
  3447. X        return (FALSE);
  3448. X    }
  3449. X    if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) {
  3450. X        return (FALSE);
  3451. X    }
  3452. X    return (TRUE);
  3453. X}
  3454. X
  3455. Xbool_t
  3456. Xxdr_readres(xdrs, objp)
  3457. X    XDR *xdrs;
  3458. X    readres *objp;
  3459. X{
  3460. X    if (!xdr_nfsstat(xdrs, &objp->status)) {
  3461. X        return (FALSE);
  3462. X    }
  3463. X    switch (objp->status) {
  3464. X    case NFS_OK:
  3465. X        if (!xdr_readokres(xdrs, &objp->readres_u.reply)) {
  3466. X            return (FALSE);
  3467. X        }
  3468. X        break;
  3469. X    }
  3470. X    return (TRUE);
  3471. X}
  3472. X
  3473. Xbool_t
  3474. Xxdr_writeargs(xdrs, objp)
  3475. X    XDR *xdrs;
  3476. X    writeargs *objp;
  3477. X{
  3478. X    if (!xdr_nfs_fh(xdrs, &objp->file)) {
  3479. X        return (FALSE);
  3480. X    }
  3481. X    if (!xdr_u_int(xdrs, &objp->beginoffset)) {
  3482. X        return (FALSE);
  3483. X    }
  3484. X    if (!xdr_u_int(xdrs, &objp->offset)) {
  3485. X        return (FALSE);
  3486. X    }
  3487. X    if (!xdr_u_int(xdrs, &objp->totalcount)) {
  3488. X        return (FALSE);
  3489. X    }
  3490. X    if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) {
  3491. X        return (FALSE);
  3492. X    }
  3493. X    return (TRUE);
  3494. X}
  3495. X
  3496. Xbool_t
  3497. Xxdr_createargs(xdrs, objp)
  3498. X    XDR *xdrs;
  3499. X    createargs *objp;
  3500. X{
  3501. X    if (!xdr_diropargs(xdrs, &objp->where)) {
  3502. X        return (FALSE);
  3503. X    }
  3504. X    if (!xdr_sattr(xdrs, &objp->attributes)) {
  3505. X        return (FALSE);
  3506. X    }
  3507. X    return (TRUE);
  3508. X}
  3509. X
  3510. Xbool_t
  3511. Xxdr_renameargs(xdrs, objp)
  3512. X    XDR *xdrs;
  3513. X    renameargs *objp;
  3514. X{
  3515. X    if (!xdr_diropargs(xdrs, &objp->from)) {
  3516. X        return (FALSE);
  3517. X    }
  3518. X    if (!xdr_diropargs(xdrs, &objp->to)) {
  3519. X        return (FALSE);
  3520. X    }
  3521. X    return (TRUE);
  3522. X}
  3523. X
  3524. Xbool_t
  3525. Xxdr_linkargs(xdrs, objp)
  3526. X    XDR *xdrs;
  3527. X    linkargs *objp;
  3528. X{
  3529. X    if (!xdr_nfs_fh(xdrs, &objp->from)) {
  3530. X        return (FALSE);
  3531. X    }
  3532. X    if (!xdr_diropargs(xdrs, &objp->to)) {
  3533. X        return (FALSE);
  3534. X    }
  3535. X    return (TRUE);
  3536. X}
  3537. X
  3538. Xbool_t
  3539. Xxdr_symlinkargs(xdrs, objp)
  3540. X    XDR *xdrs;
  3541. X    symlinkargs *objp;
  3542. X{
  3543. X    if (!xdr_diropargs(xdrs, &objp->from)) {
  3544. X        return (FALSE);
  3545. X    }
  3546. X    if (!xdr_nfspath(xdrs, &objp->to)) {
  3547. X        return (FALSE);
  3548. X    }
  3549. X    if (!xdr_sattr(xdrs, &objp->attributes)) {
  3550. X        return (FALSE);
  3551. X    }
  3552. X    return (TRUE);
  3553. X}
  3554. X
  3555. Xbool_t
  3556. Xxdr_nfscookie(xdrs, objp)
  3557. X    XDR *xdrs;
  3558. X    nfscookie objp;
  3559. X{
  3560. X    if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) {
  3561. X        return (FALSE);
  3562. X    }
  3563. X    return (TRUE);
  3564. X}
  3565. X
  3566. Xbool_t
  3567. Xxdr_readdirargs(xdrs, objp)
  3568. X    XDR *xdrs;
  3569. X    readdirargs *objp;
  3570. X{
  3571. X    if (!xdr_nfs_fh(xdrs, &objp->dir)) {
  3572. X        return (FALSE);
  3573. X    }
  3574. X    if (!xdr_nfscookie(xdrs, objp->cookie)) {
  3575. X        return (FALSE);
  3576. X    }
  3577. X    if (!xdr_u_int(xdrs, &objp->count)) {
  3578. X        return (FALSE);
  3579. X    }
  3580. X    return (TRUE);
  3581. X}
  3582. X
  3583. Xbool_t
  3584. Xxdr_entry(xdrs, objp)
  3585. X    XDR *xdrs;
  3586. X    entry *objp;
  3587. X{
  3588. X    if (!xdr_u_int(xdrs, &objp->fileid)) {
  3589. X        return (FALSE);
  3590. X    }
  3591. X    if (!xdr_filename(xdrs, &objp->name)) {
  3592. X        return (FALSE);
  3593. X    }
  3594. X    if (!xdr_nfscookie(xdrs, objp->cookie)) {
  3595. X        return (FALSE);
  3596. X    }
  3597. X    if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof(entry), xdr_entry)) {
  3598. X        return (FALSE);
  3599. X    }
  3600. X    return (TRUE);
  3601. X}
  3602. X
  3603. Xbool_t
  3604. Xxdr_dirlist(xdrs, objp)
  3605. X    XDR *xdrs;
  3606. X    dirlist *objp;
  3607. X{
  3608. X    if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof(entry), xdr_entry)) {
  3609. X        return (FALSE);
  3610. X    }
  3611. X    if (!xdr_bool(xdrs, &objp->eof)) {
  3612. X        return (FALSE);
  3613. X    }
  3614. X    return (TRUE);
  3615. X}
  3616. X
  3617. Xbool_t
  3618. Xxdr_readdirres(xdrs, objp)
  3619. X    XDR *xdrs;
  3620. X    readdirres *objp;
  3621. X{
  3622. X    if (!xdr_nfsstat(xdrs, &objp->status)) {
  3623. X        return (FALSE);
  3624. X    }
  3625. X    switch (objp->status) {
  3626. X    case NFS_OK:
  3627. X        if (!xdr_dirlist(xdrs, &objp->readdirres_u.reply)) {
  3628. X            return (FALSE);
  3629. X        }
  3630. X        break;
  3631. X    }
  3632. X    return (TRUE);
  3633. X}
  3634. X
  3635. Xbool_t
  3636. Xxdr_statfsokres(xdrs, objp)
  3637. X    XDR *xdrs;
  3638. X    statfsokres *objp;
  3639. X{
  3640. X    if (!xdr_u_int(xdrs, &objp->tsize)) {
  3641. X        return (FALSE);
  3642. X    }
  3643. X    if (!xdr_u_int(xdrs, &objp->bsize)) {
  3644. X        return (FALSE);
  3645. X    }
  3646. X    if (!xdr_u_int(xdrs, &objp->blocks)) {
  3647. X        return (FALSE);
  3648. X    }
  3649. X    if (!xdr_u_int(xdrs, &objp->bfree)) {
  3650. X        return (FALSE);
  3651. X    }
  3652. X    if (!xdr_u_int(xdrs, &objp->bavail)) {
  3653. X        return (FALSE);
  3654. X    }
  3655. X    return (TRUE);
  3656. X}
  3657. X
  3658. Xbool_t
  3659. Xxdr_statfsres(xdrs, objp)
  3660. X    XDR *xdrs;
  3661. X    statfsres *objp;
  3662. X{
  3663. X    if (!xdr_nfsstat(xdrs, &objp->status)) {
  3664. X        return (FALSE);
  3665. X    }
  3666. X    switch (objp->status) {
  3667. X    case NFS_OK:
  3668. X        if (!xdr_statfsokres(xdrs, &objp->statfsres_u.reply)) {
  3669. X            return (FALSE);
  3670. X        }
  3671. X        break;
  3672. X    }
  3673. X    return (TRUE);
  3674. X}
  3675. END_OF_FILE
  3676.   if test 8059 -ne `wc -c <'rpc/nfs_prot_xdr.c'`; then
  3677.     echo shar: \"'rpc/nfs_prot_xdr.c'\" unpacked with wrong size!
  3678.   fi
  3679.   # end of 'rpc/nfs_prot_xdr.c'
  3680. fi
  3681. if test -f 'saps/crontab-add.sh' -a "${1}" != "-c" ; then 
  3682.   echo shar: Will not clobber existing file \"'saps/crontab-add.sh'\"
  3683. else
  3684.   echo shar: Extracting \"'saps/crontab-add.sh'\" \(833 characters\)
  3685.   sed "s/^X//" >'saps/crontab-add.sh' <<'END_OF_FILE'
  3686. X#!/bin/sh
  3687. X#
  3688. X# crontab-add.sh -- add crontab for expire.
  3689. X# This file is part of WWFS.
  3690. X#
  3691. Xif [ -f /usr/lib/crontab.local ]; then
  3692. X    # for SONY NEWS-OS
  3693. X    . /etc/csd.conf
  3694. X    /bin/cp /usr/lib/crontab.local /usr/lib/crontab.local.org
  3695. X    echo 33 6 * * * wwfs    $WWFSDIR/bin/expire >> /usr/lib/crontab.local
  3696. Xelse if [ -f /usr/lib/crontab ]; then
  3697. X    # for DEC Ultrix, NeXT
  3698. X    . /etc/csd.conf
  3699. X    /bin/cp /usr/lib/crontab.local /usr/lib/crontab.local.org
  3700. X    echo 33 6 * * * wwfs    $WWFSDIR/bin/expire >> /usr/lib/crontab.local
  3701. Xelse if [ -d /var/spool/cron/crontabs ]; then
  3702. X    # for SunOS
  3703. X    . /etc/csd.conf
  3704. X    echo 33 6 * * * wwfs    $WWFSDIR/bin/expire >> /var/spool/cron/crontabs/wwfs
  3705. Xelse if [ -d /usr/spool/cron/crontabs ]; then
  3706. X    # for IRIX
  3707. X    . /etc/csd.conf
  3708. X    echo 33 6 * * * wwfs    $WWFSDIR/bin/expire >> /usr/spool/cron/crontabs/wwfs
  3709. Xfi
  3710. X# other machines...?
  3711. END_OF_FILE
  3712.   if test 833 -ne `wc -c <'saps/crontab-add.sh'`; then
  3713.     echo shar: \"'saps/crontab-add.sh'\" unpacked with wrong size!
  3714.   fi
  3715.   # end of 'saps/crontab-add.sh'
  3716. fi
  3717. echo shar: End of archive 15 \(of 22\).
  3718. cp /dev/null ark15isdone
  3719. MISSING=""
  3720. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ; do
  3721.     if test ! -f ark${I}isdone ; then
  3722.     MISSING="${MISSING} ${I}"
  3723.     fi
  3724. done
  3725. if test "${MISSING}" = "" ; then
  3726.     echo You have unpacked all 22 archives.
  3727.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  3728. else
  3729.     echo You still must unpack the following archives:
  3730.     echo "        " ${MISSING}
  3731. fi
  3732. exit 0
  3733. exit 0 # Just in case...
  3734.