2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <sys/types.h>
17 int bulk_SendFile(fd, call, status)
19 register struct rx_call *call;
20 register struct stat *status;
22 char *buffer = (char*) 0;
27 blockSize = status->st_blksize;
28 length = status->st_size;
29 buffer = (char *)malloc(status->st_blksize);
31 printf("malloc failed\n");
34 xdrrx_create(&xdr, call, XDR_ENCODE);
35 if (!xdr_long(&xdr, &length)) error = BULK_ERROR;
36 while (!error && length) {
37 register nbytes = (length>blockSize?blockSize:length);
38 nbytes = read(fd, buffer, nbytes);
40 fprintf(stderr, "File system read failed\n");
43 if (rx_Write(call, buffer, nbytes) != nbytes)
47 if (buffer) free(buffer);
48 if (length) error = BULK_ERROR;
52 /* Copy the appropriate number of bytes from the call to fd. The status should reflect the file's status coming into the routine and will reflect it going out of the routine, in the absence of errors */
53 int bulk_ReceiveFile(fd, call, status)
55 register struct rx_call *call;
56 register struct stat *status;
58 register char *buffer = (char*) 0;
61 register int blockSize;
64 xdrrx_create(&xdr, call, XDR_DECODE);
65 if (!xdr_long(&xdr, &length)) return BULK_ERROR;
66 blockSize = status->st_blksize;
67 buffer = (char *)malloc(status->st_blksize);
69 printf("malloc failed\n");
72 while (!error && length) {
73 register nbytes = (length>blockSize?blockSize:length);
74 nbytes = rx_Read(call, buffer, nbytes);
75 if (!nbytes) error = BULK_ERROR;
76 if (write(fd, buffer, nbytes) != nbytes) {
77 fprintf("File system write failed!\n");
82 if (buffer) free(buffer);
83 if (!error) fstat(fd, status);