#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
-
+#include <sys/types.h>
#ifdef AFS_NT40_ENV
#include <winsock2.h>
#else
#include <netinet/in.h>
+#include <sys/wait.h>
#endif
-#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <afs/butm.h>
#include <afs/usd.h>
#include "error_macros.h"
+#include "butm_prototypes.h"
#ifdef O_LARGEFILE
typedef off64_t osi_lloff_t;
/* note: as painful as it is, we have to reach under the covers of
* the usd package to implement this functionality.
*/
- unixfd = (int)(fd->handle);
+ unixfd = (intptr_t)(fd->handle);
for (i = 3; i < _POSIX_OPEN_MAX; i++) {
if (i != unixfd && i != pipefd[1]) {
/* note: as painful as it is, we have to reach under the covers of
* the usd package to implement this functionality.
*/
- unixfd = (int)(fd->handle);
+ unixfd = (intptr_t)(fd->handle);
for (i = 3; i < _POSIX_OPEN_MAX; i++) {
if (i != unixfd && i != ctlpipe[0] && i != pipefd[1]) {
errno);
} else if (status != 0) {
printf
- ("butm: Unexpected exit status 0x04x from CLOSE process. Error %d\n",
+ ("butm: Unexpected exit status 0x%04x from CLOSE process. Error %d\n",
status, errno);
}
}
/* write end of file mark */
-static
+static int
WriteEOF(usd_handle_t fid, int count)
{
POLL();
* dataSize - bytes used on the tape
*/
-incSize(info, dataSize)
- struct butm_tapeInfo *info;
- afs_uint32 dataSize;
+void
+incSize(struct butm_tapeInfo *info, afs_uint32 dataSize)
{
info->nBytes += dataSize;
info->kBytes += (info->nBytes / 1024);
* dataSize - bytes used on the tape
*/
-incPosition(info, fid, dataSize)
- struct butm_tapeInfo *info;
- usd_handle_t fid;
- afs_uint32 dataSize;
+void
+incPosition(struct butm_tapeInfo *info, usd_handle_t fid, afs_uint32 dataSize)
{
/* Add this to the amount of data written to the tape */
incSize(info, dataSize);
*/
afs_int32 TapeBlockSize;
afs_int32
-readData(fid, data, totalSize, errorP)
- usd_handle_t fid;
- char *data;
- afs_int32 totalSize;
- afs_int32 *errorP;
+readData(usd_handle_t fid, char *data, afs_uint32 totalSize, afs_int32 *errorP)
{
afs_int32 toread; /* Number of bytes to read */
- afs_int32 rSize; /* Total bytes read so far */
- afs_int32 tSize; /* Temporary size */
+ afs_uint32 rSize; /* Total bytes read so far */
+ afs_uint32 tSize; /* Temporary size */
afs_int32 rc; /* return code */
toread = totalSize; /* First, try to read all the data */
}
afs_int32
-SeekFile(info, count)
- struct butm_tapeInfo *info;
- int count;
+SeekFile(struct butm_tapeInfo *info, int count)
{
afs_int32 code = 0;
struct progress *p;
/* Step to the next filemark if we are not at one already */
afs_int32
-NextFile(info)
- struct butm_tapeInfo *info;
+NextFile(struct butm_tapeInfo *info)
{
afs_int32 code;
}
static afs_int32
-WriteTapeBlock(info, buffer, length, blockType)
- struct butm_tapeInfo *info;
- char *buffer; /* assumed to be 16384 bytes with data in it */
- afs_int32 length; /* amount data in buffer */
- afs_int32 blockType;
+WriteTapeBlock(struct butm_tapeInfo *info,
+ char *buffer, /* assumed to be 16384 bytes with data in it */
+ afs_int32 length, /* amount data in buffer */
+ afs_int32 blockType)
{
afs_int32 code = 0, rc = 0;
- afs_int32 wsize;
+ afs_uint32 wsize;
struct tapeLabel *label;
struct fileMark *fmark;
struct blockMark *bmark;
}
static afs_int32
-ReadTapeBlock(info, buffer, blockType)
- struct butm_tapeInfo *info;
- char *buffer; /* assumed to be 16384 bytes */
- afs_int32 *blockType;
+ReadTapeBlock(struct butm_tapeInfo *info,
+ char *buffer, /* assumed to be 16384 bytes */
+ afs_int32 *blockType)
{
afs_int32 code = 0;
afs_int32 rsize, fmtype;
*/
static afs_int32
-check(info, write)
- struct butm_tapeInfo *info;
- int write; /* write operation requested */
+check(struct butm_tapeInfo *info,
+ int write) /* write operation requested */
{
struct progress *p;
}
static afs_int32
-rewindFile(info)
- struct butm_tapeInfo *info;
+rewindFile(struct butm_tapeInfo *info)
{
struct progress *p;
afs_int32 code = 0;
* ===================================================================== */
static afs_int32
-file_Mount(info, tape)
- struct butm_tapeInfo *info;
- char *tape;
+file_Mount(struct butm_tapeInfo *info, char *tape)
{
struct progress *p;
char filename[64];
}
static afs_int32
-file_Dismount(info)
- struct butm_tapeInfo *info;
+file_Dismount(struct butm_tapeInfo *info)
{
struct progress *p;
afs_int32 code = 0, error = 0;
(void)ShutdownAccess(p->fid); /* for NT */
/* close the device */
- if (error = ForkClose(p->fid)) {
+ if ((error = ForkClose(p->fid))) {
printf("butm: Tape close failed. Error %d\n", errno);
}
*/
static afs_int32
-file_WriteLabel(info, label, rewind)
- struct butm_tapeInfo *info;
- struct butm_tapeLabel *label;
- afs_int32 rewind;
+file_WriteLabel(struct butm_tapeInfo *info, struct butm_tapeLabel *label,
+ afs_int32 rewind)
{
afs_int32 code = 0;
afs_int32 fcode;
}
static afs_int32
-file_ReadLabel(info, label, rewind)
- struct butm_tapeInfo *info;
- struct butm_tapeLabel *label;
- afs_int32 rewind;
+file_ReadLabel(struct butm_tapeInfo *info, struct butm_tapeLabel *label,
+ afs_int32 rewind)
{
struct tapeLabel *tlabel;
afs_int32 code = 0;
}
static afs_int32
-file_WriteFileBegin(info)
- struct butm_tapeInfo *info;
+file_WriteFileBegin(struct butm_tapeInfo *info)
{
afs_int32 code = 0;
- afs_int32 error = 0;
if (info->debug)
printf("butm: Write filemark begin\n");
}
static afs_int32
-file_ReadFileBegin(info)
- struct butm_tapeInfo *info;
+file_ReadFileBegin(struct butm_tapeInfo *info)
{
afs_int32 code = 0;
afs_int32 blockType;
* Assumes the data buffer has a space reserved at beginning for a blockMark.
*/
static afs_int32
-file_WriteFileData(info, data, blocks, len)
- struct butm_tapeInfo *info;
- char *data;
- afs_int32 blocks;
- afs_int32 len;
+file_WriteFileData(struct butm_tapeInfo *info, char *data, afs_int32 blocks, afs_int32 len)
{
afs_int32 code = 0;
int length;
*/
static afs_int32
-file_ReadFileData(info, data, len, nBytes)
- struct butm_tapeInfo *info;
- char *data;
- int len;
- int *nBytes;
+file_ReadFileData(struct butm_tapeInfo *info, char *data, int len, int *nBytes)
{
struct blockMark *bmark;
afs_int32 code = 0;
}
static afs_int32
-file_WriteFileEnd(info)
- struct butm_tapeInfo *info;
+file_WriteFileEnd(struct butm_tapeInfo *info)
{
afs_int32 code = 0;
* missing with some 3.1 dumps).
*/
static afs_int32
-file_ReadFileEnd(info)
- struct butm_tapeInfo *info;
+file_ReadFileEnd(struct butm_tapeInfo *info)
{
afs_int32 code = 0;
afs_int32 blockType;
* Write the end-of-dump marker.
*/
static afs_int32
-file_WriteEODump(info)
- struct butm_tapeInfo *info;
+file_WriteEODump(struct butm_tapeInfo *info)
{
afs_int32 code = 0;
}
static afs_int32
-file_Seek(info, position)
- struct butm_tapeInfo *info;
- afs_int32 position;
+file_Seek(struct butm_tapeInfo *info, afs_int32 position)
{
afs_int32 code = 0;
afs_int32 w;
* This is for tapes of version 4 or greater.
*/
static afs_int32
-file_SeekEODump(info, position)
- struct butm_tapeInfo *info;
- afs_int32 position;
+file_SeekEODump(struct butm_tapeInfo *info, afs_int32 position)
{
afs_int32 code = 0;
afs_int32 blockType;
}
static afs_int32
-file_SetSize(info, size)
- struct butm_tapeInfo *info;
- afs_uint32 size;
+file_SetSize(struct butm_tapeInfo *info, afs_uint32 size)
{
if (info->debug)
printf("butm: Set size of tape\n");
}
static afs_int32
-file_GetSize(info, size)
- struct butm_tapeInfo *info;
- afs_uint32 *size;
+file_GetSize(struct butm_tapeInfo *info, afs_uint32 *size)
{
if (info->debug)
printf("butm: Get size of tape\n");
* ===================================================================== */
static afs_int32
-file_Configure(file)
- struct tapeConfig *file;
+file_Configure(struct tapeConfig *file)
{
if (!file) {
afs_com_err(whoami, BUTM_BADCONFIG, "device not specified");
/* This procedure instantiates a tape module of type file_tm. */
afs_int32
-butm_file_Instantiate(info, file)
- struct butm_tapeInfo *info;
- struct tapeConfig *file;
+butm_file_Instantiate(struct butm_tapeInfo *info, struct tapeConfig *file)
{
extern int debugLevel;
afs_int32 code = 0;