mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 15:30:14 +00:00
large-file-support-20030808
FIXES 1493 large file support in the fileserver, again
This commit is contained in:
parent
0e49bd804a
commit
08db75c196
@ -113,11 +113,26 @@ RCSID
|
||||
#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 */
|
||||
|
||||
@ -198,22 +213,22 @@ extern int CEs, CEBlocks;
|
||||
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 */
|
||||
);
|
||||
|
||||
@ -584,7 +599,7 @@ GetRights(struct client *client, struct acl_accessList *ACL,
|
||||
|
||||
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);
|
||||
@ -1018,7 +1033,8 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
|
||||
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 */
|
||||
@ -1072,7 +1088,7 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
|
||||
length = COPYBUFFSIZE;
|
||||
size -= COPYBUFFSIZE;
|
||||
} else {
|
||||
length = size;
|
||||
length = (int)size;
|
||||
size = 0;
|
||||
}
|
||||
rdlen = FDH_READ(targFdP, buff, length);
|
||||
@ -1298,7 +1314,7 @@ Update_ParentVnodeStatus(Vnode * parentptr, Volume * volptr, DirHandle * dir,
|
||||
#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
|
||||
@ -1525,7 +1541,8 @@ SetCallBackStruct(afs_uint32 CallBackTime, struct AFSCallBack *CallBack)
|
||||
* 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;
|
||||
@ -1559,7 +1576,7 @@ AdjustDiskUsage(Volume * volptr, afs_int32 length, afs_int32 checkLength)
|
||||
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;
|
||||
@ -1570,8 +1587,8 @@ Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -2039,8 +2056,9 @@ GetStatus(Vnode * targetptr, AFSFetchStatus * status, afs_int32 rights,
|
||||
|
||||
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)
|
||||
{
|
||||
@ -2061,8 +2079,8 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
|
||||
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 */
|
||||
|
||||
@ -2284,13 +2302,15 @@ SRXAFS_FetchData64(struct rx_call * acall, struct AFSFid * Fid, afs_int64 Pos,
|
||||
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;
|
||||
@ -2852,8 +2872,8 @@ SRXAFS_FetchStatus(struct rx_call * acall, struct AFSFid * Fid,
|
||||
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 */
|
||||
@ -2873,8 +2893,8 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *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 */
|
||||
|
||||
/*
|
||||
@ -3092,16 +3112,18 @@ SRXAFS_StoreData64(struct rx_call * acall, struct AFSFid * Fid,
|
||||
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;
|
||||
@ -3968,7 +3990,8 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
|
||||
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 =
|
||||
@ -4663,7 +4686,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
|
||||
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);
|
||||
@ -6398,7 +6421,7 @@ SRXAFS_GetRootVolume(struct rx_call * acall, char **VolumeName)
|
||||
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 {
|
||||
@ -6583,10 +6606,11 @@ SRXAFS_GetTime(struct rx_call * acall, afs_uint32 * Seconds,
|
||||
|
||||
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 */
|
||||
)
|
||||
{
|
||||
@ -6601,9 +6625,9 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
|
||||
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
|
||||
@ -6616,15 +6640,20 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
|
||||
(*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);
|
||||
@ -6634,6 +6663,8 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
|
||||
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;
|
||||
@ -6642,12 +6673,17 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
|
||||
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 */
|
||||
@ -6655,31 +6691,32 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
|
||||
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
|
||||
/*
|
||||
@ -6688,14 +6725,14 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
|
||||
*/
|
||||
(*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);
|
||||
@ -6730,7 +6767,8 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
|
||||
} /*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;
|
||||
@ -6748,9 +6786,9 @@ GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc, int *size)
|
||||
*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;
|
||||
}
|
||||
|
||||
@ -6782,14 +6820,15 @@ GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc, int *size)
|
||||
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
|
||||
@ -6798,13 +6837,13 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
|
||||
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;
|
||||
@ -6828,9 +6867,9 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
|
||||
/* 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 {
|
||||
@ -6921,6 +6960,10 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
|
||||
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)
|
||||
@ -6952,17 +6995,20 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
|
||||
(*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;
|
||||
@ -6971,17 +7017,17 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
|
||||
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:
|
||||
@ -6992,7 +7038,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
|
||||
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
|
||||
@ -7002,7 +7048,8 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
|
||||
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);
|
||||
|
@ -1677,7 +1677,7 @@ h_PrintClient(register struct host *host, int held, StreamHandle_t * file)
|
||||
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) {
|
||||
@ -1692,25 +1692,25 @@ h_PrintClient(register struct host *host, int held, StreamHandle_t * file)
|
||||
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;
|
||||
@ -1742,7 +1742,7 @@ h_PrintClients()
|
||||
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));
|
||||
@ -1767,29 +1767,29 @@ h_DumpHost(register struct host *host, int held, StreamHandle_t * file)
|
||||
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;
|
||||
@ -1814,7 +1814,7 @@ h_DumpHosts()
|
||||
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));
|
||||
|
@ -95,6 +95,17 @@ RCSID
|
||||
#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();
|
||||
@ -209,11 +220,11 @@ static void
|
||||
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);
|
||||
@ -299,7 +310,7 @@ ResetCheckDescriptors(void)
|
||||
#if defined(AFS_PTHREAD_ENV)
|
||||
softsig_signal(SIGTERM, CheckDescriptors_Signal);
|
||||
#else
|
||||
signal(SIGTERM, CheckDescriptors_Signal);
|
||||
(void)signal(SIGTERM, CheckDescriptors_Signal);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -355,12 +366,12 @@ static void
|
||||
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 */
|
||||
@ -1050,17 +1061,17 @@ ParseArgs(int argc, char *argv[])
|
||||
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;
|
||||
@ -1221,15 +1232,15 @@ ReadSysIdFile()
|
||||
{
|
||||
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));
|
||||
@ -1297,18 +1308,18 @@ WriteSysIdFile()
|
||||
{
|
||||
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,
|
||||
@ -1504,7 +1515,7 @@ main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
#ifndef AFS_QUIETFS_ENV
|
||||
console = fopen("/dev/console", "w");
|
||||
console = afs_fopen("/dev/console", "w");
|
||||
#endif
|
||||
|
||||
if (ParseArgs(argc, argv)) {
|
||||
@ -1689,7 +1700,7 @@ main(int argc, char *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)
|
||||
@ -1808,7 +1819,7 @@ main(int argc, char *argv[])
|
||||
} 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",
|
||||
@ -1821,7 +1832,7 @@ main(int argc, char *argv[])
|
||||
#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,
|
||||
|
@ -315,7 +315,7 @@ DoCloneIndex(Volume * rwvp, Volume * clvp, VnodeClass class, int reclone)
|
||||
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);
|
||||
}
|
||||
|
@ -52,6 +52,16 @@ RCSID
|
||||
#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
|
||||
@ -475,10 +485,11 @@ stream_open(const char *filename, const char *mode)
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
@ -526,11 +537,13 @@ stream_read(void *ptr, int size, int nitems, StreamHandle_t * streamP)
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
@ -574,7 +587,7 @@ stream_write(void *ptr, int size, int nitems, StreamHandle_t * streamP)
|
||||
|
||||
/* 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;
|
||||
@ -822,11 +835,11 @@ ih_icreate(IHandle_t * ih, int dev, char *part, Inode nI, int p1, int p2,
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -174,8 +174,8 @@ typedef struct FdHandle_s {
|
||||
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 */
|
||||
@ -249,21 +249,25 @@ extern FILE *ih_fdopen(FdHandle_t * h, char *fdperms);
|
||||
#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);
|
||||
@ -335,25 +339,69 @@ extern int ih_condsync(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 */
|
||||
@ -378,6 +426,7 @@ extern Inode ih_icreate(IHandle_t * ih, int dev, char *part, Inode nI, int p1,
|
||||
#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
|
||||
|
@ -45,14 +45,36 @@ RCSID
|
||||
#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);
|
||||
@ -69,10 +91,10 @@ namei_iread(IHandle_t * h, int offset, char *buf, int size)
|
||||
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);
|
||||
@ -221,7 +243,7 @@ namei_ViceREADME(char *partition)
|
||||
|
||||
(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);
|
||||
@ -295,7 +317,7 @@ delTree(char *root, char *tree, int *errp)
|
||||
char *cp;
|
||||
DIR *ds;
|
||||
struct dirent *dirp;
|
||||
struct stat st;
|
||||
struct afs_stat st;
|
||||
|
||||
if (*tree) {
|
||||
/* delete the children first */
|
||||
@ -318,7 +340,7 @@ delTree(char *root, char *tree, int *errp)
|
||||
*/
|
||||
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
|
||||
@ -441,7 +463,7 @@ SetOGM(int fd, int parm, int tag)
|
||||
|
||||
/* 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;
|
||||
@ -451,8 +473,8 @@ GetOGMFromStat(struct stat *status, int *parm, int *tag)
|
||||
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);
|
||||
@ -528,12 +550,13 @@ namei_icreate(IHandle_t * lh, char *part, int p1, int p2, int p3, int p4)
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -579,7 +602,7 @@ namei_iopen(IHandle_t * h)
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@ -805,12 +828,12 @@ namei_inc(IHandle_t * h, Inode ino, int p1)
|
||||
#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;
|
||||
}
|
||||
|
||||
@ -823,7 +846,8 @@ int
|
||||
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);
|
||||
|
||||
@ -836,7 +860,7 @@ namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit)
|
||||
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)) {
|
||||
@ -860,7 +884,7 @@ static int
|
||||
GetFreeTag(IHandle_t * ih, int vno)
|
||||
{
|
||||
FdHandle_t *fdP;
|
||||
int offset;
|
||||
afs_foff_t offset;
|
||||
int col;
|
||||
int coldata;
|
||||
short row;
|
||||
@ -882,7 +906,7 @@ GetFreeTag(IHandle_t * ih, int vno)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -905,7 +929,7 @@ GetFreeTag(IHandle_t * ih, int vno)
|
||||
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)) {
|
||||
@ -939,7 +963,8 @@ GetFreeTag(IHandle_t * ih, int vno)
|
||||
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;
|
||||
@ -955,7 +980,7 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked)
|
||||
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;
|
||||
}
|
||||
@ -975,7 +1000,7 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked)
|
||||
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;
|
||||
}
|
||||
@ -1035,9 +1060,9 @@ int mode_errors; /* Number of errors found in mode bits on directories. */
|
||||
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 {
|
||||
@ -1066,10 +1091,10 @@ ListViceInodes(char *devname, char *mountedOn, char *resultFile,
|
||||
{
|
||||
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;
|
||||
@ -1110,7 +1135,7 @@ ListViceInodes(char *devname, char *mountedOn, char *resultFile,
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
@ -1247,7 +1272,7 @@ namei_ListAFSSubDirs(IHandle_t * dirIH,
|
||||
/* 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);
|
||||
}
|
||||
@ -1365,19 +1390,19 @@ static int
|
||||
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) {
|
||||
@ -1545,7 +1570,7 @@ namei_ConvertROtoRWvolume(IHandle_t * h, afs_uint32 vid)
|
||||
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);
|
||||
@ -1553,7 +1578,7 @@ namei_ConvertROtoRWvolume(IHandle_t * h, afs_uint32 vid)
|
||||
}
|
||||
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);
|
||||
@ -1572,7 +1597,7 @@ namei_ConvertROtoRWvolume(IHandle_t * h, afs_uint32 vid)
|
||||
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;
|
||||
@ -1585,7 +1610,7 @@ namei_ConvertROtoRWvolume(IHandle_t * h, afs_uint32 vid)
|
||||
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;
|
||||
|
@ -35,8 +35,10 @@ extern Inode namei_icreate(IHandle_t * h, char *p, int p1, int p2, int p3,
|
||||
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);
|
||||
|
@ -43,6 +43,12 @@ RCSID
|
||||
#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, ...);
|
||||
|
||||
|
||||
@ -106,7 +112,7 @@ int
|
||||
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;
|
||||
@ -125,7 +131,7 @@ nuke(char *aname, afs_int32 avolid)
|
||||
|
||||
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;
|
||||
|
@ -30,7 +30,7 @@ RCSID
|
||||
#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)
|
||||
@ -112,7 +112,6 @@ RCSID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include <rx/xdr.h>
|
||||
#include <afs/afsint.h>
|
||||
#include "nfs.h"
|
||||
@ -147,6 +146,42 @@ RCSID
|
||||
#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% */
|
||||
@ -216,7 +251,7 @@ VInitPartition_r(char *path, char *devname, Device dev)
|
||||
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);
|
||||
@ -257,7 +292,7 @@ VOL_UNLOCK}
|
||||
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
|
||||
@ -267,7 +302,7 @@ VCheckPartition(char *part, char *devname)
|
||||
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;
|
||||
}
|
||||
@ -276,7 +311,7 @@ VCheckPartition(char *part, char *devname)
|
||||
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;
|
||||
}
|
||||
@ -287,7 +322,7 @@ VCheckPartition(char *part, char *devname)
|
||||
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;
|
||||
|
||||
@ -303,7 +338,7 @@ VCheckPartition(char *part, char *devname)
|
||||
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;
|
||||
}
|
||||
@ -316,7 +351,7 @@ VCheckPartition(char *part, char *devname)
|
||||
#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;
|
||||
}
|
||||
@ -336,7 +371,7 @@ static int
|
||||
VIsAlwaysAttach(char *part)
|
||||
{
|
||||
#ifdef AFS_NAMEI_ENV
|
||||
struct stat st;
|
||||
struct afs_stat st;
|
||||
char checkfile[256];
|
||||
int ret;
|
||||
|
||||
@ -347,7 +382,7 @@ VIsAlwaysAttach(char *part)
|
||||
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;
|
||||
@ -391,7 +426,7 @@ VAttachPartitions(void)
|
||||
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);
|
||||
@ -706,11 +741,11 @@ VAttachPartitions(void)
|
||||
* 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);
|
||||
}
|
||||
@ -833,10 +868,10 @@ VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
|
||||
{
|
||||
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)
|
||||
@ -845,10 +880,10 @@ VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
|
||||
* 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",
|
||||
@ -862,7 +897,7 @@ VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
|
||||
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;
|
||||
@ -918,8 +953,8 @@ VResetDiskUsage(void)
|
||||
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
|
||||
@ -948,14 +983,14 @@ VAdjustDiskUsage_r(Error * ec, Volume * vp, afs_int32 blocks,
|
||||
}
|
||||
|
||||
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
|
||||
@ -975,7 +1010,7 @@ VDiskUsage_r(Volume * vp, afs_int32 blocks)
|
||||
}
|
||||
|
||||
int
|
||||
VDiskUsage(Volume * vp, afs_int32 blocks)
|
||||
VDiskUsage(Volume * vp, afs_sfsize_t blocks)
|
||||
{
|
||||
int retVal;
|
||||
VOL_LOCK retVal = VDiskUsage_r(vp, blocks);
|
||||
@ -1091,7 +1126,7 @@ VLockPartition_r(char *name)
|
||||
#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)
|
||||
|
@ -90,6 +90,8 @@ extern int VValidVPTEntry(struct vptab *vptp);
|
||||
#endif
|
||||
|
||||
|
||||
struct Volume; /* Potentially forward definition */
|
||||
|
||||
extern struct DiskPartition *DiskPartitionList;
|
||||
extern struct DiskPartition *VGetPartition();
|
||||
extern int VAttachPartitions(void);
|
||||
@ -102,6 +104,7 @@ extern void VResetDiskUsage_r(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);
|
||||
|
@ -66,7 +66,7 @@ ReallyRead(DirHandle * file, int block, char *data)
|
||||
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;
|
||||
@ -99,7 +99,7 @@ ReallyWrite(DirHandle * file, int block, char *data)
|
||||
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;
|
||||
|
@ -46,7 +46,7 @@ struct SpecialInodeParams {
|
||||
*/
|
||||
struct ViceInodeInfo {
|
||||
Inode inodeNumber;
|
||||
int byteCount;
|
||||
afs_fsize_t byteCount;
|
||||
int linkCount;
|
||||
union {
|
||||
bit32 param[4];
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#define Date afs_uint32
|
||||
|
||||
struct Volume; /* Potentially forward definition. */
|
||||
|
||||
typedef struct ViceLock {
|
||||
int lockCount;
|
||||
int lockTime;
|
||||
@ -198,17 +200,19 @@ typedef struct Vnode {
|
||||
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);
|
||||
|
@ -57,6 +57,16 @@ RCSID
|
||||
|
||||
#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 */
|
||||
@ -82,10 +92,10 @@ struct DiskPartition *FindCurrentPartition(void);
|
||||
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);
|
||||
@ -93,14 +103,15 @@ 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];
|
||||
}
|
||||
|
||||
@ -309,7 +320,8 @@ handleit(struct cmd_syndesc *as)
|
||||
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");
|
||||
@ -436,7 +448,7 @@ HandleVolume(struct DiskPartition *dp, char *name)
|
||||
{
|
||||
struct VolumeHeader header;
|
||||
struct VolumeDiskHeader diskHeader;
|
||||
struct stat status, stat;
|
||||
struct afs_stat status, stat;
|
||||
register int fd;
|
||||
Volume *vp;
|
||||
IHandle_t *ih;
|
||||
@ -448,9 +460,10 @@ HandleVolume(struct DiskPartition *dp, char *name)
|
||||
} 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);
|
||||
@ -475,7 +488,7 @@ HandleVolume(struct DiskPartition *dp, char *name)
|
||||
int size = 0;
|
||||
int code;
|
||||
|
||||
if (fstat(fd, &stat) == -1) {
|
||||
if (afs_fstat(fd, &stat) == -1) {
|
||||
perror("stat");
|
||||
exit(1);
|
||||
}
|
||||
@ -602,8 +615,7 @@ HandleVolume(struct DiskPartition *dp, char *name)
|
||||
}
|
||||
|
||||
|
||||
main(argc, argv)
|
||||
char **argv;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
register struct cmd_syndesc *ts;
|
||||
afs_int32 code;
|
||||
@ -717,8 +729,8 @@ GetFileInfo(FD_t fd, int *size, char **ctime, char **mtime, char **atime)
|
||||
*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);
|
||||
}
|
||||
@ -786,8 +798,9 @@ PrintVnodes(Volume * vp, VnodeClass class)
|
||||
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);
|
||||
@ -847,11 +860,12 @@ PrintVnodes(Volume * vp, VnodeClass class)
|
||||
|
||||
#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)
|
||||
@ -871,7 +885,7 @@ PrintVnode(int offset, VnodeDiskObject * vnode, int vnodeNumber, Inode ino)
|
||||
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);
|
||||
|
@ -194,6 +194,28 @@ RCSID
|
||||
#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
|
||||
@ -323,7 +345,7 @@ struct VnodeInfo {
|
||||
* 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 */
|
||||
@ -839,7 +861,7 @@ ObtainSalvageLock(void)
|
||||
}
|
||||
#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) {
|
||||
@ -877,7 +899,7 @@ IsPartitionMounted(char *part)
|
||||
/* 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
|
||||
@ -1121,7 +1143,7 @@ SalvageFileSysParallel(struct DiskPartition *partP)
|
||||
"%s.%d",
|
||||
AFSDIR_SERVER_SLVGLOG_FILEPATH,
|
||||
jobs[startjob]->jobnumb);
|
||||
logFile = fopen(logFileName, "w");
|
||||
logFile = afs_fopen(logFileName, "w");
|
||||
}
|
||||
if (!logFile)
|
||||
logFile = stdout;
|
||||
@ -1141,7 +1163,7 @@ SalvageFileSysParallel(struct DiskPartition *partP)
|
||||
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);
|
||||
}
|
||||
@ -1277,7 +1299,7 @@ SalvageFileSys1(struct DiskPartition *partP, VolumeId singleVolumeNumber)
|
||||
_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)
|
||||
@ -1507,7 +1529,7 @@ OnlyOneVolume(struct ViceInodeInfo *inodeinfo, VolumeId singleVolumeNumber)
|
||||
int
|
||||
GetInodeSummary(char *path, VolumeId singleVolumeNumber)
|
||||
{
|
||||
struct stat status;
|
||||
struct afs_stat status;
|
||||
int forceSal, err;
|
||||
struct ViceInodeInfo *ip;
|
||||
struct InodeSummary summary;
|
||||
@ -1539,8 +1561,8 @@ GetInodeSummary(char *path, VolumeId singleVolumeNumber)
|
||||
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);
|
||||
}
|
||||
@ -1552,7 +1574,7 @@ GetInodeSummary(char *path, VolumeId singleVolumeNumber)
|
||||
(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);
|
||||
@ -1589,7 +1611,7 @@ GetInodeSummary(char *path, VolumeId singleVolumeNumber)
|
||||
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);
|
||||
@ -1630,13 +1652,13 @@ GetInodeSummary(char *path, VolumeId singleVolumeNumber)
|
||||
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);
|
||||
}
|
||||
@ -1682,7 +1704,7 @@ GetVolumeSummary(VolumeId singleVolumeNumber)
|
||||
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) {
|
||||
@ -1716,7 +1738,7 @@ GetVolumeSummary(VolumeId singleVolumeNumber)
|
||||
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) {
|
||||
@ -1742,7 +1764,8 @@ GetVolumeSummary(VolumeId singleVolumeNumber)
|
||||
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)) {
|
||||
@ -1906,8 +1929,9 @@ DoSalvageVolumeGroup(register struct InodeSummary *isp, int nVols)
|
||||
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
|
||||
@ -2182,7 +2206,7 @@ SalvageVolumeHeaderFile(register struct InodeSummary *isp,
|
||||
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));
|
||||
@ -2209,7 +2233,7 @@ SalvageVolumeHeaderFile(register struct InodeSummary *isp,
|
||||
if (check)
|
||||
return -1;
|
||||
|
||||
headerFd = open(name, O_RDWR | O_TRUNC, 0644);
|
||||
headerFd = afs_open(name, O_RDWR | O_TRUNC, 0644);
|
||||
assert(headerFd != -1);
|
||||
}
|
||||
}
|
||||
@ -2591,7 +2615,7 @@ SalvageIndex(Inode ino, VnodeClass class, int RW,
|
||||
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;
|
||||
@ -2627,22 +2651,22 @@ SalvageIndex(Inode ino, VnodeClass class, int RW,
|
||||
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;
|
||||
@ -3616,10 +3640,10 @@ PrintInodeList(void)
|
||||
{
|
||||
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);
|
||||
@ -3729,7 +3753,7 @@ CheckLogFile(void)
|
||||
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;
|
||||
@ -3779,7 +3803,7 @@ showlog(void)
|
||||
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);
|
||||
@ -3867,11 +3891,11 @@ RemoveTheForce(char *path)
|
||||
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
|
||||
/*
|
||||
@ -3930,7 +3954,7 @@ nt_SetupPartitionSalvage(void *datap, int len)
|
||||
/* 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;
|
||||
|
||||
|
@ -135,6 +135,16 @@ RCSID
|
||||
#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;
|
||||
@ -149,15 +159,17 @@ extern void *calloc(), *realloc();
|
||||
/*@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);
|
||||
@ -550,7 +562,7 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode)
|
||||
{
|
||||
register Volume *vp;
|
||||
int fd, n;
|
||||
struct stat status;
|
||||
struct afs_stat status;
|
||||
struct VolumeDiskHeader diskHeader;
|
||||
struct VolumeHeader iheader;
|
||||
struct DiskPartition *partp;
|
||||
@ -585,8 +597,8 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode)
|
||||
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);
|
||||
@ -1488,12 +1500,12 @@ GetVolumePath(Error * ec, VolId volumeId, char **partitionp, char **namep)
|
||||
|
||||
*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;
|
||||
@ -1519,8 +1531,8 @@ VolumeNumber(char *name)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -447,13 +447,15 @@ extern int VInitVolumePackage(ProgramType pt, int nLargeVnodes,
|
||||
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"
|
||||
|
@ -66,13 +66,18 @@ RCSID
|
||||
#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))
|
||||
@ -155,7 +160,7 @@ VCreateVolume_r(Error * ec, char *partname, VolId volumeId, VolId parentId)
|
||||
(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",
|
||||
|
@ -52,6 +52,16 @@ RCSID
|
||||
#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;
|
||||
@ -91,8 +101,9 @@ static int ReadDumpHeader(register struct iod *iodp, struct DumpHeader *hp);
|
||||
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,
|
||||
@ -484,14 +495,16 @@ DumpByteString(register struct iod *iodp, char tag, register byte * bs,
|
||||
}
|
||||
|
||||
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;
|
||||
@ -502,7 +515,7 @@ DumpFile(struct iod *iodp, char tag, int vnode, FdHandle_t * handleP)
|
||||
howMany = 4096;
|
||||
|
||||
#else
|
||||
fstat(handleP->fd_fd, &status);
|
||||
afs_fstat(handleP->fd_fd, &status);
|
||||
howBig = status.st_size;
|
||||
|
||||
#ifdef AFS_AIX_ENV
|
||||
@ -518,7 +531,19 @@ DumpFile(struct iod *iodp, char tag, int vnode, FdHandle_t * handleP)
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
@ -855,7 +880,7 @@ DumpVnode(register struct iod *iodp, struct VnodeDiskObject *v, int volid,
|
||||
IH_RELEASE(ihP);
|
||||
return VOLSERREAD_DUMPERROR;
|
||||
}
|
||||
code = DumpFile(iodp, 'f', vnodeNumber, fdP);
|
||||
code = DumpFile(iodp, vnodeNumber, fdP);
|
||||
FDH_CLOSE(fdP);
|
||||
IH_RELEASE(ihP);
|
||||
}
|
||||
@ -1116,6 +1141,9 @@ ReadVnodes(register struct iod *iodp, Volume * vp, int incremental,
|
||||
VAclDiskSize(vnode));
|
||||
acl_NtohACL(VVnodeDiskACL(vnode));
|
||||
break;
|
||||
#ifdef AFS_LARGEFILE_ENV
|
||||
case 'h':
|
||||
#endif
|
||||
case 'f':{
|
||||
Inode ino;
|
||||
Error error;
|
||||
@ -1140,7 +1168,7 @@ ReadVnodes(register struct iod *iodp, Volume * vp, int incremental,
|
||||
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);
|
||||
@ -1215,23 +1243,42 @@ ReadVnodes(register struct iod *iodp, Volume * vp, int incremental,
|
||||
* 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;
|
||||
|
@ -128,14 +128,14 @@ char buf[BUFSIZE];
|
||||
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);
|
||||
@ -388,7 +388,7 @@ struct vNode {
|
||||
} entries[100];
|
||||
} acl;
|
||||
#endif
|
||||
afs_int32 dataSize;
|
||||
afs_sfsize_t dataSize;
|
||||
};
|
||||
|
||||
#define MAXNAMELEN 256
|
||||
@ -464,9 +464,21 @@ ReadVNode(count)
|
||||
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.
|
||||
@ -656,7 +668,7 @@ ReadVNode(count)
|
||||
*/
|
||||
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.
|
||||
@ -682,7 +694,7 @@ ReadVNode(count)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user