#include <afs/unified_afs.h>
#include <afs/audit.h>
#include <afs/afsutil.h>
+#include <afs/dir.h>
+
+extern void SetDirHandle(register DirHandle * dir, register Vnode * vnode);
+extern void FidZap(DirHandle * file);
+extern void FidZero(DirHandle * file);
#ifdef AFS_PTHREAD_ENV
pthread_mutex_t fileproc_glock_mutex;
#endif /* AFS_PTHREAD_ENV */
+#ifdef O_LARGEFILE
+#define afs_stat stat64
+#define afs_fstat fstat64
+#define afs_open open64
+#else /* !O_LARGEFILE */
+#define afs_stat stat
+#define afs_fstat fstat
+#define afs_open open
+#endif /* !O_LARGEFILE */
+
/* Useful local defines used by this module */
extern int HTs, HTBlocks;
afs_int32 FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
- register struct rx_call *Call, afs_int32 Pos,
- afs_int32 Len, afs_int32 Int64Mode,
+ register struct rx_call *Call, afs_sfsize_t Pos,
+ afs_sfsize_t Len, afs_int32 Int64Mode,
#if FS_STATS_DETAILED
- afs_int32 * a_bytesToFetchP,
- afs_int32 * a_bytesFetchedP
+ afs_sfsize_t * a_bytesToFetchP,
+ afs_sfsize_t * a_bytesFetchedP
#endif /* FS_STATS_DETAILED */
);
afs_int32 StoreData_RXStyle(Volume * volptr, Vnode * targetptr,
struct AFSFid *Fid, struct client *client,
- register struct rx_call *Call, afs_uint32 Pos,
- afs_uint32 Length, afs_uint32 FileLength,
+ register struct rx_call *Call, afs_fsize_t Pos,
+ afs_fsize_t Length, afs_fsize_t FileLength,
int sync,
#if FS_STATS_DETAILED
- afs_int32 * a_bytesToStoreP,
- afs_int32 * a_bytesStoredP
+ afs_sfsize_t * a_bytesToStoreP,
+ afs_sfsize_t * a_bytesStoredP
#endif /* FS_STATS_DETAILED */
);
if (client->host->hcps.prlist_len && !client->host->hcps.prlist_val) {
ViceLog(0,
- ("CheckRights: len=%d, for host=0x%x\n",
+ ("CheckRights: len=%u, for host=0x%x\n",
client->host->hcps.prlist_len, client->host->host));
} else
acl_CheckRights(ACL, &client->host->hcps, &hrights);
Inode ino, nearInode;
int rdlen;
int wrlen;
- register int size, length;
+ register afs_fsize_t size;
+ register int length;
int ifd, ofd;
char *buff;
int rc; /* return code */
length = COPYBUFFSIZE;
size -= COPYBUFFSIZE;
} else {
- length = size;
+ length = (int)size;
size = 0;
}
rdlen = FDH_READ(targFdP, buff, length);
#endif /* FS_STATS_DETAILED */
parentptr->disk.dataVersion++;
- newlength = Length(dir);
+ newlength = (afs_fsize_t) Length(dir);
/*
* This is a called on both dir removals (i.e. remove, removedir, rename) but also in dir additions
* (create, symlink, link, makedir) so we need to check if we have enough space
* enough space before consuming some.
*/
static afs_int32
-AdjustDiskUsage(Volume * volptr, afs_int32 length, afs_int32 checkLength)
+AdjustDiskUsage(Volume * volptr, afs_sfsize_t length,
+ afs_sfsize_t checkLength)
{
int rc;
int nc;
static afs_int32
Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
Vnode ** targetptr, char *Name, struct AFSFid *OutFid,
- int FileType, int BlocksPreallocatedForVnode)
+ int FileType, afs_sfsize_t BlocksPreallocatedForVnode)
{
int errorCode = 0; /* Error code returned back */
int temp;
AdjustDiskUsage(volptr, BlocksPreallocatedForVnode,
BlocksPreallocatedForVnode))) {
ViceLog(25,
- ("Insufficient space to allocate %d blocks\n",
- BlocksPreallocatedForVnode));
+ ("Insufficient space to allocate %lld blocks\n",
+ (afs_intmax_t) BlocksPreallocatedForVnode));
return (errorCode);
}
static
afs_int32
-common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
- afs_int32 Len, struct AFSFetchStatus *OutStatus,
+common_FetchData64(struct rx_call *acall, struct AFSFid *Fid,
+ afs_sfsize_t Pos, afs_sfsize_t Len,
+ struct AFSFetchStatus *OutStatus,
struct AFSCallBack *CallBack, struct AFSVolSync *Sync,
int type)
{
struct timeval opStartTime, opStopTime; /* Start/stop times for RPC op */
struct timeval xferStartTime, xferStopTime; /* Start/stop times for xfer portion */
struct timeval elapsedTime; /* Transfer time */
- afs_int32 bytesToXfer; /* # bytes to xfer */
- afs_int32 bytesXferred; /* # bytes actually xferred */
+ afs_sfsize_t bytesToXfer; /* # bytes to xfer */
+ afs_sfsize_t bytesXferred; /* # bytes actually xferred */
int readIdx; /* Index of read stats array to bump */
static afs_int32 tot_bytesXferred; /* shared access protected by FS_LOCK */
struct AFSCallBack * CallBack, struct AFSVolSync * Sync)
{
int code;
- afs_int32 tPos, tLen;
+ afs_sfsize_t tPos, tLen;
#ifdef AFS_64BIT_ENV
+#ifndef AFS_LARGEFILE_ENV
if (Pos + Len > 0x7fffffff)
return E2BIG;
- tPos = Pos;
- tLen = Len;
+#endif /* !AFS_LARGEFILE_ENV */
+ tPos = (afs_sfsize_t) Pos;
+ tLen = (afs_sfsize_t) Len;
#else /* AFS_64BIT_ENV */
if (Pos.high || Len.high)
return E2BIG;
static
afs_int32
common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
- struct AFSStoreStatus *InStatus, afs_uint32 Pos,
- afs_uint32 Length, afs_uint32 FileLength,
+ struct AFSStoreStatus *InStatus, afs_fsize_t Pos,
+ afs_fsize_t Length, afs_fsize_t FileLength,
struct AFSFetchStatus *OutStatus, struct AFSVolSync *Sync)
{
Vnode *targetptr = 0; /* pointer to input fid */
struct timeval opStartTime, opStopTime; /* Start/stop times for RPC op */
struct timeval xferStartTime, xferStopTime; /* Start/stop times for xfer portion */
struct timeval elapsedTime; /* Transfer time */
- afs_int32 bytesToXfer; /* # bytes to xfer */
- afs_int32 bytesXferred; /* # bytes actually xfer */
+ afs_sfsize_t bytesToXfer; /* # bytes to xfer */
+ afs_sfsize_t bytesXferred; /* # bytes actually xfer */
static afs_int32 tot_bytesXferred; /* shared access protected by FS_LOCK */
/*
struct AFSVolSync * Sync)
{
int code;
- afs_int32 tPos;
- afs_int32 tLength;
- afs_int32 tFileLength;
+ afs_fsize_t tPos;
+ afs_fsize_t tLength;
+ afs_fsize_t tFileLength;
#ifdef AFS_64BIT_ENV
+#ifndef AFS_LARGEFILE_ENV
if (FileLength > 0x7fffffff)
return E2BIG;
- tPos = Pos;
- tLength = Length;
- tFileLength = FileLength;
+#endif /* !AFS_LARGEFILE_ENV */
+ tPos = (afs_fsize_t) Pos;
+ tLength = (afs_fsize_t) Length;
+ tFileLength = (afs_fsize_t) FileLength;
#else /* AFS_64BIT_ENV */
if (FileLength.high)
return E2BIG;
if (newfileptr->disk.linkCount == 0) { /* Link count 0 - delete */
afs_fsize_t newSize;
VN_GET_LEN(newSize, newfileptr);
- VAdjustDiskUsage(&errorCode, volptr, -nBlocks(newSize), 0);
+ VAdjustDiskUsage((Error *) & errorCode, volptr,
+ (afs_sfsize_t) - nBlocks(newSize), 0);
if (VN_GET_INO(newfileptr)) {
IH_REALLYCLOSE(newfileptr->handle);
errorCode =
SetDirHandle(&dir, targetptr);
assert(!(MakeDir(&dir, OutFid, DirFid)));
DFlush();
- VN_SET_LEN(targetptr, Length(&dir));
+ VN_SET_LEN(targetptr, (afs_fsize_t) Length(&dir));
/* set up return status */
GetStatus(targetptr, OutFidStatus, rights, anyrights, parentptr);
AFSCallStats.GetRootVolume++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
temp = malloc(256);
- fd = open(AFSDIR_SERVER_ROOTVOL_FILEPATH, O_RDONLY, 0666);
+ fd = afs_open(AFSDIR_SERVER_ROOTVOL_FILEPATH, O_RDONLY, 0666);
if (fd <= 0)
strcpy(temp, DEFAULTVOLUME);
else {
afs_int32
FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
- register struct rx_call * Call, afs_int32 Pos,
- afs_int32 Len, afs_int32 Int64Mode,
+ register struct rx_call * Call, afs_sfsize_t Pos,
+ afs_sfsize_t Len, afs_int32 Int64Mode,
#if FS_STATS_DETAILED
- afs_int32 * a_bytesToFetchP, afs_int32 * a_bytesFetchedP
+ afs_sfsize_t * a_bytesToFetchP,
+ afs_sfsize_t * a_bytesFetchedP
#endif /* FS_STATS_DETAILED */
)
{
struct iovec tiov[RX_MAXIOVECS];
int tnio;
#endif /* AFS_NT40_ENV */
- afs_int32 tlen;
+ afs_sfsize_t tlen;
afs_int32 optSize;
- struct stat tstat;
+ struct afs_stat tstat;
#ifdef AFS_AIX_ENV
struct statfs tstatfs;
#endif
(*a_bytesFetchedP) = 0;
#endif /* FS_STATS_DETAILED */
+
+ ViceLog(25,
+ ("FetchData_RXStyle: Pos %llu, Len %llu\n", (afs_uintmax_t) Pos,
+ (afs_uintmax_t) Len));
+
if (!VN_GET_INO(targetptr)) {
+ afs_int32 zero = htonl(0);
/*
* This is used for newly created files; we simply send 0 bytes
* back to make the cache manager happy...
*/
- tlen = htonl(0);
if (Int64Mode)
- rx_Write(Call, (char *)&tlen, sizeof(afs_int32)); /* send 0-length */
- rx_Write(Call, (char *)&tlen, sizeof(afs_int32)); /* send 0-length */
+ rx_Write(Call, (char *)&zero, sizeof(afs_int32)); /* send 0-length */
+ rx_Write(Call, (char *)&zero, sizeof(afs_int32)); /* send 0-length */
return (0);
}
TM_GetTimeOfDay(&StartTime, 0);
return EIO;
optSize = sendBufSize;
tlen = FDH_SIZE(fdP);
+ ViceLog(25,
+ ("FetchData_RXStyle: file size %llu\n", (afs_uintmax_t) tlen));
if (tlen < 0) {
FDH_CLOSE(fdP);
return EIO;
if (Pos + Len > tlen)
Len = tlen - Pos; /* get length we should send */
(void)FDH_SEEK(fdP, Pos, 0);
- tlen = htonl(Len);
- if (Int64Mode) {
- afs_int32 zero = 0;
- rx_Write(Call, (char *)&zero, sizeof(afs_int32)); /* High order bits */
+ {
+ afs_int32 high, low;
+ SplitOffsetOrSize(Len, high, low);
+ assert(Int64Mode || high == 0);
+ if (Int64Mode) {
+ high = htonl(high);
+ rx_Write(Call, (char *)&high, sizeof(afs_int32)); /* High order bits */
+ }
+ low = htonl(low);
+ rx_Write(Call, (char *)&low, sizeof(afs_int32)); /* send length on fetch */
}
- rx_Write(Call, (char *)&tlen, sizeof(afs_int32)); /* send length on fetch */
#if FS_STATS_DETAILED
(*a_bytesToFetchP) = Len;
#endif /* FS_STATS_DETAILED */
tbuffer = AllocSendBuffer();
#endif /* AFS_NT40_ENV */
while (Len > 0) {
+ int wlen;
if (Len > optSize)
- tlen = optSize;
+ wlen = optSize;
else
- tlen = Len;
+ wlen = (int)Len;
#ifdef AFS_NT40_ENV
- errorCode = FDH_READ(fdP, tbuffer, tlen);
- if (errorCode != tlen) {
+ errorCode = FDH_READ(fdP, tbuffer, wlen);
+ if (errorCode != wlen) {
FDH_CLOSE(fdP);
FreeSendBuffer((struct afs_buffer *)tbuffer);
return EIO;
}
- errorCode = rx_Write(Call, tbuffer, tlen);
+ errorCode = rx_Write(Call, tbuffer, wlen);
#else /* AFS_NT40_ENV */
- errorCode = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, tlen);
+ errorCode = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, wlen);
if (errorCode <= 0) {
FDH_CLOSE(fdP);
return EIO;
}
- tlen = errorCode;
+ wlen = errorCode;
errorCode = FDH_READV(fdP, tiov, tnio);
- if (errorCode != tlen) {
+ if (errorCode != wlen) {
FDH_CLOSE(fdP);
return EIO;
}
- errorCode = rx_Writev(Call, tiov, tnio, tlen);
+ errorCode = rx_Writev(Call, tiov, tnio, wlen);
#endif /* AFS_NT40_ENV */
#if FS_STATS_DETAILED
/*
*/
(*a_bytesFetchedP) += errorCode;
#endif /* FS_STATS_DETAILED */
- if (errorCode != tlen) {
+ if (errorCode != wlen) {
FDH_CLOSE(fdP);
#ifdef AFS_NT40_ENV
FreeSendBuffer((struct afs_buffer *)tbuffer);
#endif /* AFS_NT40_ENV */
return -31;
}
- Len -= tlen;
+ Len -= wlen;
}
#ifdef AFS_NT40_ENV
FreeSendBuffer((struct afs_buffer *)tbuffer);
} /*FetchData_RXStyle */
static int
-GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc, int *size)
+GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc,
+ afs_sfsize_t * size)
{
#ifdef AFS_NAMEI_ENV
FdHandle_t *lhp;
*size = OS_SIZE(fdP->fd_fd);
return (*size == -1) ? -1 : 0;
#else
- struct stat status;
+ struct afs_stat status;
- if (fstat(fdP->fd_fd, &status) < 0) {
+ if (afs_fstat(fdP->fd_fd, &status) < 0) {
return -1;
}
afs_int32
StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
struct client * client, register struct rx_call * Call,
- afs_uint32 Pos, afs_uint32 Length, afs_uint32 FileLength,
+ afs_fsize_t Pos, afs_fsize_t Length, afs_fsize_t FileLength,
int sync,
#if FS_STATS_DETAILED
- afs_int32 * a_bytesToStoreP, afs_int32 * a_bytesStoredP
+ afs_sfsize_t * a_bytesToStoreP,
+ afs_sfsize_t * a_bytesStoredP
#endif /* FS_STATS_DETAILED */
)
{
- int bytesTransfered; /* number of bytes actually transfered */
+ afs_sfsize_t bytesTransfered; /* number of bytes actually transfered */
struct timeval StartTime, StopTime; /* Used to measure how long the store takes */
int errorCode = 0; /* Returned error code to caller */
#ifdef AFS_NT40_ENV
struct iovec tiov[RX_MAXIOVECS]; /* no data copying with iovec */
int tnio; /* temp for iovec size */
#endif /* AFS_NT40_ENV */
- int tlen; /* temp for xfr length */
+ afs_sfsize_t tlen; /* temp for xfr length */
Inode tinode; /* inode for I/O */
afs_int32 optSize; /* optimal transfer size */
- int DataLength; /* size of inode */
- afs_int32 TruncatedLength; /* size after ftruncate */
- afs_uint32 NewLength; /* size after this store completes */
- afs_int32 adjustSize; /* bytes to call VAdjust... with */
+ afs_sfsize_t DataLength; /* size of inode */
+ afs_sfsize_t TruncatedLength; /* size after ftruncate */
+ afs_fsize_t NewLength; /* size after this store completes */
+ afs_sfsize_t adjustSize; /* bytes to call VAdjust... with */
int linkCount; /* link count on inode */
int code;
FdHandle_t *fdP;
/* the inode should have been created in Alloc_NewVnode */
logHostAddr.s_addr = rx_HostOf(rx_PeerOf(rx_ConnectionOf(Call)));
ViceLog(0,
- ("StoreData_RXStyle : Inode non-existent Fid = %u.%u.%u, inode = %llu, Pos %d Host %s\n",
+ ("StoreData_RXStyle : Inode non-existent Fid = %u.%u.%u, inode = %llu, Pos %llu Host %s\n",
Fid->Volume, Fid->Vnode, Fid->Unique,
- (afs_uintmax_t) VN_GET_INO(targetptr), Pos,
+ (afs_uintmax_t) VN_GET_INO(targetptr), (afs_uintmax_t) Pos,
inet_ntoa(logHostAddr)));
return ENOENT; /* is this proper error code? */
} else {
TM_GetTimeOfDay(&StartTime, 0);
optSize = sendBufSize;
+ ViceLog(25,
+ ("StoreData_RXStyle: Pos %llu, DataLength %llu, FileLength %llu, Length %llu\n",
+ (afs_uintmax_t) Pos, (afs_uintmax_t) DataLength,
+ (afs_uintmax_t) FileLength, (afs_uintmax_t) Length));
/* truncate the file iff it needs it (ftruncate is slow even when its a noop) */
if (FileLength < DataLength)
(*a_bytesToStoreP) = Length;
#endif /* FS_STATS_DETAILED */
while (1) {
+ int rlen;
if (bytesTransfered >= Length) {
errorCode = 0;
break;
}
tlen = Length - bytesTransfered; /* how much more to do */
if (tlen > optSize)
- tlen = optSize; /* bound by buffer size */
+ rlen = optSize; /* bound by buffer size */
+ else
+ rlen = (int)tlen;
#ifdef AFS_NT40_ENV
- errorCode = rx_Read(Call, tbuffer, tlen);
+ errorCode = rx_Read(Call, tbuffer, rlen);
#else /* AFS_NT40_ENV */
- errorCode = rx_Readv(Call, tiov, &tnio, RX_MAXIOVECS, tlen);
+ errorCode = rx_Readv(Call, tiov, &tnio, RX_MAXIOVECS, rlen);
#endif /* AFS_NT40_ENV */
#if FS_STATS_DETAILED
(*a_bytesStoredP) += errorCode;
errorCode = -32;
break;
}
- tlen = errorCode;
+ rlen = errorCode;
#ifdef AFS_NT40_ENV
- errorCode = FDH_WRITE(fdP, tbuffer, tlen);
+ errorCode = FDH_WRITE(fdP, tbuffer, rlen);
#else /* AFS_NT40_ENV */
errorCode = FDH_WRITEV(fdP, tiov, tnio);
#endif /* AFS_NT40_ENV */
- if (errorCode != tlen) {
+ if (errorCode != rlen) {
errorCode = VDISKFULL;
break;
}
- bytesTransfered += tlen;
+ bytesTransfered += rlen;
}
}
done:
FDH_SYNC(fdP);
}
if (errorCode) {
- afs_fsize_t nfSize = FDH_SIZE(fdP);
+ afs_fsize_t nfSize = (afs_fsize_t) FDH_SIZE(fdP);
/* something went wrong: adjust size and return */
VN_SET_LEN(targetptr, nfSize); /* set new file size. */
/* changed_newTime is tested in StoreData to detemine if we
FDH_CLOSE(fdP);
/* set disk usage to be correct */
VAdjustDiskUsage(&errorCode, volptr,
- (int)(nBlocks(nfSize) - nBlocks(NewLength)), 0);
+ (afs_sfsize_t) (nBlocks(nfSize) -
+ nBlocks(NewLength)), 0);
return errorCode;
}
FDH_CLOSE(fdP);
ntohs(host->port), (host->hostFlags & VENUSDOWN),
afs_ctime((time_t *) & host->LastCall, tbuffer,
sizeof(tbuffer)));
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
for (client = host->FirstClient; client; client = client->next) {
if (!client->deleted) {
if (client->tcon) {
expTime, tbuffer,
sizeof(tbuffer))
: "No Limit\n");
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
} else {
(void)afs_snprintf(tmpStr, sizeof tmpStr,
" user=%s, no current server connection\n",
h_UserName(client));
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
}
(void)afs_snprintf(tmpStr, sizeof tmpStr, " CPS-%d is [",
client->CPS.prlist_len);
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
if (client->CPS.prlist_val) {
for (i = 0; i > client->CPS.prlist_len; i++) {
(void)afs_snprintf(tmpStr, sizeof tmpStr, " %d",
client->CPS.prlist_val[i]);
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
}
}
sprintf(tmpStr, "]\n");
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
}
}
H_UNLOCK;
now = FT_ApproxTime();
(void)afs_snprintf(tmpStr, sizeof tmpStr, "List of active users at %s\n",
afs_ctime(&now, tbuffer, sizeof(tbuffer)));
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
h_Enumerate(h_PrintClient, (char *)file);
STREAM_REALLYCLOSE(file);
ViceLog(0, ("Created client dump %s\n", AFSDIR_SERVER_CLNTDUMP_FILEPATH));
host->hostFlags & HOSTDELETED, host->Console,
host->hostFlags & CLIENTDELETED,
host->hcpsfailed, host->cpsCall);
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
if (host->hcps.prlist_val)
for (i = 0; i < host->hcps.prlist_len; i++) {
(void)afs_snprintf(tmpStr, sizeof tmpStr, " %d",
host->hcps.prlist_val[i]);
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
}
sprintf(tmpStr, "] [");
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
if (host->interface)
for (i = 0; i < host->interface->numberOfInterfaces; i++) {
sprintf(tmpStr, " %x", host->interface->addr[i]);
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
}
sprintf(tmpStr, "] holds: ");
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
for (i = 0; i < h_maxSlots; i++) {
sprintf(tmpStr, "%04x", host->holds[i]);
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
}
sprintf(tmpStr, " slot/bit: %d/%d\n", h_holdSlot(), h_holdbit());
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
H_UNLOCK;
return held;
now = FT_ApproxTime();
(void)afs_snprintf(tmpStr, sizeof tmpStr, "List of active hosts at %s\n",
afs_ctime(&now, tbuffer, sizeof(tbuffer)));
- STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
+ (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
h_Enumerate(h_DumpHost, (char *)file);
STREAM_REALLYCLOSE(file);
ViceLog(0, ("Created host dump %s\n", AFSDIR_SERVER_HOSTDUMP_FILEPATH));
#endif
#include <rx/rx_globals.h>
+#ifdef O_LARGEFILE
+#define afs_stat stat64
+#define afs_fstat fstat64
+#define afs_open open64
+#define afs_fopen fopen64
+#else /* !O_LARGEFILE */
+#define afs_stat stat
+#define afs_fstat fstat
+#define afs_open open
+#define afs_fopen fopen
+#endif /* !O_LARGEFILE */
extern int BreakVolumeCallBacks(), InitCallBack();
extern int BreakVolumeCallBacks(), InitCallBack(), BreakLaterCallBacks();
CheckDescriptors()
{
#ifndef AFS_NT40_ENV
- struct stat status;
+ struct afs_stat status;
register int tsize = getdtablesize();
register int i;
for (i = 0; i < tsize; i++) {
- if (fstat(i, &status) != -1) {
+ if (afs_fstat(i, &status) != -1) {
printf("%d: dev %x, inode %u, length %u, type/mode %x\n", i,
status.st_dev, status.st_ino, status.st_size,
status.st_mode);
#if defined(AFS_PTHREAD_ENV)
softsig_signal(SIGTERM, CheckDescriptors_Signal);
#else
- signal(SIGTERM, CheckDescriptors_Signal);
+ (void)signal(SIGTERM, CheckDescriptors_Signal);
#endif
#endif
}
CheckAdminName()
{
int fd = 0;
- struct stat status;
+ struct afs_stat status;
- if ((stat("/AdminName", &status)) || /* if file does not exist */
+ if ((afs_stat("/AdminName", &status)) || /* if file does not exist */
(status.st_size <= 0) || /* or it is too short */
(status.st_size >= (MAXADMINNAME)) || /* or it is too long */
- !(fd = open("/AdminName", O_RDONLY, 0))) { /* or the open fails */
+ !(fd = afs_open("/AdminName", O_RDONLY, 0))) { /* or the open fails */
strcpy(adminName, "System:Administrators"); /* use the default name */
} else {
(void)read(fd, adminName, status.st_size); /* use name from the file */
static void
NewParms(int initializing)
{
- static struct stat sbuf;
+ static struct afs_stat sbuf;
register int i, fd;
char *parms;
char *argv[MAXPARMS];
register int argc;
- if (!(stat("/vice/file/parms", &sbuf))) {
+ if (!(afs_stat("/vice/file/parms", &sbuf))) {
parms = (char *)malloc(sbuf.st_size);
if (!parms)
return;
- fd = open("parms", O_RDONLY, 0666);
+ fd = afs_open("parms", O_RDONLY, 0666);
if (fd <= 0) {
ViceLog(0, ("Open for parms failed with errno = %d\n", errno));
return;
{
afs_int32 fd, nentries, i;
struct versionStamp vsn;
- struct stat status;
+ struct afs_stat status;
afsUUID uuid;
- if ((stat(AFSDIR_SERVER_SYSID_FILEPATH, &status))
+ if ((afs_stat(AFSDIR_SERVER_SYSID_FILEPATH, &status))
|| (status.st_size <= 0)) {
ViceLog(0, ("%s: doesn't exist\n", AFSDIR_SERVER_SYSID_FILEPATH));
return ENOENT;
}
- if (!(fd = open(AFSDIR_SERVER_SYSID_FILEPATH, O_RDONLY, 0))) {
+ if (!(fd = afs_open(AFSDIR_SERVER_SYSID_FILEPATH, O_RDONLY, 0))) {
ViceLog(0,
("%s: can't open (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
errno));
{
afs_int32 fd, nentries, i;
struct versionStamp vsn;
- struct stat status;
+ struct afs_stat status;
afsUUID uuid;
- if (!stat(AFSDIR_SERVER_SYSID_FILEPATH, &status)) {
+ if (!afs_stat(AFSDIR_SERVER_SYSID_FILEPATH, &status)) {
/*
* File exists; keep the old one around
*/
renamefile(AFSDIR_SERVER_SYSID_FILEPATH,
AFSDIR_SERVER_OLDSYSID_FILEPATH);
}
- fd = open(AFSDIR_SERVER_SYSID_FILEPATH, O_WRONLY | O_TRUNC | O_CREAT,
- 0666);
+ fd = afs_open(AFSDIR_SERVER_SYSID_FILEPATH, O_WRONLY | O_TRUNC | O_CREAT,
+ 0666);
if (fd < 1) {
ViceLog(0,
("%s: can't create (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
exit(2);
}
#ifndef AFS_QUIETFS_ENV
- console = fopen("/dev/console", "w");
+ console = afs_fopen("/dev/console", "w");
#endif
if (ParseArgs(argc, argv)) {
/* Some rx debugging */
if (rxlog || eventlog) {
- debugFile = fopen("rx_dbg", "w");
+ debugFile = afs_fopen("rx_dbg", "w");
if (rxlog)
rx_debugFile = debugFile;
if (eventlog)
} else {
char hoststr[16];
memcpy(&FS_HostAddr_NBO, he->h_addr, 4);
- afs_inet_ntoa_r(FS_HostAddr_NBO, hoststr);
+ (void)afs_inet_ntoa_r(FS_HostAddr_NBO, hoststr);
FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO);
ViceLog(0,
("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n",
#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
softsig_signal(SIGQUIT, ShutDown_Signal);
#else
- signal(SIGQUIT, ShutDown_Signal);
+ (void)signal(SIGQUIT, ShutDown_Signal);
#endif
ViceLog(0,
if (dircloned) {
rwvnode->cloned = 0;
if (STREAM_SEEK(rwfile, offset, 0) != -1)
- STREAM_WRITE(rwvnode, vcp->diskSize, 1, rwfile);
+ (void)STREAM_WRITE(rwvnode, vcp->diskSize, 1, rwfile);
}
ERROR_EXIT(EIO);
}
#endif /* AFS_PTHREAD_ENV */
#include <limits.h>
+#ifndef AFS_NT40_ENV
+#ifdef O_LARGEFILE
+#define afs_stat stat64
+#define afs_fstat fstat64
+#else /* !O_LARGEFILE */
+#define afs_stat stat
+#define afs_fstat fstat
+#endif /* !O_LARGEFILE */
+#endif /* AFS_NT40_ENV */
+
extern afs_int32 DErrno;
#ifdef AFS_PTHREAD_ENV
}
/* fread for buffered I/O handles */
-int
-stream_read(void *ptr, int size, int nitems, StreamHandle_t * streamP)
+afs_sfsize_t
+stream_read(void *ptr, afs_fsize_t size, afs_fsize_t nitems,
+ StreamHandle_t * streamP)
{
- int nbytes, bytesRead, bytesToRead;
+ afs_fsize_t nbytes, bytesRead, bytesToRead;
char *p;
/* Need to seek before changing direction */
}
/* fwrite for buffered I/O handles */
-int
-stream_write(void *ptr, int size, int nitems, StreamHandle_t * streamP)
+afs_sfsize_t
+stream_write(void *ptr, afs_fsize_t size, afs_fsize_t nitems,
+ StreamHandle_t * streamP)
{
char *p;
- int rc, nbytes, bytesWritten, bytesToWrite;
+ afs_sfsize_t rc;
+ afs_fsize_t nbytes, bytesWritten, bytesToWrite;
/* Need to seek before changing direction */
if (streamP->str_direction == STREAM_DIRECTION_NONE) {
/* fseek for buffered I/O handles */
int
-stream_seek(StreamHandle_t * streamP, int offset, int whence)
+stream_seek(StreamHandle_t * streamP, afs_foff_t offset, int whence)
{
int rc;
int retval = 0;
#ifndef AFS_NT40_ENV
-int
+afs_sfsize_t
ih_size(int fd)
{
- struct stat status;
- if (fstat(fd, &status) < 0)
+ struct afs_stat status;
+ if (afs_fstat(fd, &status) < 0)
return -1;
return status.st_size;
}
typedef struct StreamHandle_s {
FD_t str_fd; /* file descriptor */
int str_direction; /* current read/write direction */
- int str_buflen; /* bytes remaining in buffer */
- int str_bufoff; /* current offset into buffer */
+ afs_sfsize_t str_buflen; /* bytes remaining in buffer */
+ afs_foff_t str_bufoff; /* current offset into buffer */
int str_error; /* error code */
int str_eof; /* end of file flag */
struct StreamHandle_s *str_next; /* Avail list pointers */
#endif /* AFS_NAMEI_ENV */
/*
- * Prototypes for file descriptor cache routined
+ * Prototypes for file descriptor cache routines
*/
+extern void ih_Initialize(void);
extern void ih_UseLargeCache(void);
-extern IHandle_t *ih_init(int dev, int vid, Inode ino);
+extern IHandle_t *ih_init(int /*@alt Device@ */ dev, int /*@alt VolId@ */ vid,
+ Inode ino);
extern IHandle_t *ih_copy(IHandle_t * ihP);
extern FdHandle_t *ih_open(IHandle_t * ihP);
extern int fd_close(FdHandle_t * fdP);
extern int fd_reallyclose(FdHandle_t * fdP);
extern StreamHandle_t *stream_fdopen(FD_t fd);
extern StreamHandle_t *stream_open(const char *file, const char *mode);
-extern int stream_read(void *ptr, int size, int nitems,
- StreamHandle_t * streamP);
-extern int stream_write(void *ptr, int size, int nitems,
- StreamHandle_t * streamP);
-extern int stream_seek(StreamHandle_t * streamP, int offset, int whence);
+extern afs_sfsize_t stream_read(void *ptr, afs_fsize_t size,
+ afs_fsize_t nitems, StreamHandle_t * streamP);
+extern afs_sfsize_t stream_write(void *ptr, afs_fsize_t size,
+ afs_fsize_t nitems,
+ StreamHandle_t * streamP);
+extern int stream_seek(StreamHandle_t * streamP, afs_foff_t offset,
+ int whence);
extern int stream_flush(StreamHandle_t * streamP);
extern int stream_close(StreamHandle_t * streamP, int reallyClose);
extern int ih_reallyclose(IHandle_t * ihP);
#define IH_IWRITE(H, O, B, S) nt_iwrite(H, O, B, S)
#else /* AFS_NT40_ENV */
+
+/*@+fcnmacros +macrofcndecl@*/
+#ifdef S_SPLINT_S
+extern Inode IH_CREATE(IHandle_t * H, int /*@alt Device @ */ D,
+ char *P, Inode N, int /*@alt VolumeId @ */ P1,
+ int /*@alt VnodeId @ */ P2,
+ int /*@alt Unique @ */ P3,
+ int /*@alt unsigned @ */ P4);
+extern FD_t OS_IOPEN(IHandle_t * H);
+extern int OS_OPEN(const char *F, int M, mode_t P);
+extern int OS_CLOSE(int FD);
+extern ssize_t OS_READ(int FD, void *B, size_t S);
+extern ssize_t OS_WRITE(int FD, void *B, size_t S);
+extern int OS_SYNC(int FD);
+extern afs_sfsize_t OS_SIZE(int FD);
+extern int IH_INC(IHandle_t * H, Inode I, int /*@alt VolId, VolumeId @ */ P);
+extern int IH_DEC(IHandle_t * H, Inode I, int /*@alt VolId, VolumeId @ */ P);
+extern afs_sfsize_t IH_IREAD(IHandle_t * H, afs_foff_t O, void *B,
+ afs_fsize_t S);
+extern afs_sfsize_t IH_IWRITE(IHandle_t * H, afs_foff_t O, void *B,
+ afs_fsize_t S);
+#ifdef O_LARGEFILE
+extern off64_t OS_SEEK(int FD, off64_t O, int F);
+extern int OS_TRUNC(int FD, off64_t L);
+#else /* !O_LARGEFILE */
+extern off_t OS_SEEK(int FD, off_t O, int F);
+extern int OS_TRUNC(int FD, off_t L);
+#endif /* !O_LARGEFILE */
+#endif /*S_SPLINT_S */
+
#define IH_CREATE(H, D, P, N, P1, P2, P3, P4) \
namei_icreate(H, P, P1, P2, P3, P4)
#define OS_IOPEN(H) namei_iopen(H)
+#ifdef O_LARGEFILE
+#define OS_OPEN(F, M, P) open64(F, M, P)
+#else /* !O_LARGEFILE */
#define OS_OPEN(F, M, P) open(F, M, P)
+#endif /* !O_LARGEFILE */
#define OS_CLOSE(FD) close(FD)
#define OS_READ(FD, B, S) read(FD, B, S)
#define OS_WRITE(FD, B, S) write(FD, B, S)
-#define OS_SEEK(FD, O, F) lseek(FD, O, F)
+#ifdef O_LARGEFILE
+#define OS_SEEK(FD, O, F) lseek64(FD, (off64_t) (O), F)
+#else /* !O_LARGEFILE */
+#define OS_SEEK(FD, O, F) lseek(FD, (off_t) (O), F)
+#endif /* !O_LARGEFILE */
#define OS_SYNC(FD) fsync(FD)
-#define OS_TRUNC(FD, L) ftruncate(FD, L)
+#ifdef O_LARGEFILE
+#define OS_TRUNC(FD, L) ftruncate64(FD, (off64_t) (L))
+#else /* !O_LARGEFILE */
+#define OS_TRUNC(FD, L) ftruncate(FD, (off_t) (L))
+#endif /* !O_LARGEFILE */
#define OS_SIZE(FD) ih_size(FD)
+extern afs_sfsize_t ih_size(int fd);
#define IH_INC(H, I, P) namei_inc(H, I, P)
#define IH_DEC(H, I, P) namei_dec(H, I, P)
#define IH_IREAD(H, O, B, S) namei_iread(H, O, B, S)
#define IH_IWRITE(H, O, B, S) namei_iwrite(H, O, B, S)
+/*@=fcnmacros =macrofcndecl@*/
#endif /* AFS_NT40_ENV */
#else /* AFS_NAMEI_ENV */
#define OS_SYNC(FD) fsync(FD)
#define OS_TRUNC(FD, L) ftruncate(FD, L)
#define OS_SIZE(FD) ih_size(FD)
+extern afs_sfsize_t ih_size(int fd);
#ifdef AFS_LINUX22_ENV
#define IH_INC(H, I, P) -1
#include "partition.h"
#include <afs/errors.h>
+/*@+fcnmacros +macrofcndecl@*/
+#ifdef O_LARGEFILE
+#ifdef S_SPLINT_S
+extern off64_t afs_lseek(int FD, off64_t O, int F);
+#endif /*S_SPLINT_S */
+#define afs_lseek(FD, O, F) lseek64(FD, (off64_t)(O), F)
+#define afs_stat stat64
+#define afs_fstat fstat64
+#define afs_open open64
+#define afs_fopen fopen64
+#else /* !O_LARGEFILE */
+#ifdef S_SPLINT_S
+extern off_t afs_lseek(int FD, off_t O, int F);
+#endif /*S_SPLINT_S */
+#define afs_lseek(FD, O, F) lseek(FD, (off_t)(O), F)
+#define afs_stat stat
+#define afs_fstat fstat
+#define afs_open open
+#define afs_fopen fopen
+#endif /* !O_LARGEFILE */
+/*@=fcnmacros =macrofcndecl@*/
+
/*@printflike@*/ extern void Log(const char *format, ...);
extern char *volutil_PartitionName_r(int volid, char *buf, int buflen);
-int
-namei_iread(IHandle_t * h, int offset, char *buf, int size)
+afs_sfsize_t
+namei_iread(IHandle_t * h, afs_foff_t offset, char *buf, afs_fsize_t size)
{
- int nBytes;
+ afs_sfsize_t nBytes;
FdHandle_t *fdP;
fdP = IH_OPEN(h);
return nBytes;
}
-int
-namei_iwrite(IHandle_t * h, int offset, char *buf, int size)
+afs_sfsize_t
+namei_iwrite(IHandle_t * h, afs_foff_t offset, char *buf, afs_fsize_t size)
{
- int nBytes;
+ afs_sfsize_t nBytes;
FdHandle_t *fdP;
fdP = IH_OPEN(h);
(void)afs_snprintf(filename, sizeof filename, "%s/%s/README", partition,
INODEDIR);
- fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0444);
+ fd = afs_open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0444);
if (fd >= 0) {
(void)write(fd, VICE_README, strlen(VICE_README));
close(fd);
char *cp;
DIR *ds;
struct dirent *dirp;
- struct stat st;
+ struct afs_stat st;
if (*tree) {
/* delete the children first */
*/
strcat(root, "/");
strcat(root, dirp->d_name);
- if (stat(root, &st) == 0 && S_ISDIR(st.st_mode)) {
+ if (afs_stat(root, &st) == 0 && S_ISDIR(st.st_mode)) {
/* delete this subtree */
delTree(root, cp + 1, errp);
} else
/* GetOGM - get parm and tag from owner, group and mode bits. */
static void
-GetOGMFromStat(struct stat *status, int *parm, int *tag)
+GetOGMFromStat(struct afs_stat *status, int *parm, int *tag)
{
*parm = status->st_uid | (status->st_gid << 15);
*parm |= (status->st_mode & 0x18) << 27;
static int
GetOGM(int fd, int *parm, int *tag)
{
- struct stat status;
- if (fstat(fd, &status) < 0)
+ struct afs_stat status;
+ if (afs_fstat(fd, &status) < 0)
return -1;
GetOGMFromStat(&status, parm, tag);
}
namei_HandleToName(&name, &tmp);
- fd = open(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
+ fd = afs_open(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
if (fd < 0) {
if (errno == ENOTDIR || errno == ENOENT) {
if (namei_CreateDataDirectories(&name, &created_dir) < 0)
goto bad;
- fd = open(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
+ fd = afs_open(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR,
+ 0);
if (fd < 0)
goto bad;
} else {
/* Convert handle to file name. */
namei_HandleToName(&name, h);
- fd = open(name.n_path, O_RDWR, 0666);
+ fd = afs_open(name.n_path, O_RDWR, 0666);
return fd;
}
#define LINKTABLE_SHIFT 1 /* log 2 = 1 */
static void
-namei_GetLCOffsetAndIndexFromIno(Inode ino, int *offset, int *index)
+namei_GetLCOffsetAndIndexFromIno(Inode ino, afs_foff_t * offset, int *index)
{
int toff = (int)(ino & NAMEI_VNODEMASK);
int tindex = (int)((ino >> NAMEI_TAGSHIFT) & NAMEI_TAGMASK);
- *offset = (toff << LINKTABLE_SHIFT) + 8; /* * 2 + sizeof stamp */
+ *offset = (afs_foff_t) ((toff << LINKTABLE_SHIFT) + 8); /* * 2 + sizeof stamp */
*index = (tindex << 1) + tindex;
}
namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit)
{
unsigned short row = 0;
- int offset, index;
+ afs_foff_t offset;
+ int index;
namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index);
return -1;
}
- if (lseek(h->fd_fd, offset, SEEK_SET) == -1)
+ if (afs_lseek(h->fd_fd, offset, SEEK_SET) == -1)
goto bad_getLinkByte;
if (read(h->fd_fd, (char *)&row, sizeof(row)) != sizeof(row)) {
GetFreeTag(IHandle_t * ih, int vno)
{
FdHandle_t *fdP;
- int offset;
+ afs_foff_t offset;
int col;
int coldata;
short row;
}
offset = (vno << LINKTABLE_SHIFT) + 8; /* * 2 + sizeof stamp */
- if (lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
+ if (afs_lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
goto badGetFreeTag;
}
coldata = 1 << (col * 3);
row |= coldata;
- if (lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
+ if (afs_lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
goto badGetFreeTag;
}
if (write(fdP->fd_fd, (char *)&row, sizeof(row)) != sizeof(row)) {
int
namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked)
{
- int offset, index;
+ afs_foff_t offset;
+ int index;
unsigned short row;
int junk;
int code = -1;
return -1;
}
}
- if (lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
+ if (afs_lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
errno = EBADF;
goto bad_SetLinkCount;
}
row &= (unsigned short)~junk;
row |= (unsigned short)count;
- if (lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
+ if (afs_lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
errno = EBADF;
goto bad_SetLinkCount;
}
void
VerifyDirPerms(char *path)
{
- struct stat status;
+ struct afs_stat status;
- if (stat(path, &status) < 0) {
+ if (afs_stat(path, &status) < 0) {
Log("Unable to stat %s. Please manually verify mode bits for this"
" directory\n", path);
} else {
{
FILE *fp = (FILE *) - 1;
int ninodes;
- struct stat status;
+ struct afs_stat status;
if (resultFile) {
- fp = fopen(resultFile, "w");
+ fp = afs_fopen(resultFile, "w");
if (!fp) {
Log("Unable to create inode description file %s\n", resultFile);
return -1;
/*
* Paranoia: check that the file is really the right size
*/
- if (stat(resultFile, &status) == -1) {
+ if (afs_stat(resultFile, &status) == -1) {
Log("Unable to successfully stat inode file for %s\n", mountedOn);
return -2;
}
/* Open this handle */
(void)afs_snprintf(path2, sizeof path2, "%s/%s", path1,
dp1->d_name);
- linkHandle.fd_fd = open(path2, O_RDONLY, 0666);
+ linkHandle.fd_fd = afs_open(path2, O_RDONLY, 0666);
info.linkCount =
namei_GetLinkCount(&linkHandle, (Inode) 0, 0);
}
DecodeInode(char *dpath, char *name, struct ViceInodeInfo *info, int volid)
{
char fpath[512];
- struct stat status;
+ struct afs_stat status;
int parm, tag;
(void)strcpy(fpath, dpath);
(void)strcat(fpath, "/");
(void)strcat(fpath, name);
- if (stat(fpath, &status) < 0) {
+ if (afs_stat(fpath, &status) < 0) {
return -1;
}
info->byteCount = status.st_size;
- info->inodeNumber = flipbase64_to_int64(name);
+ info->inodeNumber = (Inode) flipbase64_to_int64(name);
GetOGMFromStat(&status, &parm, &tag);
if ((info->inodeNumber & NAMEI_INODESPECIAL) == NAMEI_INODESPECIAL) {
t_ih.ih_vid = h->ih_vid;
(void)afs_snprintf(oldpath, sizeof oldpath, "%s/%s", dir_name, infoName);
- fd = open(oldpath, O_RDWR, 0);
+ fd = afs_open(oldpath, O_RDWR, 0);
if (fd < 0) {
Log("1 namei_ConvertROtoRWvolume: could not open RO info file: %s\n",
oldpath);
}
t_ih.ih_ino = namei_MakeSpecIno(h->ih_vid, VI_VOLINFO);
namei_HandleToName(&n, &t_ih);
- fd2 = open(n.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
+ fd2 = afs_open(n.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
if (fd2 < 0) {
Log("1 namei_ConvertROtoRWvolume: could not create RW info file: %s\n", n.n_path);
close(fd);
t_ih.ih_ino = namei_MakeSpecIno(h->ih_vid, VI_SMALLINDEX);
namei_HandleToName(&n, &t_ih);
(void)afs_snprintf(newpath, sizeof newpath, "%s/%s", dir_name, smallName);
- fd = open(newpath, O_RDWR, 0);
+ fd = afs_open(newpath, O_RDWR, 0);
if (fd < 0) {
Log("1 namei_ConvertROtoRWvolume: could not open SmallIndex file: %s\n", newpath);
return -1;
t_ih.ih_ino = namei_MakeSpecIno(h->ih_vid, VI_LARGEINDEX);
namei_HandleToName(&n, &t_ih);
(void)afs_snprintf(newpath, sizeof newpath, "%s/%s", dir_name, largeName);
- fd = open(newpath, O_RDWR, 0);
+ fd = afs_open(newpath, O_RDWR, 0);
if (fd < 0) {
Log("1 namei_ConvertROtoRWvolume: could not open LargeIndex file: %s\n", newpath);
return -1;
int p4);
extern FD_t namei_iopen(IHandle_t * h);
extern int namei_irelease(IHandle_t * h);
-int namei_iread(IHandle_t * h, int offset, char *buf, int size);
-int namei_iwrite(IHandle_t * h, int offset, char *buf, int size);
+afs_sfsize_t namei_iread(IHandle_t * h, afs_foff_t offset, char *buf,
+ afs_fsize_t size);
+afs_sfsize_t namei_iwrite(IHandle_t * h, afs_foff_t offset, char *buf,
+ afs_fsize_t size);
extern int namei_dec(IHandle_t * h, Inode ino, int p1);
extern int namei_inc(IHandle_t * h, Inode ino, int p1);
extern int namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit);
#include "salvage.h"
#include "fssync.h"
+#ifdef O_LARGEFILE
+#define afs_stat stat64
+#else /* !O_LARGEFILE */
+#define afs_stat stat
+#endif /* !O_LARGEFILE */
+
/*@printflike@*/ extern void Log(const char *format, ...);
nuke(char *aname, afs_int32 avolid)
{
/* first process the partition containing this junk */
- struct stat tstat;
+ struct afs_stat tstat;
struct ilist *ti, *ni;
register afs_int32 code;
char *tfile;
if (avolid == 0)
return EINVAL;
- code = stat(aname, &tstat);
+ code = afs_stat(aname, &tstat);
if (code) {
printf("volnuke: partition %s does not exist.\n", aname);
return code;
#include <sys/param.h>
#include <sys/types.h>
-#if AFS_HAVE_STATVFS
+#if AFS_HAVE_STATVFS || AFS_HAVE_STATVFS64
#include <sys/statvfs.h>
#endif /* AFS_HAVE_STATVFS */
#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
#endif
#endif
-
#include <rx/xdr.h>
#include <afs/afsint.h>
#include "nfs.h"
#include <jfs/filsys.h>
#endif
+#ifdef O_LARGEFILE
+
+#define afs_stat stat64
+#define afs_open open64
+#define afs_fopen fopen64
+#ifndef AFS_NT40_ENV
+#if AFS_HAVE_STATVFS64
+# define afs_statvfs statvfs64
+#else
+# if AFS_HAVE_STATFS64
+# define afs_statfs statfs64
+#else
+# if AFS_HAVE_STATVFS
+# define afs_statvfs statvfs
+# else
+# define afs_statfs statfs
+# endif /* !AFS_HAVE_STATVFS */
+# endif /* !AFS_HAVE_STATFS64 */
+#endif /* !AFS_HAVE_STATVFS64 */
+#endif /* !AFS_NT40_ENV */
+
+#else /* !O_LARGEFILE */
+
+#define afs_stat stat
+#define afs_open open
+#define afs_fopen fopen
+#ifndef AFS_NT40_ENV
+#if AFS_HAVE_STATVFS
+#define afs_statvfs statvfs
+#else /* !AFS_HAVE_STATVFS */
+#define afs_statfs statfs
+#endif /* !AFS_HAVE_STATVFS */
+#endif /* !AFS_NT40_ENV */
+
+#endif /* !O_LARGEFILE */
+
/*@printflike@*/ extern void Log(const char *format, ...);
int aixlow_water = 8; /* default 8% */
strcat(dp->devName, "Lock");
mkdir(dp->devName, 0700);
strcat(dp->devName, path);
- close(open(dp->devName, O_RDWR | O_CREAT, 0600));
+ close(afs_open(dp->devName, O_RDWR | O_CREAT, 0600));
dp->device = volutil_GetPartitionID(path);
#else
dp->devName = (char *)malloc(strlen(devname) + 1);
int
VCheckPartition(char *part, char *devname)
{
- struct stat status;
+ struct afs_stat status;
#if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV)
char AFSIDatPath[MAXPATHLEN];
#endif
if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
return 0;
}
- if (stat(part, &status) < 0) {
+ if (afs_stat(part, &status) < 0) {
Log("VInitVnodes: Couldn't find file system %s; ignored\n", part);
return 0;
}
char salvpath[MAXPATHLEN];
strcpy(salvpath, part);
strcat(salvpath, "/FORCESALVAGE");
- if (stat(salvpath, &status) == 0) {
+ if (afs_stat(salvpath, &status) == 0) {
Log("VInitVnodes: Found %s; aborting\n", salvpath);
return -1;
}
strcpy(AFSIDatPath, part);
strcat(AFSIDatPath, "/AFSIDat");
#ifdef AFS_NAMEI_ENV
- if (stat(AFSIDatPath, &status) < 0) {
+ if (afs_stat(AFSIDatPath, &status) < 0) {
DIR *dirp;
struct dirent *dp;
closedir(dirp);
}
#else /* AFS_NAMEI_ENV */
- if (stat(AFSIDatPath, &status) == 0) {
+ if (afs_stat(AFSIDatPath, &status) == 0) {
Log("This program is compiled without AFS_NAMEI_ENV, but partition %s seems to contain volumes which use the namei-interface; aborting\n", part);
return -1;
}
#endif
#if defined(AFS_DUX40_ENV) && !defined(AFS_NAMEI_ENV)
- if (status.st_ino != ROOTINO) {
+ if (afs_status.st_ino != ROOTINO) {
Log("%s is not a mounted file system; ignored.\n", part);
return 0;
}
VIsAlwaysAttach(char *part)
{
#ifdef AFS_NAMEI_ENV
- struct stat st;
+ struct afs_stat st;
char checkfile[256];
int ret;
strcat(checkfile, "/");
strcat(checkfile, VICE_ALWAYSATTACH_FILE);
- ret = stat(checkfile, &st);
+ ret = afs_stat(checkfile, &st);
return (ret < 0) ? 0 : 1;
#else /* AFS_NAMEI_ENV */
return 0;
struct mnttab mnt;
FILE *mntfile;
- if (!(mntfile = fopen(MNTTAB, "r"))) {
+ if (!(mntfile = afs_fopen(MNTTAB, "r"))) {
Log("Can't open %s\n", MNTTAB);
perror(MNTTAB);
exit(-1);
* doing this for us.
*/
if (programType == fileServer) {
- struct stat status;
+ struct afs_stat status;
char salvpath[MAXPATHLEN];
strcpy(salvpath, entry.vp_dev);
strcat(salvpath, "\\FORCESALVAGE");
- if (stat(salvpath, &status) == 0) {
+ if (afs_stat(salvpath, &status) == 0) {
Log("VAttachPartitions: Found %s; aborting\n", salvpath);
exit(1);
}
{
int fd, totalblks, free, used, availblks, bsize, code;
int reserved;
-#if AFS_HAVE_STATVFS
- struct statvfs statbuf;
+#ifdef afs_statvfs
+ struct afs_statvfs statbuf;
#else
- struct statfs statbuf;
+ struct afs_statfs statbuf;
#endif
if (dp->flags & PART_DONTUPDATE)
* is syncing every 30 seconds anyway, we only have to keep the disk
* approximately 10% from full--you just can't get the stuff in from
* the net fast enough to worry */
-#if AFS_HAVE_STATVFS
- code = statvfs(dp->name, &statbuf);
+#ifdef afs_statvfs
+ code = afs_statvfs(dp->name, &statbuf);
#else
- code = statfs(dp->name, &statbuf);
+ code = afs_statfs(dp->name, &statbuf);
#endif
if (code < 0) {
Log("statfs of %s failed in VSetPartitionDiskUsage (errno = %d)\n",
totalblks = statbuf.f_blocks;
free = statbuf.f_bfree;
reserved = free - statbuf.f_bavail;
-#if AFS_HAVE_STATVFS
+#ifdef afs_statvfs
bsize = statbuf.f_frsize;
#else
bsize = statbuf.f_bsize;
VOL_UNLOCK}
void
-VAdjustDiskUsage_r(Error * ec, Volume * vp, afs_int32 blocks,
- afs_int32 checkBlocks)
+VAdjustDiskUsage_r(Error * ec, Volume * vp, afs_sfsize_t blocks,
+ afs_sfsize_t checkBlocks)
{
*ec = 0;
/* why blocks instead of checkBlocks in the check below? Otherwise, any check
}
void
-VAdjustDiskUsage(Error * ec, Volume * vp, afs_int32 blocks,
- afs_int32 checkBlocks)
+VAdjustDiskUsage(Error * ec, Volume * vp, afs_sfsize_t blocks,
+ afs_sfsize_t checkBlocks)
{
VOL_LOCK VAdjustDiskUsage_r(ec, vp, blocks, checkBlocks);
VOL_UNLOCK}
int
-VDiskUsage_r(Volume * vp, afs_int32 blocks)
+VDiskUsage_r(Volume * vp, afs_sfsize_t blocks)
{
if (blocks > 0) {
#ifdef AFS_AIX32_ENV
}
int
-VDiskUsage(Volume * vp, afs_int32 blocks)
+VDiskUsage(Volume * vp, afs_sfsize_t blocks)
{
int retVal;
VOL_LOCK retVal = VDiskUsage_r(vp, blocks);
#endif
for (retries = 25; retries; retries--) {
- dp->lock_fd = open(partitionName, code);
+ dp->lock_fd = afs_open(partitionName, code);
if (dp->lock_fd != -1)
break;
if (errno == ENOENT)
#endif
+struct Volume; /* Potentially forward definition */
+
extern struct DiskPartition *DiskPartitionList;
extern struct DiskPartition *VGetPartition();
extern int VAttachPartitions(void);
extern void VSetPartitionDiskUsage(register struct DiskPartition *dp);
extern void VSetPartitionDiskUsage_r(register struct DiskPartition *dp);
extern char *VPartitionPath(struct DiskPartition *p);
-/*extern void VAdjustDiskUsage(Error *ec, Volume *vp, afs_int32 blocks,
- afs_int32 checkBlocks); */
+extern void VAdjustDiskUsage(Error * ec, struct Volume *vp,
+ afs_sfsize_t blocks, afs_sfsize_t checkBlocks);
+extern int VDiskUsage(struct Volume *vp, afs_sfsize_t blocks);
extern void VPrintDiskStats(void);
FDH_REALLYCLOSE(fdP);
return code;
}
- code = FDH_READ(fdP, data, AFS_PAGESIZE);
+ code = FDH_READ(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
if (code != AFS_PAGESIZE) {
if (code < 0)
code = errno;
FDH_REALLYCLOSE(fdP);
return code;
}
- code = FDH_WRITE(fdP, data, AFS_PAGESIZE);
+ code = FDH_WRITE(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
if (code != AFS_PAGESIZE) {
if (code < 0)
code = errno;
*/
struct ViceInodeInfo {
Inode inodeNumber;
- int byteCount;
+ afs_fsize_t byteCount;
int linkCount;
union {
bit32 param[4];
#define Date afs_uint32
+struct Volume; /* Potentially forward definition. */
+
typedef struct ViceLock {
int lockCount;
int lockTime;
vnodes */
#define VAclSize(vnp) (SIZEOF_LARGEDISKVNODE - SIZEOF_SMALLDISKVNODE)
#define VAclDiskSize(v) (SIZEOF_LARGEDISKVNODE - SIZEOF_SMALLDISKVNODE)
-extern int VolumeHashOffset();
-extern int VolumeHashOffset_r();
-extern VInitVnodes();
-extern VInitVnodes_r();
-extern Vnode *VGetVnode();
-extern Vnode *VGetVnode_r();
-extern void VPutVnode();
-extern void VPutVnode_r();
-extern VVnodeWriteToRead();
-extern VVnodeWriteToRead_r();
-extern Vnode *VAllocVnode();
-extern Vnode *VAllocVnode_r();
-extern VFreeVnode();
-extern VFreeVnode_r();
+/*extern int VolumeHashOffset(); */
+extern int VolumeHashOffset_r(void);
+extern VInitVnodes(VnodeClass class, int nVnodes);
+/*extern VInitVnodes_r();*/
+extern Vnode *VGetVnode(Error * ec, struct Volume *vp, VnodeId vnodeNumber,
+ int locktype);
+extern Vnode *VGetVnode_r(Error * ec, struct Volume *vp, VnodeId vnodeNumber,
+ int locktype);
+extern void VPutVnode(Error * ec, register Vnode * vnp);
+extern void VPutVnode_r(Error * ec, register Vnode * vnp);
+extern VVnodeWriteToRead(Error * ec, register Vnode * vnp);
+extern VVnodeWriteToRead_r(Error * ec, register Vnode * vnp);
+extern Vnode *VAllocVnode(Error * ec, struct Volume *vp, VnodeType type);
+extern Vnode *VAllocVnode_r(Error * ec, struct Volume *vp, VnodeType type);
+/*extern VFreeVnode();*/
+extern Vnode *VGetFreeVnode_r(struct VnodeClassInfo *vcp);
#include <dirent.h>
+#ifdef O_LARGEFILE
+#define afs_stat stat64
+#define afs_fstat fstat64
+#define afs_open open64
+#else /* !O_LARGEFILE */
+#define afs_stat stat
+#define afs_fstat fstat
+#define afs_open open
+#endif /* !O_LARGEFILE */
+
int DumpVnodes = 0; /* Dump everything, i.e. summary of all vnodes */
int DumpInodeNumber = 0; /* Dump inode numbers with vnodes */
int DumpDate = 0; /* Dump vnode date (server modify date) with vnode */
Volume *AttachVolume(struct DiskPartition *dp, char *volname,
register struct VolumeHeader *header);
#if defined(AFS_NAMEI_ENV)
-void PrintVnode(int offset, VnodeDiskObject * vnode, int vnodeNumber,
+void PrintVnode(int offset, VnodeDiskObject * vnode, VnodeId vnodeNumber,
Inode ino, Volume * vp);
#else
-void PrintVnode(int offset, VnodeDiskObject * vnode, int vnodeNumber,
+void PrintVnode(int offset, VnodeDiskObject * vnode, VnodeId vnodeNumber,
Inode ino);
#endif
void PrintVnodes(Volume * vp, VnodeClass class);
char *
date(time_t date)
{
- static char results[8][100];
+#define MAX_DATE_RESULT 100
+ static char results[8][MAX_DATE_RESULT];
static next;
struct tm *tm = localtime(&date);
char buf[32];
(void)strftime(buf, 32, "%Y/%m/%d.%H:%M:%S", tm); /* NT does not have %T */
- sprintf(results[next = (next + 1) & 7], "%lu (%s)", (unsigned long)date,
- buf);
+ (void)afs_snprintf(results[next = (next + 1) & 7], MAX_DATE_RESULT,
+ "%lu (%s)", (unsigned long)date, buf);
return results[next];
}
exit(1);
}
}
- sprintf(name1, VFORMAT, (unsigned long)volumeId);
+ (void)afs_snprintf(name1, sizeof name1, VFORMAT,
+ (unsigned long)volumeId);
if (dsizeOnly && !saveinodes)
printf
("Volume-Id\t Volsize Auxsize Inodesize AVolsize SizeDiff (VolName)\n");
{
struct VolumeHeader header;
struct VolumeDiskHeader diskHeader;
- struct stat status, stat;
+ struct afs_stat status, stat;
register int fd;
Volume *vp;
IHandle_t *ih;
} else {
afs_int32 n;
- (void)sprintf(headerName, "%s/%s", VPartitionPath(dp), name);
- if ((fd = open(headerName, O_RDONLY)) == -1
- || fstat(fd, &status) == -1) {
+ (void)afs_snprintf(headerName, sizeof headerName, "%s/%s",
+ VPartitionPath(dp), name);
+ if ((fd = afs_open(headerName, O_RDONLY)) == -1
+ || afs_fstat(fd, &status) == -1) {
printf("Volinfo: Cannot read volume header %s\n", name);
close(fd);
exit(1);
int size = 0;
int code;
- if (fstat(fd, &stat) == -1) {
+ if (afs_fstat(fd, &stat) == -1) {
perror("stat");
exit(1);
}
}
-main(argc, argv)
- char **argv;
+main(int argc, char **argv)
{
register struct cmd_syndesc *ts;
afs_int32 code;
*mtime = NT_date(&fi.ftLastWriteTime);
*atime = NT_date(&fi.ftLastAccessTime);
#else
- struct stat status;
- if (fstat(fd, &status) == -1) {
+ struct afs_stat status;
+ if (afs_fstat(fd, &status) == -1) {
printf("fstat failed %d\n", errno);
exit(1);
}
PrintInode(NULL, ino), errno);
continue;
}
- sprintf(nfile, "TmpInode.%s", PrintInode(NULL, ino));
- ofd = open(nfile, O_CREAT | O_RDWR | O_TRUNC, 0600);
+ (void)afs_snprintf(nfile, sizeof nfile, "TmpInode.%s",
+ PrintInode(NULL, ino));
+ ofd = afs_open(nfile, O_CREAT | O_RDWR | O_TRUNC, 0600);
if (ofd < 0) {
printf("Can't create file %s; error %d (ignored)\n",
nfile, errno);
#if defined(AFS_NAMEI_ENV)
void
-PrintVnode(int offset, VnodeDiskObject * vnode, int vnodeNumber, Inode ino,
- Volume * vp)
+PrintVnode(int offset, VnodeDiskObject * vnode, VnodeId vnodeNumber,
+ Inode ino, Volume * vp)
#else
void
-PrintVnode(int offset, VnodeDiskObject * vnode, int vnodeNumber, Inode ino)
+PrintVnode(int offset, VnodeDiskObject * vnode, VnodeId vnodeNumber,
+ Inode ino)
#endif
{
#if defined(AFS_NAMEI_ENV)
if (orphaned && (fileLength == 0 || vnode->parent || !offset))
return;
printf
- ("%10d Vnode %u.%u.%u cloned: %d, length: %llu linkCount: %d parent: %u",
+ ("%10d Vnode %u.%u.%u cloned: %u, length: %llu linkCount: %d parent: %u",
offset, vnodeNumber, vnode->uniquifier, vnode->dataVersion,
vnode->cloned, (afs_uintmax_t) fileLength, vnode->linkCount,
vnode->parent);
#include <pthread.h>
#endif
+/*@+fcnmacros +macrofcndecl@*/
+#ifdef O_LARGEFILE
+#ifdef S_SPLINT_S
+extern off64_t afs_lseek(int FD, off64_t O, int F);
+#endif /*S_SPLINT_S */
+#define afs_lseek(FD, O, F) lseek64(FD, (off64_t) (O), F)
+#define afs_stat stat64
+#define afs_fstat fstat64
+#define afs_open open64
+#define afs_fopen fopen64
+#else /* !O_LARGEFILE */
+#ifdef S_SPLINT_S
+extern off_t afs_lseek(int FD, off_t O, int F);
+#endif /*S_SPLINT_S */
+#define afs_lseek(FD, O, F) lseek(FD, (off_t) (O), F)
+#define afs_stat stat
+#define afs_fstat fstat
+#define afs_open open
+#define afs_fopen fopen
+#endif /* !O_LARGEFILE */
+/*@=fcnmacros =macrofcndecl@*/
+
#ifdef AFS_OSF_ENV
extern void *calloc();
#endif
* 0 after scanning all directories */
unsigned salvaged:1; /* Set if this directory vnode has already been salvaged. */
unsigned todelete:1; /* Set if this vnode is to be deleted (should not be claimed) */
- afs_uint32 blockCount;
+ afs_fsize_t blockCount;
/* Number of blocks (1K) used by this vnode,
* approximately */
VnodeId parent; /* parent in vnode */
}
#else
salvageLock =
- open(AFSDIR_SERVER_SLVGLOCK_FILEPATH, O_CREAT | O_RDWR, 0666);
+ afs_open(AFSDIR_SERVER_SLVGLOCK_FILEPATH, O_CREAT | O_RDWR, 0666);
assert(salvageLock >= 0);
#ifdef AFS_DARWIN_ENV
if (flock(salvageLock, LOCK_EX) == -1) {
/* Check if the given inode is the root of the filesystem. */
#ifndef AFS_SGI_XFS_IOPS_ENV
int
-IsRootInode(struct stat *status)
+IsRootInode(struct afs_stat *status)
{
/*
* The root inode is not a fixed value in XFS partitions. So we need to
"%s.%d",
AFSDIR_SERVER_SLVGLOG_FILEPATH,
jobs[startjob]->jobnumb);
- logFile = fopen(logFileName, "w");
+ logFile = afs_fopen(logFileName, "w");
}
if (!logFile)
logFile = stdout;
for (i = 0; i < jobcount; i++) {
(void)afs_snprintf(logFileName, sizeof logFileName, "%s.%d",
AFSDIR_SERVER_SLVGLOG_FILEPATH, i);
- if ((passLog = fopen(logFileName, "r"))) {
+ if ((passLog = afs_fopen(logFileName, "r"))) {
while (fgets(buf, sizeof(buf), passLog)) {
fputs(buf, logFile);
}
_open_osfhandle((long)nt_open(inodeListPath, O_RDWR, 0), O_RDWR);
nt_unlink(inodeListPath); /* NT's crt unlink won't if file is open. */
#else
- inodeFd = open(inodeListPath, O_RDONLY);
+ inodeFd = afs_open(inodeListPath, O_RDONLY);
unlink(inodeListPath);
#endif
if (inodeFd == -1)
int
GetInodeSummary(char *path, VolumeId singleVolumeNumber)
{
- struct stat status;
+ struct afs_stat status;
int forceSal, err;
struct ViceInodeInfo *ip;
struct InodeSummary summary;
Log("***Forced salvage of all volumes on this partition***\n");
ForceSalvage = 1;
}
- inodeFd = open(path, O_RDWR);
- if (inodeFd == -1 || fstat(inodeFd, &status) == -1) {
+ inodeFd = afs_open(path, O_RDWR);
+ if (inodeFd == -1 || afs_fstat(inodeFd, &status) == -1) {
unlink(path);
Abort("No inode description file for \"%s\"; not salvaged\n", dev);
}
(void)afs_snprintf(summaryFileName, sizeof summaryFileName,
"%s/salvage.temp.%d", tdir, getpid());
#endif
- summaryFile = fopen(summaryFileName, "a+");
+ summaryFile = afs_fopen(summaryFileName, "a+");
if (summaryFile == NULL) {
close(inodeFd);
unlink(path);
Abort("Unable to read inode table; %s not salvaged\n", dev);
}
qsort(ip, nInodes, sizeof(struct ViceInodeInfo), CompareInodes);
- if (lseek(inodeFd, 0, SEEK_SET) == -1
+ if (afs_lseek(inodeFd, 0, SEEK_SET) == -1
|| write(inodeFd, ip, status.st_size) != status.st_size) {
fclose(summaryFile);
close(inodeFd);
Exit(1); /* salvage of this partition aborted */
}
}
- assert(fstat(fileno(summaryFile), &status) != -1);
+ assert(afs_fstat(fileno(summaryFile), &status) != -1);
if (status.st_size != 0) {
int ret;
inodeSummary = (struct InodeSummary *)malloc(status.st_size);
assert(inodeSummary != NULL);
/* For GNU we need to do lseek to get the file pointer moved. */
- assert(lseek(fileno(summaryFile), 0, SEEK_SET) == 0);
+ assert(afs_lseek(fileno(summaryFile), 0, SEEK_SET) == 0);
ret = read(fileno(summaryFile), inodeSummary, status.st_size);
assert(ret == status.st_size);
}
p = strrchr(dp->d_name, '.');
if (p != NULL && strcmp(p, VHDREXT) == 0) {
int fd;
- if ((fd = open(dp->d_name, O_RDONLY)) != -1
+ if ((fd = afs_open(dp->d_name, O_RDONLY)) != -1
&& read(fd, (char *)&diskHeader, sizeof(diskHeader))
== sizeof(diskHeader)
&& diskHeader.stamp.magic == VOLUMEHEADERMAGIC) {
if (p != NULL && strcmp(p, VHDREXT) == 0) {
int error = 0;
int fd;
- if ((fd = open(dp->d_name, O_RDONLY)) == -1
+ if ((fd = afs_open(dp->d_name, O_RDONLY)) == -1
|| read(fd, &diskHeader, sizeof(diskHeader))
!= sizeof(diskHeader)
|| diskHeader.stamp.magic != VOLUMEHEADERMAGIC) {
if (!singleVolumeNumber
|| (vsp->header.id == singleVolumeNumber
|| vsp->header.parent == singleVolumeNumber)) {
- sprintf(nameShouldBe, VFORMAT, vsp->header.id);
+ (void)afs_snprintf(nameShouldBe, sizeof nameShouldBe,
+ VFORMAT, vsp->header.id);
if (singleVolumeNumber)
AskOffline(vsp->header.id);
if (strcmp(nameShouldBe, dp->d_name)) {
allInodes = inodes - isp->index; /* this would the base of all the inodes
* for the partition, if all the inodes
* had been read into memory */
- assert(lseek(inodeFd, isp->index * sizeof(struct ViceInodeInfo), SEEK_SET)
- != -1);
+ assert(afs_lseek
+ (inodeFd, isp->index * sizeof(struct ViceInodeInfo),
+ SEEK_SET) != -1);
assert(read(inodeFd, inodes, size) == size);
/* Don't try to salvage a read write volume if there isn't one on this
Log("No header file for volume %u; %screating %s/%s\n",
isp->volumeId, (Testing ? "it would have been " : ""),
fileSysPathName, name);
- headerFd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0644);
+ headerFd = afs_open(name, O_RDWR | O_CREAT | O_TRUNC, 0644);
assert(headerFd != -1);
isp->volSummary = (struct VolumeSummary *)
malloc(sizeof(struct VolumeSummary));
if (check)
return -1;
- headerFd = open(name, O_RDWR | O_TRUNC, 0644);
+ headerFd = afs_open(name, O_RDWR | O_TRUNC, 0644);
assert(headerFd != -1);
}
}
if (ip->inodeNumber != VNDISK_GET_INO(vnode)) {
if (check) {
if (!Showmode) {
- Log("Vnode %d: inode number incorrect (is %s should be %s). FileSize=%d\n", vnodeNumber, PrintInode(stmp1, VNDISK_GET_INO(vnode)), PrintInode(stmp2, ip->inodeNumber), ip->byteCount);
+ Log("Vnode %d: inode number incorrect (is %s should be %s). FileSize=%llu\n", vnodeNumber, PrintInode(stmp1, VNDISK_GET_INO(vnode)), PrintInode(stmp2, ip->inodeNumber), (afs_uintmax_t) ip->byteCount);
}
VNDISK_SET_INO(vnode, ip->inodeNumber);
err = -1;
if (check) {
if (VNDISK_GET_INO(vnode)) {
if (!Showmode) {
- Log("Vnode %d (unique %d): corresponding inode %s is missing\n", vnodeNumber, vnode->uniquifier, PrintInode(NULL, VNDISK_GET_INO(vnode)));
+ Log("Vnode %d (unique %u): corresponding inode %s is missing\n", vnodeNumber, vnode->uniquifier, PrintInode(NULL, VNDISK_GET_INO(vnode)));
}
} else {
if (!Showmode)
- Log("Vnode %d (unique %d): bad directory vnode (no inode number listed)\n", vnodeNumber, vnode->uniquifier);
+ Log("Vnode %d (unique %u): bad directory vnode (no inode number listed)\n", vnodeNumber, vnode->uniquifier);
}
err = -1;
goto zooks;
}
if (VNDISK_GET_INO(vnode)) {
if (!Showmode) {
- Log("Vnode %d (unique %d): corresponding inode %s is missing; vnode deleted, vnode mod time=%s", vnodeNumber, vnode->uniquifier, PrintInode(NULL, VNDISK_GET_INO(vnode)), ctime((time_t *) & (vnode->serverModifyTime)));
+ Log("Vnode %d (unique %u): corresponding inode %s is missing; vnode deleted, vnode mod time=%s", vnodeNumber, vnode->uniquifier, PrintInode(NULL, VNDISK_GET_INO(vnode)), ctime((time_t *) & (vnode->serverModifyTime)));
}
} else {
if (!Showmode)
- Log("Vnode %d (unique %d): bad directory vnode (no inode number listed); vnode deleted, vnode mod time=%s", vnodeNumber, vnode->uniquifier, ctime((time_t *) & (vnode->serverModifyTime)));
+ Log("Vnode %d (unique %u): bad directory vnode (no inode number listed); vnode deleted, vnode mod time=%s", vnodeNumber, vnode->uniquifier, ctime((time_t *) & (vnode->serverModifyTime)));
}
memset(vnode, 0, vcp->diskSize);
vnodeChanged = 1;
{
register struct ViceInodeInfo *ip;
struct ViceInodeInfo *buf;
- struct stat status;
+ struct afs_stat status;
register nInodes;
- assert(fstat(inodeFd, &status) == 0);
+ assert(afs_fstat(inodeFd, &status) == 0);
buf = (struct ViceInodeInfo *)malloc(status.st_size);
assert(buf != NULL);
nInodes = status.st_size / sizeof(struct ViceInodeInfo);
strcat(oldSlvgLog, ".old");
if (!logFile) {
renamefile(AFSDIR_SERVER_SLVGLOG_FILEPATH, oldSlvgLog);
- logFile = fopen(AFSDIR_SERVER_SLVGLOG_FILEPATH, "a");
+ logFile = afs_fopen(AFSDIR_SERVER_SLVGLOG_FILEPATH, "a");
if (!logFile) { /* still nothing, use stdout */
logFile = stdout;
rewind(logFile);
fclose(logFile);
- logFile = fopen(AFSDIR_SERVER_SLVGLOG_FILEPATH, "r");
+ logFile = afs_fopen(AFSDIR_SERVER_SLVGLOG_FILEPATH, "r");
if (!logFile)
printf("Can't read %s, exiting\n", AFSDIR_SERVER_SLVGLOG_FILEPATH);
int
UseTheForceLuke(char *path)
{
- struct stat force;
+ struct afs_stat force;
assert(chdir(path) != -1);
- return (stat("FORCESALVAGE", &force) == 0);
+ return (afs_stat("FORCESALVAGE", &force) == 0);
}
#else
/*
/* Open logFile */
(void)sprintf(logname, "%s.%d", AFSDIR_SERVER_SLVGLOG_FILEPATH,
myjob.cj_number);
- logFile = fopen(logname, "w");
+ logFile = afs_fopen(logname, "w");
if (!logFile)
logFile = stdout;
#include <unistd.h>
#endif
+#ifdef O_LARGEFILE
+#define afs_stat stat64
+#define afs_fstat fstat64
+#define afs_open open64
+#else /* !O_LARGEFILE */
+#define afs_stat stat
+#define afs_fstat fstat
+#define afs_open open
+#endif /* !O_LARGEFILE */
+
#ifdef AFS_PTHREAD_ENV
pthread_mutex_t vol_glock_mutex;
pthread_mutex_t vol_attach_mutex;
/*@printflike@*/ extern void Log(const char *format, ...);
/* Forward declarations */
-static Volume *attach2();
-static void FreeVolume();
-static void VScanUpdateList();
-static void InitLRU();
-static int GetVolumeHeader();
-static void ReleaseVolumeHeader();
-static void FreeVolumeHeader();
-static void AddVolumeToHashTable();
-static void DeleteVolumeFromHashTable();
+static Volume *attach2(Error * ec, char *path,
+ register struct VolumeHeader *header,
+ struct DiskPartition *partp, int isbusy);
+static void FreeVolume(Volume * vp);
+static void VScanUpdateList(void);
+static void InitLRU(int howMany);
+static int GetVolumeHeader(register Volume * vp);
+static void ReleaseVolumeHeader(register struct volHeader *hd);
+static void FreeVolumeHeader(register Volume * vp);
+static void AddVolumeToHashTable(register Volume * vp, int hashid);
+static void DeleteVolumeFromHashTable(register Volume * vp);
static int VHold(Volume * vp);
static int VHold_r(Volume * vp);
static void GetBitmap(Error * ec, Volume * vp, VnodeClass class);
{
register Volume *vp;
int fd, n;
- struct stat status;
+ struct afs_stat status;
struct VolumeDiskHeader diskHeader;
struct VolumeHeader iheader;
struct DiskPartition *partp;
strcpy(path, VPartitionPath(partp));
strcat(path, "/");
strcat(path, name);
- VOL_UNLOCK if ((fd = open(path, O_RDONLY)) == -1
- || fstat(fd, &status) == -1) {
+ VOL_UNLOCK if ((fd = afs_open(path, O_RDONLY)) == -1
+ || afs_fstat(fd, &status) == -1) {
Log("VAttachVolume: Failed to open %s (errno %d)\n", path, errno);
if (fd > -1)
close(fd);
*ec = 0;
name[0] = '/';
- sprintf(&name[1], VFORMAT, volumeId);
+ (void)afs_snprintf(&name[1], (sizeof name) - 1, VFORMAT, volumeId);
for (dp = DiskPartitionList; dp; dp = dp->next) {
- struct stat status;
+ struct afs_stat status;
strcpy(path, VPartitionPath(dp));
strcat(path, name);
- if (stat(path, &status) == 0) {
+ if (afs_stat(path, &status) == 0) {
strcpy(partition, dp->name);
found = 1;
break;
char *
VolumeExternalName(VolumeId volumeId)
{
- static char name[15];
- sprintf(name, VFORMAT, volumeId);
+ static char name[VMAXPATHLEN];
+ (void)afs_snprintf(name, sizeof name, VFORMAT, volumeId);
return name;
}
int nSmallVnodes, int connect, int volcache);
extern void DiskToVolumeHeader(VolumeHeader_t * h, VolumeDiskHeader_t * dh);
extern void VolumeHeaderToDisk(VolumeDiskHeader_t * dh, VolumeHeader_t * h);
+extern void VTakeOffline_r(register Volume * vp);
+extern void VTakeOffline(register Volume * vp);
/* Naive formula relating number of file size to number of 1K blocks in file */
/* Note: we charge 1 block for 0 length files so the user can't store
an inifite number of them; for most files, we give him the inode, vnode,
and indirect block overhead, for FREE! */
-#define nBlocks(bytes) ((bytes) == 0? 1: ((bytes)+1023)/1024)
+#define nBlocks(bytes) ((afs_sfsize_t)((bytes) == 0? 1: (((afs_sfsize_t)(bytes))+1023)/1024))
/* Client process id -- file server sends a Check volumes signal back to the client at this pid */
#define CLIENTPID "/vice/vol/clientpid"
#include <strings.h>
#endif
+#ifdef O_LARGEFILE
+#define afs_open open64
+#else /* !O_LARGEFILE */
+#define afs_open open
+#endif /* !O_LARGEFILE */
/*@printflike@*/ extern void Log(const char *format, ...);
-void AssignVolumeName();
-void AssignVolumeName_r();
-void ClearVolumeStats();
-void ClearVolumeStats_r();
+void AssignVolumeName(register VolumeDiskData * vol, char *name, char *ext);
+void AssignVolumeName_r(register VolumeDiskData * vol, char *name, char *ext);
+void ClearVolumeStats(register VolumeDiskData * vol);
+void ClearVolumeStats_r(register VolumeDiskData * vol);
#define nFILES (sizeof (stuff)/sizeof(struct stuff))
(void)afs_snprintf(headerName, sizeof headerName, VFORMAT, vol.id);
(void)afs_snprintf(volumePath, sizeof volumePath, "%s/%s",
VPartitionPath(partition), headerName);
- fd = open(volumePath, O_CREAT | O_EXCL | O_WRONLY, 0600);
+ fd = afs_open(volumePath, O_CREAT | O_EXCL | O_WRONLY, 0600);
if (fd == -1) {
if (errno == EEXIST) {
Log("VCreateVolume: Header file %s already exists!\n",
#include "volser.h"
#include "volint.h"
+#ifndef AFS_NT40_ENV
+#ifdef O_LARGEFILE
+#define afs_stat stat64
+#define afs_fstat fstat64
+#else /* !O_LARGEFILE */
+#define afs_stat stat
+#define afs_fstat fstat
+#endif /* !O_LARGEFILE */
+#endif /* !AFS_NT40_ENV */
+
/*@printflike@*/ extern void Log(const char *format, ...);
extern int DoLogging;
static int ReadVnodes(register struct iod *iodp, Volume * vp, int incremental,
afs_int32 * Lbuf, afs_int32 s1, afs_int32 * Sbuf,
afs_int32 s2, afs_int32 delo);
-static bit32 volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP,
- Error * status);
+static afs_fsize_t volser_WriteFile(int vn, struct iod *iodp,
+ FdHandle_t * handleP, int tag,
+ Error * status);
static int SizeDumpDumpHeader(register struct iod *iodp, register Volume * vp,
afs_int32 fromtime,
}
static int
-DumpFile(struct iod *iodp, char tag, int vnode, FdHandle_t * handleP)
+DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
{
int code = 0, lcode = 0, error = 0;
afs_int32 pad = 0, offset;
- int n, nbytes, howMany, howBig;
+ afs_sfsize_t n, nbytes, howMany, howBig;
byte *p;
- struct stat status;
- int size;
+#ifndef AFS_NT40_ENV
+ struct afs_stat status;
+#endif
+ afs_sfsize_t size;
#ifdef AFS_AIX_ENV
#include <sys/statfs.h>
struct statfs tstatfs;
howMany = 4096;
#else
- fstat(handleP->fd_fd, &status);
+ afs_fstat(handleP->fd_fd, &status);
howBig = status.st_size;
#ifdef AFS_AIX_ENV
size = FDH_SIZE(handleP);
- code = DumpInt32(iodp, tag, size);
+#ifdef AFS_LARGEFILE_ENV
+ {
+ afs_uint32 hi, lo;
+ SplitInt64(size, hi, lo);
+ if (hi == 0L) {
+ code = DumpInt32(iodp, 'f', lo);
+ } else {
+ code = DumpDouble(iodp, 'h', hi, lo);
+ }
+ }
+#else /* !AFS_LARGEFILE_ENV */
+ code = DumpInt32(iodp, 'f', size);
+#endif /* !AFS_LARGEFILE_ENV */
if (code) {
return VOLSERDUMPERROR;
}
IH_RELEASE(ihP);
return VOLSERREAD_DUMPERROR;
}
- code = DumpFile(iodp, 'f', vnodeNumber, fdP);
+ code = DumpFile(iodp, vnodeNumber, fdP);
FDH_CLOSE(fdP);
IH_RELEASE(ihP);
}
VAclDiskSize(vnode));
acl_NtohACL(VVnodeDiskACL(vnode));
break;
+#ifdef AFS_LARGEFILE_ENV
+ case 'h':
+#endif
case 'f':{
Inode ino;
Error error;
return VOLSERREAD_DUMPERROR;
}
vnodeLength =
- volser_WriteFile(vnodeNumber, iodp, fdP, &error);
+ volser_WriteFile(vnodeNumber, iodp, fdP, tag, &error);
VNDISK_SET_LEN(vnode, vnodeLength);
FDH_REALLYCLOSE(fdP);
IH_RELEASE(tmpH);
* needing to read an ungetc'd character, since the ReadInt32 will have read
* it instead.
*/
-static bit32
-volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP,
+static afs_fsize_t
+volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP, int tag,
Error * status)
{
afs_int32 code;
- afs_uint32 filesize;
- bit32 written = 0;
+ afs_fsize_t filesize;
+ afs_fsize_t written = 0;
register afs_uint32 size = 8192;
- register afs_uint32 nbytes;
+ register afs_fsize_t nbytes;
unsigned char *p;
*status = 0;
+#ifdef AFS_64BIT_ENV
+ {
+ afs_uint32 filesize_high = 0L, filesize_low = 0L;
+#ifdef AFS_LARGEFILE_ENV
+ if (tag == 'h') {
+ if (!ReadInt32(iodp, &filesize_high)) {
+ *status = 1;
+ return 0;
+ }
+ }
+#endif /* !AFS_LARGEFILE_ENV */
+ if (!ReadInt32(iodp, &filesize_low)) {
+ *status = 1;
+ return 0;
+ }
+ FillInt64(filesize, filesize_high, filesize_low);
+ }
+#else /* !AFS_64BIT_ENV */
if (!ReadInt32(iodp, &filesize)) {
*status = 1;
return (0);
}
+#endif /* !AFS_64BIT_ENV */
p = (unsigned char *)malloc(size);
if (p == NULL) {
*status = 2;
char
readdata(buffer, size)
char *buffer;
- afs_int32 size;
+ afs_sfsize_t size;
{
int code;
afs_int32 s;
if (!buffer) {
while (size > 0) {
- s = ((size > BUFSIZE) ? BUFSIZE : size);
+ s = (afs_int32) ((size > BUFSIZE) ? BUFSIZE : size);
code = fread(buf, 1, s, dumpfile);
if (code != s)
fprintf(stderr, "Code = %d; Errno = %d\n", code, errno);
} entries[100];
} acl;
#endif
- afs_int32 dataSize;
+ afs_sfsize_t dataSize;
};
#define MAXNAMELEN 256
readdata(vn.acl, 192); /* Skip ACL data */
break;
+#ifdef AFS_LARGEFILE_ENV
+ case 'h':
+ {
+ afs_uint32 hi, lo;
+ hi = ntohl(readvalue(4));
+ lo = ntohl(readvalue(4));
+ FillInt64(vn.dataSize, hi, lo);
+ }
+ goto common_vnode;
+#endif /* !AFS_LARGEFILE_ENV */
+
case 'f':
vn.dataSize = ntohl(readvalue(4));
+ common_vnode:
/* parentdir is the name of this dir's vnode-file-link
* or this file's parent vnode-file-link.
* "./AFSDir-<#>". It's a symbolic link to its real dir.
*/
int fid;
int lfile;
- afs_int32 size, s;
+ afs_sfsize_t size, s;
/* Check if its vnode-file-link exists. If not,
* then the file will be an orphaned file.
fid = open(filename, (O_CREAT | O_WRONLY | O_TRUNC), mode);
size = vn.dataSize;
while (size > 0) {
- s = ((size > BUFSIZE) ? BUFSIZE : size);
+ s = (afs_int32) ((size > BUFSIZE) ? BUFSIZE : size);
code = fread(buf, 1, s, dumpfile);
if (code > 0) {
(void)write(fid, buf, code);