userp = smb_GetUser(vcp, inp);
lock_ObtainMutex(&fidp->mx);
- if (fidp->flags & SMB_FID_OPENWRITE)
- code = cm_FSync(fidp->scp, userp, &req);
- else
+ if (fidp->flags & SMB_FID_OPENWRITE) {
+ cm_scache_t * scp = fidp->scp;
+ cm_HoldSCache(scp);
+ lock_ReleaseMutex(&fidp->mx);
+ code = cm_FSync(scp, userp, &req);
+ cm_ReleaseSCache(scp);
+ } else {
code = 0;
- lock_ReleaseMutex(&fidp->mx);
+ lock_ReleaseMutex(&fidp->mx);
+ }
smb_ReleaseFID(fidp);
cm_req_t req;
cm_scache_t *dscp = fidp->NTopen_dscp;
char *pathp = fidp->NTopen_pathp;
+ cm_scache_t * scp;
osi_Log3(smb_logp, "smb_CloseFID Closing fidp 0x%x (fid=%d vcp=0x%x)",
fidp, fidp->fid, vcp);
lock_ObtainMutex(&fidp->mx);
}
+ scp = fidp->scp;
+ if (scp)
+ cm_HoldSCache(scp);
+
/* watch for ioctl closes, and read-only opens */
- if (fidp->scp != NULL &&
+ if (scp != NULL &&
(fidp->flags & (SMB_FID_OPENWRITE | SMB_FID_DELONCLOSE))
== SMB_FID_OPENWRITE) {
if (dosTime != 0 && dosTime != -1) {
- fidp->scp->mask |= CM_SCACHEMASK_CLIENTMODTIME;
+ scp->mask |= CM_SCACHEMASK_CLIENTMODTIME;
/* This fixes defect 10958 */
CompensateForSmbClientLastWriteTimeBugs(&dosTime);
smb_UnixTimeFromDosUTime(&fidp->scp->clientModTime, dosTime);
}
- code = cm_FSync(fidp->scp, userp, &req);
+ lock_ReleaseMutex(&fidp->mx);
+ code = cm_FSync(scp, userp, &req);
+ lock_ObtainMutex(&fidp->mx);
}
else
code = 0;
/* unlock any pending locks */
- if (!(fidp->flags & SMB_FID_IOCTL) && fidp->scp &&
- fidp->scp->fileType == CM_SCACHETYPE_FILE) {
+ if (!(fidp->flags & SMB_FID_IOCTL) && scp &&
+ scp->fileType == CM_SCACHETYPE_FILE) {
cm_key_t key;
- cm_scache_t * scp;
long tcode;
- /* CM_UNLOCK_BY_FID doesn't look at the process ID. We pass
+ lock_ReleaseMutex(&fidp->mx);
+
+ /* CM_UNLOCK_BY_FID doesn't look at the process ID. We pass
in zero. */
key = cm_GenerateKey(vcp->vcID, 0, fidp->fid);
- scp = fidp->scp;
- cm_HoldSCache(scp);
lock_ObtainMutex(&scp->mx);
tcode = cm_SyncOp(scp, NULL, userp, &req, 0,
post_syncopdone:
lock_ReleaseMutex(&scp->mx);
- cm_ReleaseSCache(scp);
+ lock_ObtainMutex(&fidp->mx);
}
if (fidp->flags & SMB_FID_DELONCLOSE) {
char *fullPathp;
- smb_FullName(dscp, fidp->scp, pathp, &fullPathp, userp, &req);
- if (fidp->scp->fileType == CM_SCACHETYPE_DIRECTORY) {
+ lock_ReleaseMutex(&fidp->mx);
+ smb_FullName(dscp, scp, pathp, &fullPathp, userp, &req);
+ if (scp->fileType == CM_SCACHETYPE_DIRECTORY) {
code = cm_RemoveDir(dscp, fullPathp, userp, &req);
if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
smb_NotifyChange(FILE_ACTION_REMOVED,
if (dscp)
cm_ReleaseSCache(dscp);
+ if (scp)
+ cm_ReleaseSCache(scp);
+
if (pathp)
free(pathp);
if (fidp->curr_chunk == fidp->prev_chunk + 1)
sequential = 1;
}
+ lock_ReleaseMutex(&fidp->mx);
/* start by looking up the file's end */
code = cm_SyncOp(scp, NULL, userp, &req, 0,
done:
lock_ReleaseMutex(&scp->mx);
- lock_ReleaseMutex(&fidp->mx);
if (bufferp)
buf_Release(bufferp);
offset = *offsetp;
lock_ObtainMutex(&fidp->mx);
+ /* make sure we have a writable FD */
+ if (!(fidp->flags & SMB_FID_OPENWRITE)) {
+ osi_Log2(smb_logp, "smb_WriteData fid %d not OPENWRITE flags 0x%x",
+ fidp->fid, fidp->flags);
+ lock_ReleaseMutex(&fidp->mx);
+ code = CM_ERROR_BADFDOP;
+ goto done;
+ }
+
scp = fidp->scp;
- lock_ObtainMutex(&scp->mx);
+ cm_HoldSCache(scp);
+ lock_ReleaseMutex(&fidp->mx);
+ lock_ObtainMutex(&scp->mx);
/* start by looking up the file's end */
code = cm_SyncOp(scp, NULL, userp, &req, 0,
CM_SCACHESYNC_NEEDCALLBACK
if (code)
goto done;
- /* make sure we have a writable FD */
- if (!(fidp->flags & SMB_FID_OPENWRITE)) {
- osi_Log2(smb_logp, "smb_WriteData fid %d not OPENWRITE flags 0x%x",
- fidp->fid, fidp->flags);
- code = CM_ERROR_BADFDOP;
- goto done;
- }
-
/* now we have the entry locked, look up the length */
fileLength = scp->length;
minLength = fileLength;
buf_Release(bufferp);
}
+ lock_ObtainMutex(&fidp->mx);
if (code == 0 && filter != 0 && (fidp->flags & SMB_FID_NTOPEN)
&& (fidp->NTopen_dscp->flags & CM_SCACHEFLAG_ANYWATCH)) {
smb_NotifyChange(FILE_ACTION_MODIFIED, filter,
writeBackOffset.HighPart, cm_chunkSize, 0, userp);
}
+ cm_ReleaseSCache(scp);
+
osi_Log3(smb_logp, "smb_WriteData fid %d returns 0x%x written %d bytes",
fidp->fid, code, *writtenp);
return code;
lock_ObtainMutex(&fidp->mx);
scp = fidp->scp;
+ cm_HoldSCache(scp);
+ lock_ReleaseMutex(&fidp->mx);
lock_ObtainMutex(&scp->mx);
code = cm_SyncOp(scp, NULL, userp, &req, 0,
CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
smb_SetSMBDataLength(outp, 0);
}
lock_ReleaseMutex(&scp->mx);
- lock_ReleaseMutex(&fidp->mx);
smb_ReleaseFID(fidp);
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
return code;
}
unsigned short infoLevel;
int nbytesRequired;
unsigned short fid;
+ int delonclose = 0;
cm_user_t *userp;
smb_fid_t *fidp;
cm_scache_t *scp;
}
lock_ObtainMutex(&fidp->mx);
+ delonclose = fidp->flags & SMB_FID_DELONCLOSE;
scp = fidp->scp;
+ cm_HoldSCache(scp);
+ lock_ReleaseMutex(&fidp->mx);
lock_ObtainMutex(&scp->mx);
code = cm_SyncOp(scp, NULL, userp, &req, 0,
CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
*((LARGE_INTEGER *)op) = scp->length; op += 8; /* alloc size */
*((LARGE_INTEGER *)op) = scp->length; op += 8; /* EOF */
*((u_long *)op) = scp->linkCount; op += 4;
- *op++ = ((fidp->flags & SMB_FID_DELONCLOSE) ? 1 : 0);
+ *op++ = (delonclose ? 1 : 0);
*op++ = (scp->fileType == CM_SCACHETYPE_DIRECTORY ? 1 : 0);
*op++ = 0;
*op++ = 0;
unsigned long len;
char *name;
+ lock_ReleaseMutex(&scp->mx);
+ lock_ObtainMutex(&fidp->mx);
+ lock_ObtainMutex(&scp->mx);
if (fidp->NTopen_wholepathp)
name = fidp->NTopen_wholepathp;
else
name = "\\"; /* probably can't happen */
+ lock_ReleaseMutex(&fidp->mx);
len = strlen(name);
outp->totalData = (len*2) + 4; /* this is actually what we want to return */
*((u_long *)op) = len * 2; op += 4;
/* send and free the packets */
done:
lock_ReleaseMutex(&scp->mx);
- lock_ReleaseMutex(&fidp->mx);
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
if (code == 0)
smb_SendTran2Error(vcp, p, op, CM_ERROR_NOACCESS);
return 0;
}
+
+ scp = fidp->scp;
+ cm_HoldSCache(scp);
lock_ReleaseMutex(&fidp->mx);
osi_Log1(smb_logp, "T2 SFileInfo type 0x%x", infoLevel);
goto done;
}
- scp = fidp->scp;
-
if (infoLevel == SMB_QUERY_FILE_BASIC_INFO) {
FILETIME lastMod;
unsigned int attribute;
/* lock the vnode with a callback; we need the current status
* to determine what the new status is, in some cases.
*/
- lock_ObtainMutex(&fidp->mx);
lock_ObtainMutex(&scp->mx);
code = cm_SyncOp(scp, NULL, userp, &req, 0,
CM_SCACHESYNC_GETSTATUS
| CM_SCACHESYNC_NEEDCALLBACK);
+ lock_ReleaseMutex(&scp->mx);
if (code) {
- lock_ReleaseMutex(&scp->mx);
goto done;
}
+ lock_ObtainMutex(&fidp->mx);
+ lock_ObtainMutex(&scp->mx);
+
/* prepare for setattr call */
attr.mask = 0;
}
done:
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
if (code == 0)
smb_ReleaseFID(fidp);
return CM_ERROR_BADFD;
}
+ scp = fidp->scp;
+ cm_HoldSCache(scp);
lock_ReleaseMutex(&fidp->mx);
/* set inp->fid so that later read calls in same msg can find fid */
userp = smb_GetUser(vcp, inp);
- scp = fidp->scp;
lock_ObtainMutex(&scp->mx);
code = cm_SyncOp(scp, NULL, userp, &req, 0,
doneSync:
lock_ReleaseMutex(&scp->mx);
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
smb_ReleaseFID(fidp);
return CM_ERROR_BADFD;
}
+ scp = fidp->scp;
+ cm_HoldSCache(scp);
lock_ReleaseMutex(&fidp->mx);
userp = smb_GetUser(vcp, inp);
- scp = fidp->scp;
-
/* otherwise, stat the file */
lock_ObtainMutex(&scp->mx);
code = cm_SyncOp(scp, NULL, userp, &req, 0,
CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
- if (code) goto done;
+ if (code)
+ goto done;
/* decode times. We need a search time, but the response to this
* call provides the date first, not the time, as returned in the
done:
lock_ReleaseMutex(&scp->mx);
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
return code;
smb_ReleaseFID(fidp);
return CM_ERROR_BADFD;
}
+ scp = fidp->scp;
+ cm_HoldSCache(scp);
lock_ReleaseMutex(&fidp->mx);
userp = smb_GetUser(vcp, inp);
- scp = fidp->scp;
-
/* now prepare to call cm_setattr. This message only sets various times,
* and AFS only implements mtime, and we'll set the mtime if that's
* requested. The others we'll ignore.
osi_Log1(smb_logp, "**smb_UnixTimeFromSearchTime failed searchTime=%ld", searchTime);
}
}
- else code = 0;
+ else
+ code = 0;
+ cm_ReleaseSCache(scp);
cm_ReleaseUser(userp);
smb_ReleaseFID(fidp);
return code;