struct host *thost;
struct client *tclient;
int translate = 0;
- int held;
H_LOCK;
tclient = h_FindClient_r(aconn);
if (thost->hostFlags & HERRORTRANS)
translate = 1;
h_ReleaseClient_r(tclient);
- held = h_Held_r(thost);
- if (held)
- h_Release_r(thost);
- if (ahost && ahost != thost) {
- char hoststr[16], hoststr2[16];
- ViceLog(0, ("CallPostamble: ahost %s:%d (%x) != thost %s:%d (%x)\n",
- afs_inet_ntoa_r(ahost->host, hoststr), ntohs(ahost->port),
- ahost,
- afs_inet_ntoa_r(thost->host, hoststr2), ntohs(thost->port),
- thost));
- h_Release_r(ahost);
- } else if (!ahost) {
- char hoststr[16];
- ViceLog(0, ("CallPostamble: null ahost for thost %s:%d (%x)\n",
- afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port),
- thost));
+
+ if (ahost) {
+ if (ahost != thost) {
+ /* host/client recycle */
+ char hoststr[16], hoststr2[16];
+ ViceLog(0, ("CallPostamble: ahost %s:%d (%p) != thost "
+ "%s:%d (%p)\n",
+ afs_inet_ntoa_r(ahost->host, hoststr),
+ ntohs(ahost->port),
+ ahost,
+ afs_inet_ntoa_r(thost->host, hoststr2),
+ ntohs(thost->port),
+ thost));
+ }
+ /* return the reference taken in CallPreamble */
+ h_Release_r(ahost);
+ } else {
+ char hoststr[16];
+ ViceLog(0, ("CallPostamble: null ahost for thost %s:%d (%p)\n",
+ afs_inet_ntoa_r(thost->host, hoststr),
+ ntohs(thost->port),
+ thost));
}
+
+ /* return the reference taken in local h_FindClient_r--h_ReleaseClient_r
+ * does not decrement refcount on client->host */
+ h_Release_r(thost);
+
busyout:
H_UNLOCK;
return (translate ? sys_error_to_et(ret) : ret);
{
char *eACL; /* External access list placeholder */
- if (acl_Externalize
- ((targetptr->disk.type ==
+ if (acl_Externalize_pr
+ (hpr_IdToName, (targetptr->disk.type ==
vDirectory ? VVnodeACL(targetptr) :
VVnodeACL(parentwhentargetnotdir)), &eACL) != 0) {
return EIO;
{
struct acl_accessList *newACL; /* PlaceHolder for new access list */
- if (acl_Internalize(AccessList->AFSOpaque_val, &newACL) != 0)
+ if (acl_Internalize_pr(hpr_NameToId, AccessList->AFSOpaque_val, &newACL)
+ != 0)
return (EINVAL);
if ((newACL->size + 4) > VAclSize(targetptr))
return (E2BIG);
#define COPYBUFFSIZE 8192
#define MAXFSIZE (~(afs_fsize_t) 0)
static int
-CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_fsize_t off, afs_fsize_t len)
+CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_foff_t off, afs_fsize_t len)
{
Inode ino, nearInode;
- int rdlen;
- int wrlen;
+ ssize_t rdlen;
+ ssize_t wrlen;
register afs_fsize_t size;
- register int length;
+ size_t length;
char *buff;
int rc; /* return code */
IHandle_t *newH; /* Use until finished copying, then cp to vnode. */
length = COPYBUFFSIZE;
size -= COPYBUFFSIZE;
} else {
- length = (int)size;
+ length = size;
size = 0;
}
rdlen = FDH_READ(targFdP, buff, length);
free(buff);
return ENOSPC;
} else {
+ /* length, rdlen, and wrlen may or may not be 64-bits wide;
+ * since we never do any I/O anywhere near 2^32 bytes at a
+ * time, just case to an unsigned int for printing */
+
ViceLog(0,
("CopyOnWrite failed: volume %u in partition %s (tried reading %u, read %u, wrote %u, errno %u) volume needs salvage\n",
- V_id(volptr), volptr->partition->name, length, rdlen,
- wrlen, errno));
+ V_id(volptr), volptr->partition->name, (unsigned)length, (unsigned)rdlen,
+ (unsigned)wrlen, errno));
#if defined(AFS_DEMAND_ATTACH_FS)
ViceLog(0, ("CopyOnWrite failed: requesting salvage\n"));
#else
} /*CopyOnWrite */
static int
-CopyOnWrite2(FdHandle_t *targFdP, FdHandle_t *newFdP, afs_fsize_t off, afs_fsize_t size) {
+CopyOnWrite2(FdHandle_t *targFdP, FdHandle_t *newFdP, afs_foff_t off, afs_fsize_t size) {
char *buff = (char *)malloc(COPYBUFFSIZE);
- register int length;
- int rdlen;
- int wrlen;
+ size_t length;
+ ssize_t rdlen;
+ ssize_t wrlen;
int rc;
FDH_SEEK(targFdP, off, SEEK_SET);
length = COPYBUFFSIZE;
size -= COPYBUFFSIZE;
} else {
- length = (int)size;
+ length = size;
size = 0;
}
rdlen = FDH_READ(targFdP, buff, length);
SetDirHandle(&childdir, *targetptr);
if (IsEmpty(&childdir) != 0)
return (EEXIST);
- DZap(&childdir);
+ DZap((afs_int32 *) &childdir);
FidZap(&childdir);
(*targetptr)->delete = 1;
} else if ((--(*targetptr)->disk.linkCount) == 0)
afs_sfsize_t tPos, tLen;
#ifdef AFS_64BIT_ENV
-#ifndef AFS_LARGEFILE_ENV
- if (Pos + Len > 0x7fffffff)
- return EFBIG;
-#endif /* !AFS_LARGEFILE_ENV */
tPos = (afs_sfsize_t) Pos;
tLen = (afs_sfsize_t) Len;
#else /* AFS_64BIT_ENV */
&rights, &anyrights)))
goto Bad_BulkStatus;
/* set volume synchronization information, but only once per call */
- if (i == nfiles)
+ if (i == 0)
SetVolumeSync(Sync, volptr);
/* Are we allowed to fetch Fid's status? */
struct host *thost;
struct client *t_client = NULL; /* tmp ptr to client data */
AFSFetchStatus *tstatus;
+ int VolSync_set = 0;
#if FS_STATS_DETAILED
struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
struct timeval opStartTime, opStopTime; /* Start/stop times for RPC op */
}
CallBacks->AFSCBs_len = nfiles;
+ /* Zero out return values to avoid leaking information on partial succes */
+ memset(OutStats->AFSBulkStats_val, 0, nfiles * sizeof(struct AFSFetchStatus));
+ memset(CallBacks->AFSCBs_val, 0, nfiles * sizeof(struct AFSCallBack));
+ memset(Sync, 0, sizeof(*Sync));
+
if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost))) {
goto Bad_InlineBulkStatus;
}
}
/* set volume synchronization information, but only once per call */
- if (i == nfiles)
+ if (!VolSync_set) {
SetVolumeSync(Sync, volptr);
+ VolSync_set = 1;
+ }
/* Are we allowed to fetch Fid's status? */
if (targetptr->disk.type != vDirectory) {
afs_fsize_t tFileLength;
#ifdef AFS_64BIT_ENV
-#ifndef AFS_LARGEFILE_ENV
- if (FileLength > 0x7fffffff)
- return EFBIG;
-#endif /* !AFS_LARGEFILE_ENV */
tPos = (afs_fsize_t) Pos;
tLength = (afs_fsize_t) Length;
tFileLength = (afs_fsize_t) FileLength;
Vnode *targetptr = 0; /* vnode of the new link */
Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
Error errorCode = 0; /* error code */
- int len, code = 0;
+ afs_sfsize_t len;
+ int code = 0;
DirHandle dir; /* Handle for dir package I/O */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client structure */
len = strlen((char *) LinkContents);
code = (len == FDH_WRITE(fdP, (char *) LinkContents, len)) ? 0 : VDISKFULL;
if (code)
- ViceLog(0, ("SAFSS_Symlink FDH_WRITE failed for len=%d, Fid=%u.%d.%d\n", len, OutFid->Volume, OutFid->Vnode, OutFid->Unique));
+ ViceLog(0, ("SAFSS_Symlink FDH_WRITE failed for len=%d, Fid=%u.%d.%d\n", (int)len, OutFid->Volume, OutFid->Vnode, OutFid->Unique));
FDH_CLOSE(fdP);
/*
* Set up and return modified status for the parent dir and new symlink
/* Actually create the New directory in the directory package */
SetDirHandle(&dir, targetptr);
- assert(!(MakeDir(&dir, OutFid, DirFid)));
+ assert(!(MakeDir(&dir, (afs_int32 *)OutFid, (afs_int32 *)DirFid)));
DFlush();
VN_SET_LEN(targetptr, (afs_fsize_t) Length(&dir));
dataBytes = 1 * sizeof(afs_int32);
dataBuffP = (afs_uint32 *) malloc(dataBytes);
dataBuffP[0] = VICED_CAPABILITY_ERRORTRANS | VICED_CAPABILITY_WRITELOCKACL;
-#if defined(AFS_64BIT_ENV) && defined(AFS_LARGEFILE_ENV)
+#if defined(AFS_64BIT_ENV)
dataBuffP[0] |= VICED_CAPABILITY_64BITFILES;
#endif
if (saneacls)
)
{
struct timeval StartTime, StopTime; /* used to calculate file transfer rates */
- Error errorCode = 0; /* Returned error code to caller */
IHandle_t *ihP;
FdHandle_t *fdP;
#ifdef AFS_NT40_ENV
Len = 0;
}
- if (Pos + Len > tlen)
- Len = tlen - Pos; /* get length we should send */
+ if (Pos + Len > tlen) /* get length we should send */
+ Len = ((tlen - Pos) < 0) ? 0 : tlen - Pos;
+
(void)FDH_SEEK(fdP, Pos, 0);
{
afs_int32 high, low;
tbuffer = AllocSendBuffer();
#endif /* AFS_NT40_ENV */
while (Len > 0) {
- int wlen;
+ size_t wlen;
+ ssize_t nBytes;
if (Len > optSize)
wlen = optSize;
else
- wlen = (int)Len;
+ wlen = Len;
#ifdef AFS_NT40_ENV
- errorCode = FDH_READ(fdP, tbuffer, wlen);
- if (errorCode != wlen) {
+ nBytes = FDH_READ(fdP, tbuffer, wlen);
+ if (nBytes != wlen) {
FDH_CLOSE(fdP);
FreeSendBuffer((struct afs_buffer *)tbuffer);
VTakeOffline(volptr);
volptr->hashid));
return EIO;
}
- errorCode = rx_Write(Call, tbuffer, wlen);
+ nBytes = rx_Write(Call, tbuffer, wlen);
#else /* AFS_NT40_ENV */
- errorCode = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, wlen);
- if (errorCode <= 0) {
+ nBytes = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, wlen);
+ if (nBytes <= 0) {
FDH_CLOSE(fdP);
return EIO;
}
- wlen = errorCode;
- errorCode = FDH_READV(fdP, tiov, tnio);
- if (errorCode != wlen) {
+ wlen = nBytes;
+ nBytes = FDH_READV(fdP, tiov, tnio);
+ if (nBytes != wlen) {
FDH_CLOSE(fdP);
VTakeOffline(volptr);
ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
volptr->hashid));
return EIO;
}
- errorCode = rx_Writev(Call, tiov, tnio, wlen);
+ nBytes = rx_Writev(Call, tiov, tnio, wlen);
#endif /* AFS_NT40_ENV */
#if FS_STATS_DETAILED
/*
* Bump the number of bytes actually sent by the number from this
* latest iteration
*/
- (*a_bytesFetchedP) += errorCode;
+ (*a_bytesFetchedP) += nBytes;
#endif /* FS_STATS_DETAILED */
- if (errorCode != wlen) {
+ if (nBytes != wlen) {
FDH_CLOSE(fdP);
#ifdef AFS_NT40_ENV
FreeSendBuffer((struct afs_buffer *)tbuffer);
afs_sfsize_t adjustSize; /* bytes to call VAdjust... with */
int linkCount = 0; /* link count on inode */
afs_fsize_t CoW_off, CoW_len;
+ ssize_t nBytes;
FdHandle_t *fdP, *origfdP = NULL;
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
if (Pos == 0) CopyOnWrite_off0++;
if (CoW_len > CopyOnWrite_maxsize) CopyOnWrite_maxsize = CoW_len;
- ViceLog(1, ("StoreData : calling CopyOnWrite on vnode %lu.%lu (%s) off 0x%llx size 0x%llx\n",
- V_id(volptr), targetptr->vnodeNumber, V_name(volptr), 0, Pos));
+ ViceLog(1, ("StoreData : calling CopyOnWrite on vnode %u.%u (%s) "
+ "off 0x0 size 0x%llx\n",
+ afs_printable_VolumeId_u(V_id(volptr)),
+ afs_printable_VnodeId_u(targetptr->vnodeNumber),
+ V_name(volptr), Pos));
if ((errorCode = CopyOnWrite(targetptr, volptr, 0, Pos))) {
ViceLog(25, ("StoreData : CopyOnWrite failed\n"));
volptr->partition->flags &= ~PART_DONTUPDATE;
/* Set the file's length; we've already done an lseek to the right
* spot above.
*/
- errorCode = FDH_WRITE(fdP, &tlen, 1);
- if (errorCode != 1)
+ nBytes = FDH_WRITE(fdP, &tlen, 1);
+ if (nBytes != 1) {
+ errorCode = -1;
goto done;
+ }
errorCode = FDH_TRUNC(fdP, Pos);
} else {
/* have some data to copy */
#else /* AFS_NT40_ENV */
errorCode = rx_Readv(Call, tiov, &tnio, RX_MAXIOVECS, rlen);
#endif /* AFS_NT40_ENV */
-#if FS_STATS_DETAILED
- (*a_bytesStoredP) += errorCode;
-#endif /* FS_STATS_DETAILED */
if (errorCode <= 0) {
errorCode = -32;
break;
}
+#if FS_STATS_DETAILED
+ (*a_bytesStoredP) += errorCode;
+#endif /* FS_STATS_DETAILED */
rlen = errorCode;
#ifdef AFS_NT40_ENV
- errorCode = FDH_WRITE(fdP, tbuffer, rlen);
+ nBytes = FDH_WRITE(fdP, tbuffer, rlen);
#else /* AFS_NT40_ENV */
- errorCode = FDH_WRITEV(fdP, tiov, tnio);
+ nBytes = FDH_WRITEV(fdP, tiov, tnio);
#endif /* AFS_NT40_ENV */
- if (errorCode != rlen) {
+ if (nBytes != rlen) {
errorCode = VDISKFULL;
break;
}
if (origfdP) { /* finish CopyOnWrite */
if ( (CoW_off = Pos + Length) < NewLength) {
errorCode = CopyOnWrite2(origfdP, fdP, CoW_off, CoW_len = NewLength - CoW_off);
- ViceLog(1, ("StoreData : CopyOnWrite2 on vnode %lu.%lu (%s) off 0x%llx size 0x%llx returns %d\n",
- V_id(volptr), targetptr->vnodeNumber, V_name(volptr), CoW_off, CoW_len, errorCode));
+ ViceLog(1, ("StoreData : CopyOnWrite2 on vnode %u.%u (%s) "
+ "off 0x%llx size 0x%llx returns %d\n",
+ afs_printable_VolumeId_u(V_id(volptr)),
+ afs_printable_VnodeId_u(targetptr->vnodeNumber),
+ V_name(volptr), CoW_off, CoW_len, errorCode));
}
FDH_CLOSE(origfdP);
}
return 0;
if (in < 0 || in > 511)
return in;
- if (in >= VICE_SPECIAL_ERRORS && in <= VIO || in == VRESTRICTED)
+ if ((in >= VICE_SPECIAL_ERRORS && in <= VIO) || in == VRESTRICTED)
return in;
if (sys2et[in] != 0)
return sys2et[in];