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 <afsconfig.h>
11 #include <afs/param.h>
14 #include <sys/types.h>
22 bulk_SendFile(fd
, call
, status
)
27 char *buffer
= (char *)0;
32 blockSize
= status
->st_blksize
;
33 length
= status
->st_size
;
34 buffer
= malloc(status
->st_blksize
);
36 printf("malloc failed\n");
39 xdrrx_create(&xdr
, call
, XDR_ENCODE
);
40 if (!xdr_long(&xdr
, &length
))
42 while (!error
&& length
) {
43 int nbytes
= (length
> blockSize
? blockSize
: length
);
44 nbytes
= read(fd
, buffer
, nbytes
);
46 fprintf(stderr
, "File system read failed\n");
49 if (rx_Write(call
, buffer
, nbytes
) != nbytes
)
60 /* 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 */
62 bulk_ReceiveFile(fd
, call
, status
)
67 char *buffer
= (char *)0;
73 xdrrx_create(&xdr
, call
, XDR_DECODE
);
74 if (!xdr_long(&xdr
, &length
))
76 blockSize
= status
->st_blksize
;
77 buffer
= malloc(status
->st_blksize
);
79 printf("malloc failed\n");
82 while (!error
&& length
) {
83 int nbytes
= (length
> blockSize
? blockSize
: length
);
84 nbytes
= rx_Read(call
, buffer
, nbytes
);
87 if (write(fd
, buffer
, nbytes
) != nbytes
) {
88 fprintf(stderr
, "File system write failed!\n");