static CHAR * RDR_extentBaseAddress = NULL;
void
-RDR_InitReq(cm_req_t *reqp)
+RDR_InitReq(cm_req_t *reqp, BOOL bWow64)
{
cm_InitReq(reqp);
reqp->flags |= CM_REQ_SOURCE_REDIR;
+ if (bWow64)
+ reqp->flags |= CM_REQ_WOW64;
}
void
extern char cm_CachePath[];
extern cm_config_data_t cm_data;
extern int smb_hideDotFiles;
- size_t cm_CachePathLen = strlen(cm_CachePath);
+ size_t CachePathLen;
+ DWORD TempPathLen;
size_t err;
- DWORD TempPathLen = ExpandEnvironmentStringsW(L"%TEMP%", NULL, 0);
MEMORYSTATUSEX memStatus;
DWORD maxMemoryCacheSize;
+ char FullCachePath[MAX_PATH];
+ char TempPath[MAX_PATH];
+ char FullTempPath[MAX_PATH];
+
+ /*
+ * The %TEMP% environment variable may be relative instead
+ * of absolute which can result in the redirector referring
+ * to a different directory than the service. The full path
+ * must therefore be obtained first.
+ */
+
+ CachePathLen = GetFullPathNameA(cm_CachePath, MAX_PATH, FullCachePath, NULL);
+ if (CachePathLen == 0) {
+ osi_Log0(afsd_logp, "RDR_SetInitParams Unable to obtain Full Cache Path");
+ return STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
+ TempPathLen = ExpandEnvironmentStringsA("%TEMP%", TempPath, MAX_PATH);
+ if (TempPathLen == 0) {
+ osi_Log0(afsd_logp, "RDR_SetInitParams Unable to expand %%TEMP%%");
+ return STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
+ TempPathLen = GetFullPathNameA(TempPath, MAX_PATH, FullTempPath, NULL);
+ if (TempPathLen == 0) {
+ osi_Log0(afsd_logp, "RDR_SetInitParams Unable to obtain Full Temp Path");
+ return STATUS_OBJECT_NAME_NOT_FOUND;
+ }
memStatus.dwLength = sizeof(memStatus);
if (GlobalMemoryStatusEx(&memStatus)) {
maxMemoryCacheSize = 65536;
}
- *pRedirInitInfoLen = (DWORD) (sizeof(AFSRedirectorInitInfo) + (cm_CachePathLen + TempPathLen) * sizeof(WCHAR));
+ *pRedirInitInfoLen = (DWORD) (sizeof(AFSRedirectorInitInfo) + (CachePathLen + TempPathLen) * sizeof(WCHAR));
*ppRedirInitInfo = (AFSRedirectorInitInfo *)malloc(*pRedirInitInfoLen);
(*ppRedirInitInfo)->Flags = smb_hideDotFiles ? AFS_REDIR_INIT_FLAG_HIDE_DOT_FILES : 0;
+ (*ppRedirInitInfo)->Flags |= cm_shortNames ? 0 : AFS_REDIR_INIT_FLAG_DISABLE_SHORTNAMES;
(*ppRedirInitInfo)->MaximumChunkLength = cm_data.chunkSize;
(*ppRedirInitInfo)->GlobalFileId.Cell = cm_data.rootFid.cell;
(*ppRedirInitInfo)->GlobalFileId.Volume = cm_data.rootFid.volume;
(*ppRedirInitInfo)->GlobalFileId.Hash = cm_data.rootFid.hash;
(*ppRedirInitInfo)->ExtentCount.QuadPart = cm_data.buf_nbuffers;
(*ppRedirInitInfo)->CacheBlockSize = cm_data.blockSize;
- (*ppRedirInitInfo)->MaxPathLinkCount = 512; /* this needs to become a registry value */
- (*ppRedirInitInfo)->NameArrayLength = 32; /* this needs to become a registry value */
+ (*ppRedirInitInfo)->MaxPathLinkCount = MAX_FID_COUNT;
+ (*ppRedirInitInfo)->NameArrayLength = MAX_FID_COUNT;
if (cm_virtualCache || cm_data.bufferSize <= maxMemoryCacheSize) {
osi_Log0(afsd_logp, "RDR_SetInitParams Initializing Memory Extent Interface");
(*ppRedirInitInfo)->MemoryCacheOffset.QuadPart = (LONGLONG)cm_data.bufDataBaseAddress;
} else {
(*ppRedirInitInfo)->MemoryCacheOffset.QuadPart = 0;
(*ppRedirInitInfo)->MemoryCacheLength.QuadPart = 0;
- (*ppRedirInitInfo)->CacheFileNameLength = (ULONG) (cm_CachePathLen * sizeof(WCHAR));
- err = mbstowcs((*ppRedirInitInfo)->CacheFileName, cm_CachePath, (cm_CachePathLen + 1) *sizeof(WCHAR));
+ (*ppRedirInitInfo)->CacheFileNameLength = (ULONG) (CachePathLen * sizeof(WCHAR));
+ err = mbstowcs((*ppRedirInitInfo)->CacheFileName, FullCachePath, (CachePathLen + 1) *sizeof(WCHAR));
if (err == -1) {
free(*ppRedirInitInfo);
osi_Log0(afsd_logp, "RDR_SetInitParams Invalid Object Name");
}
(*ppRedirInitInfo)->DumpFileLocationOffset = FIELD_OFFSET(AFSRedirectorInitInfo, CacheFileName) + (*ppRedirInitInfo)->CacheFileNameLength;
(*ppRedirInitInfo)->DumpFileLocationLength = (TempPathLen - 1) * sizeof(WCHAR);
- ExpandEnvironmentStringsW(L"%TEMP%",
- (LPWSTR)(((PBYTE)(*ppRedirInitInfo)) + (*ppRedirInitInfo)->DumpFileLocationOffset),
- TempPathLen);
+
+ err = mbstowcs((((PBYTE)(*ppRedirInitInfo)) + (*ppRedirInitInfo)->DumpFileLocationOffset),
+ FullTempPath, (TempPathLen + 1) *sizeof(WCHAR));
+ if (err == -1) {
+ free(*ppRedirInitInfo);
+ osi_Log0(afsd_logp, "RDR_SetInitParams Invalid Object Name");
+ return STATUS_OBJECT_NAME_INVALID;
+ }
osi_Log0(afsd_logp,"RDR_SetInitParams Success");
return 0;
cm_scache_t * dscp = NULL;
cm_req_t req;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_EnumerateDirectory FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
DirID.Cell, DirID.Volume, DirID.Vnode, DirID.Unique);
code = RDR_PopulateCurrentEntry( pCurrentEntry, dwMaxEntryLength,
dscp, scp, userp, &req,
entryp->name,
- cm_Is8Dot3(entryp->name) ? NULL : entryp->shortName,
+ cm_shortNames && cm_Is8Dot3(entryp->name) ? NULL : entryp->shortName,
(bWow64 ? RDR_POP_WOW64 : 0) |
(bSkipStatus ? RDR_POP_NO_GETSTATUS : 0),
code,
code = RDR_PopulateCurrentEntryNoScp( pCurrentEntry, dwMaxEntryLength,
dscp, &entryp->fid, userp, &req,
entryp->name,
- cm_Is8Dot3(entryp->name) ? NULL : entryp->shortName,
+ cm_shortNames && cm_Is8Dot3(entryp->name) ? NULL : entryp->shortName,
(bWow64 ? RDR_POP_WOW64 : 0),
code,
&pCurrentEntry, &dwMaxEntryLength);
StringCchCopyNW(FileName, 260, FileNameCounted, FileNameLength / sizeof(WCHAR));
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_EvaluateNodeByName parent FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
ParentID.Cell, ParentID.Volume, ParentID.Vnode, ParentID.Unique);
/* Allocate enough room to add a volume prefix if necessary */
- cbName = FileNameLength + (CM_PREFIX_VOL_CCH + 1) * sizeof(WCHAR);
+ cbName = FileNameLength + (CM_PREFIX_VOL_CCH + 64) * sizeof(WCHAR);
wszName = malloc(cbName);
if (!wszName) {
osi_Log0(afsd_logp, "RDR_EvaluateNodeByName Out of Memory");
code = cm_Lookup(dscp, wszName, CM_FLAG_CHECKPATH, userp, &req, &scp);
if ((code == CM_ERROR_NOSUCHPATH || code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BPLUS_NOMATCH) &&
- (wcschr(wszName, '%') != NULL || wcschr(wszName, '#') != NULL)) {
- /*
- * A volume reference: <cell>{%,#}<volume> -> @vol:<cell>{%,#}<volume>
- */
- StringCchCopyNW(wszName, cbName, _C(CM_PREFIX_VOL), CM_PREFIX_VOL_CCH);
- StringCbCatNW(wszName, cbName, FileName, FileNameLength);
- bVol = TRUE;
+ dscp == cm_data.rootSCachep) {
+
+ if (wcschr(wszName, '%') != NULL || wcschr(wszName, '#') != NULL) {
+ /*
+ * A volume reference: <cell>{%,#}<volume> -> @vol:<cell>{%,#}<volume>
+ */
+ StringCchCopyNW(wszName, cbName, _C(CM_PREFIX_VOL), CM_PREFIX_VOL_CCH);
+ StringCbCatNW(wszName, cbName, FileName, FileNameLength);
+ bVol = TRUE;
+
+ code = cm_EvaluateVolumeReference(wszName, CM_FLAG_CHECKPATH, userp, &req, &scp);
+ }
+#ifdef AFS_FREELANCE_CLIENT
+ else if (dscp->fid.cell == AFS_FAKE_ROOT_CELL_ID && dscp->fid.volume == AFS_FAKE_ROOT_VOL_ID &&
+ dscp->fid.vnode == 1 && dscp->fid.unique == 1) {
+ /*
+ * If this is the Freelance volume root directory then treat unrecognized
+ * names as cell names and attempt to find the appropriate "root.cell".
+ */
+ StringCchCopyNW(wszName, cbName, _C(CM_PREFIX_VOL), CM_PREFIX_VOL_CCH);
+ if (FileName[0] == L'.') {
+ StringCbCatNW(wszName, cbName, &FileName[1], FileNameLength);
+ StringCbCatNW(wszName, cbName, L"%", sizeof(WCHAR));
+ } else {
+ StringCbCatNW(wszName, cbName, FileName, FileNameLength);
+ StringCbCatNW(wszName, cbName, L"#", sizeof(WCHAR));
+ }
+ StringCbCatNW(wszName, cbName, L"root.cell", 9 * sizeof(WCHAR));
+ bVol = TRUE;
- code = cm_EvaluateVolumeReference(wszName, CM_FLAG_CHECKPATH, userp, &req, &scp);
+ code = cm_EvaluateVolumeReference(wszName, CM_FLAG_CHECKPATH, userp, &req, &scp);
+ }
+#endif
}
if (code == 0 && scp) {
wchar_t shortName[13]=L"";
- if (bVol) {
+ if (!cm_shortNames) {
+ shortName[0] = L'\0';
+ } else if (bVol) {
cm_Gen8Dot3VolNameW(scp->fid.cell, scp->fid.volume, shortName, NULL);
} else if (!cm_Is8Dot3(wszName)) {
cm_dirFid_t dfid;
cm_Gen8Dot3NameIntW(FileName, &dfid, shortName, NULL);
} else {
- shortName[0] = '\0';
+ shortName[0] = L'\0';
}
code = RDR_PopulateCurrentEntry(pCurrentEntry, dwRemaining,
dwRemaining -= (sizeof( AFSFileEvalResultCB) - sizeof( AFSDirEnumEntry));
}
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
if (SourceID.Cell != 0) {
cm_SetFid(&Fid, SourceID.Cell, SourceID.Volume, SourceID.Vnode, SourceID.Unique);
CreateCB->ParentId.Vnode, CreateCB->ParentId.Unique);
osi_Log1(afsd_logp, "... name=%S", osi_LogSaveStringW(afsd_logp, FileName));
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
memset(&setAttr, 0, sizeof(cm_attr_t));
*ResultCB = (AFSCommResult *)malloc(size);
cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
lock_ReleaseWrite(&dscp->rw);
- dfid.vnode = htonl(scp->fid.vnode);
- dfid.unique = htonl(scp->fid.unique);
+ if (cm_shortNames) {
+ dfid.vnode = htonl(scp->fid.vnode);
+ dfid.unique = htonl(scp->fid.unique);
- if (!cm_Is8Dot3(FileName))
- cm_Gen8Dot3NameIntW(FileName, &dfid, shortName, NULL);
- else
- shortName[0] = '\0';
+ if (!cm_Is8Dot3(FileName))
+ cm_Gen8Dot3NameIntW(FileName, &dfid, shortName, NULL);
+ else
+ shortName[0] = '\0';
+ }
code = RDR_PopulateCurrentEntry(&pResultCB->DirEnum, dwRemaining,
dscp, scp, userp, &req, FileName, shortName,
DWORD status;
BOOL bScpLocked = FALSE;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
memset(&setAttr, 0, sizeof(cm_attr_t));
osi_Log4(afsd_logp, "RDR_UpdateFileEntry parent FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
BOOL bFlushFile = FALSE;
cm_key_t key;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
memset(&setAttr, 0, sizeof(cm_attr_t));
osi_Log4(afsd_logp, "RDR_CleanupFileEntry parent FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
}
cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
- if ((bLastHandle || bFlushFile) &&
+ if (bLastHandle && (scp->fileType == CM_SCACHETYPE_FILE) &&
scp->redirBufCount > 0)
{
LARGE_INTEGER heldExtents;
scp->flags &= ~CM_SCACHEFLAG_RDR_IN_USE;
}
- if (bLastHandle || bFlushFile) {
- if (!bScpLocked) {
- lock_ObtainWrite(&scp->rw);
- bScpLocked = TRUE;
- }
- code = cm_SyncOp(scp, NULL, userp, &req, PRSFS_WRITE,
- CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
- if (code == 0) {
- if (bScpLocked) {
- lock_ReleaseWrite(&scp->rw);
- bScpLocked = FALSE;
- }
+ /* If not a readonly object, flush dirty data and update metadata */
+ if (!(scp->flags & CM_SCACHEFLAG_RO)) {
+ if ((scp->fileType == CM_SCACHETYPE_FILE) && (bLastHandle || bFlushFile)) {
+ /* Serialize with any outstanding AsyncStore operation */
+ code = cm_SyncOp(scp, NULL, userp, &req, 0, CM_SCACHESYNC_ASYNCSTORE);
+ if (code == 0) {
+ cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_ASYNCSTORE);
- code = cm_FSync(scp, userp, &req, bScpLocked);
- }
- if (bLastHandle && code)
- goto on_error;
- }
+ code = cm_SyncOp(scp, NULL, userp, &req, PRSFS_WRITE,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ /*
+ * If we only have 'i' bits, then we should still be able to
+ * set flush the file.
+ */
+ if (code == CM_ERROR_NOACCESS && scp->creator == userp) {
+ code = cm_SyncOp(scp, NULL, userp, &req, PRSFS_INSERT,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ }
+ if (code == 0) {
+ if (bScpLocked) {
+ lock_ReleaseWrite(&scp->rw);
+ bScpLocked = FALSE;
+ }
- if (bUnlockFile || bDeleteFile) {
- if (!bScpLocked) {
- lock_ObtainWrite(&scp->rw);
- bScpLocked = TRUE;
- }
- code = cm_SyncOp(scp, NULL, userp, &req, 0,
- CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS | CM_SCACHESYNC_LOCK);
- if (code) {
- osi_Log2(afsd_logp, "RDR_CleanupFileEntry cm_SyncOp (2) failure scp=0x%p code=0x%x",
- scp, code);
- goto on_error;
+ code = cm_FSync(scp, userp, &req, bScpLocked);
+ }
+ }
+ if (bLastHandle && code)
+ goto unlock;
}
- key = cm_GenerateKey(CM_SESSION_IFS, CleanupCB->ProcessId, 0);
-
- /* the scp is now locked and current */
- code = cm_UnlockByKey(scp, key,
- bDeleteFile ? CM_UNLOCK_FLAG_BY_FID : 0,
- userp, &req);
-
- cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS | CM_SCACHESYNC_LOCK);
-
- if (code)
- goto on_error;
- }
+ if (CleanupCB->ChangeTime.QuadPart) {
- if (CleanupCB->ChangeTime.QuadPart) {
+ if (scp->fileType == CM_SCACHETYPE_FILE) {
+ /* Do not set length and other attributes at the same time */
+ if (scp->length.QuadPart != CleanupCB->AllocationSize.QuadPart) {
+ osi_Log2(afsd_logp, "RDR_CleanupFileEntry Length Change 0x%x -> 0x%x",
+ (afs_uint32)scp->length.QuadPart, (afs_uint32)CleanupCB->AllocationSize.QuadPart);
+ setAttr.mask |= CM_ATTRMASK_LENGTH;
+ setAttr.length.LowPart = CleanupCB->AllocationSize.LowPart;
+ setAttr.length.HighPart = CleanupCB->AllocationSize.HighPart;
- if (scp->fileType == CM_SCACHETYPE_FILE) {
- /* Do not set length and other attributes at the same time */
- if (scp->length.QuadPart != CleanupCB->AllocationSize.QuadPart) {
- osi_Log2(afsd_logp, "RDR_CleanupFileEntry Length Change 0x%x -> 0x%x",
- (afs_uint32)scp->length.QuadPart, (afs_uint32)CleanupCB->AllocationSize.QuadPart);
- setAttr.mask |= CM_ATTRMASK_LENGTH;
- setAttr.length.LowPart = CleanupCB->AllocationSize.LowPart;
- setAttr.length.HighPart = CleanupCB->AllocationSize.HighPart;
-
- if (bScpLocked) {
- lock_ReleaseWrite(&scp->rw);
- bScpLocked = FALSE;
+ if (bScpLocked) {
+ lock_ReleaseWrite(&scp->rw);
+ bScpLocked = FALSE;
+ }
+ code = cm_SetAttr(scp, &setAttr, userp, &req);
+ if (code)
+ goto unlock;
+ setAttr.mask = 0;
}
- code = cm_SetAttr(scp, &setAttr, userp, &req);
- if (code)
- goto on_error;
- setAttr.mask = 0;
}
- }
- if (!bScpLocked) {
- lock_ObtainWrite(&scp->rw);
- bScpLocked = TRUE;
- }
+ if (!bScpLocked) {
+ lock_ObtainWrite(&scp->rw);
+ bScpLocked = TRUE;
+ }
- if ((scp->unixModeBits & 0200) && (CleanupCB->FileAttributes & FILE_ATTRIBUTE_READONLY)) {
- setAttr.mask |= CM_ATTRMASK_UNIXMODEBITS;
- setAttr.unixModeBits = scp->unixModeBits & ~0222;
- } else if (!(scp->unixModeBits & 0200) && !(CleanupCB->FileAttributes & FILE_ATTRIBUTE_READONLY)) {
- setAttr.mask |= CM_ATTRMASK_UNIXMODEBITS;
- setAttr.unixModeBits = scp->unixModeBits | 0222;
+ if ((scp->unixModeBits & 0200) && (CleanupCB->FileAttributes & FILE_ATTRIBUTE_READONLY)) {
+ setAttr.mask |= CM_ATTRMASK_UNIXMODEBITS;
+ setAttr.unixModeBits = scp->unixModeBits & ~0222;
+ } else if (!(scp->unixModeBits & 0200) && !(CleanupCB->FileAttributes & FILE_ATTRIBUTE_READONLY)) {
+ setAttr.mask |= CM_ATTRMASK_UNIXMODEBITS;
+ setAttr.unixModeBits = scp->unixModeBits | 0222;
+ }
}
- }
- if (CleanupCB->LastWriteTime.QuadPart) {
- ft.dwLowDateTime = CleanupCB->LastWriteTime.LowPart;
- ft.dwHighDateTime = CleanupCB->LastWriteTime.HighPart;
+ if (CleanupCB->LastWriteTime.QuadPart) {
+ ft.dwLowDateTime = CleanupCB->LastWriteTime.LowPart;
+ ft.dwHighDateTime = CleanupCB->LastWriteTime.HighPart;
- cm_UnixTimeFromLargeSearchTime(&clientModTime, &ft);
- if (scp->clientModTime != clientModTime) {
- setAttr.mask |= CM_ATTRMASK_CLIENTMODTIME;
- setAttr.clientModTime = clientModTime;
+ cm_UnixTimeFromLargeSearchTime(&clientModTime, &ft);
+ if (scp->clientModTime != clientModTime) {
+ setAttr.mask |= CM_ATTRMASK_CLIENTMODTIME;
+ setAttr.clientModTime = clientModTime;
+ }
}
- }
- /* call setattr */
- if (setAttr.mask) {
- lock_ReleaseWrite(&scp->rw);
- bScpLocked = FALSE;
- code = cm_SetAttr(scp, &setAttr, userp, &req);
- } else
- code = 0;
+ /* call setattr */
+ if (setAttr.mask) {
+ if (bScpLocked) {
+ lock_ReleaseWrite(&scp->rw);
+ bScpLocked = FALSE;
+ }
+ code = cm_SetAttr(scp, &setAttr, userp, &req);
+ } else
+ code = 0;
+ }
+ unlock:
/* Now drop the lock enforcing the share access */
if ( CleanupCB->FileAccess != AFS_FILE_ACCESS_NOLOCK) {
unsigned int sLockType;
}
}
+ if (bUnlockFile || bDeleteFile) {
+ if (!bScpLocked) {
+ lock_ObtainWrite(&scp->rw);
+ bScpLocked = TRUE;
+ }
+ code = cm_SyncOp(scp, NULL, userp, &req, 0,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS | CM_SCACHESYNC_LOCK);
+ if (code) {
+ osi_Log2(afsd_logp, "RDR_CleanupFileEntry cm_SyncOp (2) failure scp=0x%p code=0x%x",
+ scp, code);
+ goto on_error;
+ }
+
+ key = cm_GenerateKey(CM_SESSION_IFS, CleanupCB->ProcessId, 0);
+
+ /* the scp is now locked and current */
+ code = cm_UnlockByKey(scp, key,
+ bDeleteFile ? CM_UNLOCK_FLAG_BY_FID : 0,
+ userp, &req);
+
+ cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS | CM_SCACHESYNC_LOCK);
+
+ if (code)
+ goto on_error;
+ }
+
on_error:
if (bDscpLocked)
lock_ReleaseWrite(&dscp->rw);
osi_LogSaveStringW(afsd_logp, FileName),
bCheckOnly);
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
memset(&setAttr, 0, sizeof(cm_attr_t));
*ResultCB = (AFSCommResult *)malloc( size);
afs_uint32 code;
DWORD status;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
StringCchCopyNW(SourceFileName, 260, SourceFileNameCounted, SourceFileNameLength / sizeof(WCHAR));
StringCchCopyNW(TargetFileName, 260, TargetFileNameCounted, TargetFileNameLength / sizeof(WCHAR));
cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
lock_ReleaseWrite(&scp->rw);
- dfid.vnode = htonl(scp->fid.vnode);
- dfid.unique = htonl(scp->fid.unique);
+ if (cm_shortNames) {
+ dfid.vnode = htonl(scp->fid.vnode);
+ dfid.unique = htonl(scp->fid.unique);
- if (!cm_Is8Dot3(TargetFileName))
- cm_Gen8Dot3NameIntW(TargetFileName, &dfid, shortName, NULL);
- else
- shortName[0] = '\0';
+ if (!cm_Is8Dot3(TargetFileName))
+ cm_Gen8Dot3NameIntW(TargetFileName, &dfid, shortName, NULL);
+ else
+ shortName[0] = '\0';
+ }
RDR_PopulateCurrentEntry(&pResultCB->DirEnum, dwRemaining,
newDscp, scp, userp, &req, TargetFileName, shortName,
return;
}
+/*
+ * AFS does not support cross-directory hard links but RDR_HardLinkFileEntry
+ * is written as if AFS does. The check for cross-directory links is
+ * implemented in cm_Link().
+ *
+ * Windows supports optional ReplaceIfExists functionality. The AFS file
+ * server does not. If the target name already exists and bReplaceIfExists
+ * is true, check to see if the user has insert permission before calling
+ * cm_Unlink() on the existing object. If the user does not have insert
+ * permission return STATUS_ACCESS_DENIED.
+ */
+
+void
+RDR_HardLinkFileEntry( IN cm_user_t *userp,
+ IN WCHAR *SourceFileNameCounted,
+ IN DWORD SourceFileNameLength,
+ IN AFSFileID SourceFileId,
+ IN AFSFileHardLinkCB *pHardLinkCB,
+ IN BOOL bWow64,
+ IN DWORD ResultBufferLength,
+ IN OUT AFSCommResult **ResultCB)
+{
+
+ AFSFileHardLinkResultCB *pResultCB = NULL;
+ size_t size = sizeof(AFSCommResult) + ResultBufferLength - 1;
+ AFSFileID SourceParentId = pHardLinkCB->SourceParentId;
+ AFSFileID TargetParentId = pHardLinkCB->TargetParentId;
+ WCHAR * TargetFileNameCounted = pHardLinkCB->TargetName;
+ DWORD TargetFileNameLength = pHardLinkCB->TargetNameLength;
+ cm_fid_t SourceParentFid;
+ cm_fid_t TargetParentFid;
+ cm_fid_t SourceFid;
+ cm_fid_t OrigTargetFid = {0,0,0,0,0};
+ cm_scache_t * srcDscp = NULL;
+ cm_scache_t * targetDscp = NULL;
+ cm_scache_t * srcScp = NULL;
+ cm_dirOp_t dirop;
+ wchar_t shortName[13];
+ wchar_t SourceFileName[260];
+ wchar_t TargetFileName[260];
+ cm_dirFid_t dfid;
+ cm_req_t req;
+ afs_uint32 code;
+ DWORD status;
+
+ RDR_InitReq(&req, bWow64);
+
+ StringCchCopyNW(SourceFileName, 260, SourceFileNameCounted, SourceFileNameLength / sizeof(WCHAR));
+ StringCchCopyNW(TargetFileName, 260, TargetFileNameCounted, TargetFileNameLength / sizeof(WCHAR));
+
+ osi_Log4(afsd_logp, "RDR_HardLinkFileEntry Source Parent FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
+ SourceParentId.Cell, SourceParentId.Volume,
+ SourceParentId.Vnode, SourceParentId.Unique);
+ osi_Log2(afsd_logp, "... Source Name=%S Length %u", osi_LogSaveStringW(afsd_logp, SourceFileName), SourceFileNameLength);
+ osi_Log4(afsd_logp, "... Target Parent FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
+ TargetParentId.Cell, TargetParentId.Volume,
+ TargetParentId.Vnode, TargetParentId.Unique);
+ osi_Log2(afsd_logp, "... Target Name=%S Length %u", osi_LogSaveStringW(afsd_logp, TargetFileName), TargetFileNameLength);
+
+ *ResultCB = (AFSCommResult *)malloc( size);
+ if (!(*ResultCB))
+ return;
+
+ memset( *ResultCB,
+ '\0',
+ size);
+
+ pResultCB = (AFSFileHardLinkResultCB *)(*ResultCB)->ResultData;
+
+ if (SourceFileNameLength == 0 || TargetFileNameLength == 0)
+ {
+ osi_Log2(afsd_logp, "RDR_HardLinkFileEntry Invalid Name Length: src %u target %u",
+ SourceFileNameLength, TargetFileNameLength);
+ (*ResultCB)->ResultStatus = STATUS_INVALID_PARAMETER;
+ return;
+ }
+
+ SourceFid.cell = SourceFileId.Cell;
+ SourceFid.volume = SourceFileId.Volume;
+ SourceFid.vnode = SourceFileId.Vnode;
+ SourceFid.unique = SourceFileId.Unique;
+ SourceFid.hash = SourceFileId.Hash;
+
+ SourceParentFid.cell = SourceParentId.Cell;
+ SourceParentFid.volume = SourceParentId.Volume;
+ SourceParentFid.vnode = SourceParentId.Vnode;
+ SourceParentFid.unique = SourceParentId.Unique;
+ SourceParentFid.hash = SourceParentId.Hash;
+
+ TargetParentFid.cell = TargetParentId.Cell;
+ TargetParentFid.volume = TargetParentId.Volume;
+ TargetParentFid.vnode = TargetParentId.Vnode;
+ TargetParentFid.unique = TargetParentId.Unique;
+ TargetParentFid.hash = TargetParentId.Hash;
+
+ code = cm_GetSCache(&SourceFid, NULL, &srcScp, userp, &req);
+ if (code) {
+ osi_Log1(afsd_logp, "RDR_HardLinkFileEntry cm_GetSCache source failed code 0x%x", code);
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ (*ResultCB)->ResultStatus = status;
+ return;
+ }
+
+ code = cm_GetSCache(&TargetParentFid, NULL, &targetDscp, userp, &req);
+ if (code) {
+ osi_Log1(afsd_logp, "RDR_HardLinkFileEntry cm_GetSCache target parent failed code 0x%x", code);
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ (*ResultCB)->ResultStatus = status;
+ cm_ReleaseSCache(srcScp);
+ return;
+ }
+
+ lock_ObtainWrite(&targetDscp->rw);
+ code = cm_SyncOp(targetDscp, NULL, userp, &req, PRSFS_INSERT,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ if (code) {
+ osi_Log2(afsd_logp, "RDR_HardLinkFileEntry cm_SyncOp targetDscp 0x%p failed code 0x%x", targetDscp, code);
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ (*ResultCB)->ResultStatus = status;
+ lock_ReleaseWrite(&targetDscp->rw);
+ cm_ReleaseSCache(srcScp);
+ cm_ReleaseSCache(targetDscp);
+ return;
+ }
+
+ cm_SyncOpDone(targetDscp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ lock_ReleaseWrite(&targetDscp->rw);
+
+ if (targetDscp->fileType != CM_SCACHETYPE_DIRECTORY) {
+ osi_Log1(afsd_logp, "RDR_HardLinkFileEntry targetDscp 0x%p not a directory", targetDscp);
+ (*ResultCB)->ResultStatus = STATUS_NOT_A_DIRECTORY;
+ cm_ReleaseSCache(srcScp);
+ cm_ReleaseSCache(targetDscp);
+ return;
+ }
+
+ if ( cm_FidCmp(&SourceParentFid, &TargetParentFid) ) {
+ code = cm_GetSCache(&SourceParentFid, NULL, &srcDscp, userp, &req);
+ if (code) {
+ osi_Log1(afsd_logp, "RDR_HardLinkFileEntry cm_GetSCache source parent failed code 0x%x", code);
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ if ( status == STATUS_INVALID_HANDLE)
+ status = STATUS_OBJECT_PATH_INVALID;
+ (*ResultCB)->ResultStatus = status;
+ cm_ReleaseSCache(srcScp);
+ cm_ReleaseSCache(targetDscp);
+ return;
+ }
+
+ lock_ObtainWrite(&srcDscp->rw);
+ code = cm_SyncOp(srcDscp, NULL, userp, &req, 0,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ if (code) {
+ osi_Log2(afsd_logp, "RDR_HardLinkFileEntry cm_SyncOp srcDscp 0x%p failed code 0x%x", srcDscp, code);
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ if ( status == STATUS_INVALID_HANDLE)
+ status = STATUS_OBJECT_PATH_INVALID;
+ (*ResultCB)->ResultStatus = status;
+ lock_ReleaseWrite(&srcDscp->rw);
+ if (srcDscp != targetDscp)
+ cm_ReleaseSCache(srcDscp);
+ cm_ReleaseSCache(targetDscp);
+ cm_ReleaseSCache(srcScp);
+ return;
+ }
+
+ cm_SyncOpDone(srcDscp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ lock_ReleaseWrite(&srcDscp->rw);
+
+ if (srcDscp->fileType != CM_SCACHETYPE_DIRECTORY) {
+ osi_Log1(afsd_logp, "RDR_HardLinkFileEntry srcDscp 0x%p not a directory", srcDscp);
+ (*ResultCB)->ResultStatus = STATUS_NOT_A_DIRECTORY;
+ if (srcDscp != targetDscp)
+ cm_ReleaseSCache(srcDscp);
+ cm_ReleaseSCache(targetDscp);
+ cm_ReleaseSCache(srcScp);
+ return;
+ }
+ } else {
+ srcDscp = targetDscp;
+ }
+
+ /* Obtain the target FID if it exists */
+ code = cm_BeginDirOp( targetDscp, userp, &req, CM_DIRLOCK_READ, CM_DIROP_FLAG_NONE, &dirop);
+ if (code == 0) {
+ code = cm_BPlusDirLookup(&dirop, TargetFileName, &OrigTargetFid);
+ cm_EndDirOp(&dirop);
+ }
+
+ if (OrigTargetFid.vnode) {
+
+ /* An object exists with the target name */
+ if (!pHardLinkCB->bReplaceIfExists) {
+ osi_Log0(afsd_logp, "RDR_HardLinkFileEntry target name collision and !ReplaceIfExists");
+ (*ResultCB)->ResultStatus = STATUS_OBJECT_NAME_COLLISION;
+ if (srcDscp != targetDscp)
+ cm_ReleaseSCache(srcDscp);
+ cm_ReleaseSCache(targetDscp);
+ cm_ReleaseSCache(srcScp);
+ return;
+ }
+
+ lock_ObtainWrite(&targetDscp->rw);
+ code = cm_SyncOp(targetDscp, NULL, userp, &req, PRSFS_INSERT | PRSFS_DELETE,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ if (code) {
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ (*ResultCB)->ResultStatus = status;
+ lock_ReleaseWrite(&srcDscp->rw);
+ if (srcDscp != targetDscp)
+ cm_ReleaseSCache(srcDscp);
+ cm_ReleaseSCache(targetDscp);
+ cm_ReleaseSCache(srcScp);
+ return;
+ }
+ cm_SyncOpDone(targetDscp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ lock_ReleaseWrite(&targetDscp->rw);
+
+ code = cm_Unlink(targetDscp, NULL, TargetFileName, userp, &req);
+ if (code) {
+ osi_Log1(afsd_logp, "RDR_HardLinkFileEntry cm_Unlink code 0x%x", code);
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ (*ResultCB)->ResultStatus = status;
+ lock_ReleaseWrite(&srcDscp->rw);
+ if (srcDscp != targetDscp)
+ cm_ReleaseSCache(srcDscp);
+ cm_ReleaseSCache(targetDscp);
+ cm_ReleaseSCache(srcScp);
+ return;
+ }
+ }
+
+ code = cm_Link( targetDscp, TargetFileName, srcScp, 0, userp, &req);
+ if (code == 0) {
+ cm_fid_t TargetFid;
+ cm_scache_t *targetScp = 0;
+ DWORD dwRemaining;
+
+ (*ResultCB)->ResultBufferLength = ResultBufferLength;
+ dwRemaining = ResultBufferLength - sizeof( AFSFileHardLinkResultCB) + sizeof( AFSDirEnumEntry);
+ (*ResultCB)->ResultStatus = 0;
+
+ pResultCB->SourceParentDataVersion.QuadPart = srcDscp->dataVersion;
+ pResultCB->TargetParentDataVersion.QuadPart = targetDscp->dataVersion;
+
+ osi_Log2(afsd_logp, "RDR_HardLinkFileEntry cm_Link srcDscp 0x%p targetDscp 0x%p SUCCESS",
+ srcDscp, targetDscp);
+
+ code = cm_BeginDirOp( targetDscp, userp, &req, CM_DIRLOCK_READ, CM_DIROP_FLAG_NONE, &dirop);
+ if (code == 0) {
+ code = cm_BPlusDirLookup(&dirop, TargetFileName, &TargetFid);
+ cm_EndDirOp(&dirop);
+ }
+
+ if (code != 0) {
+ osi_Log1(afsd_logp, "RDR_HardLinkFileEntry cm_BPlusDirLookup failed code 0x%x",
+ code);
+ (*ResultCB)->ResultStatus = STATUS_OBJECT_PATH_INVALID;
+ if (srcDscp != targetDscp)
+ cm_ReleaseSCache(srcDscp);
+ cm_ReleaseSCache(srcScp);
+ cm_ReleaseSCache(targetDscp);
+ return;
+ }
+
+ osi_Log4(afsd_logp, "RDR_HardLinkFileEntry Target FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
+ TargetFid.cell, TargetFid.volume,
+ TargetFid.vnode, TargetFid.unique);
+
+ code = cm_GetSCache(&TargetFid, &targetDscp->fid, &targetScp, userp, &req);
+ if (code) {
+ osi_Log1(afsd_logp, "RDR_HardLinkFileEntry cm_GetSCache target failed code 0x%x", code);
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ (*ResultCB)->ResultStatus = status;
+ if (srcDscp != targetDscp)
+ cm_ReleaseSCache(srcDscp);
+ cm_ReleaseSCache(srcScp);
+ cm_ReleaseSCache(targetDscp);
+ return;
+ }
+
+ /* Make sure the source vnode is current */
+ lock_ObtainWrite(&targetScp->rw);
+ code = cm_SyncOp(targetScp, NULL, userp, &req, 0,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ if (code) {
+ osi_Log2(afsd_logp, "RDR_HardLinkFileEntry cm_SyncOp scp 0x%p failed code 0x%x",
+ targetScp, code);
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ (*ResultCB)->ResultStatus = status;
+ lock_ReleaseWrite(&targetScp->rw);
+ cm_ReleaseSCache(targetScp);
+ if (srcDscp != targetDscp)
+ cm_ReleaseSCache(srcDscp);
+ cm_ReleaseSCache(srcScp);
+ cm_ReleaseSCache(targetDscp);
+ return;
+ }
+
+ cm_SyncOpDone(targetScp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ lock_ReleaseWrite(&targetScp->rw);
+
+ if (cm_shortNames) {
+ dfid.vnode = htonl(targetScp->fid.vnode);
+ dfid.unique = htonl(targetScp->fid.unique);
+
+ if (!cm_Is8Dot3(TargetFileName))
+ cm_Gen8Dot3NameIntW(TargetFileName, &dfid, shortName, NULL);
+ else
+ shortName[0] = '\0';
+ }
+
+ RDR_PopulateCurrentEntry(&pResultCB->DirEnum, dwRemaining,
+ targetDscp, targetScp, userp, &req, TargetFileName, shortName,
+ RDR_POP_FOLLOW_MOUNTPOINTS | RDR_POP_EVALUATE_SYMLINKS,
+ 0, NULL, &dwRemaining);
+ (*ResultCB)->ResultBufferLength = ResultBufferLength - dwRemaining;
+ cm_ReleaseSCache(targetScp);
+
+ osi_Log0(afsd_logp, "RDR_HardLinkFileEntry SUCCESS");
+ } else {
+ osi_Log3(afsd_logp, "RDR_HardLinkFileEntry cm_Link srcDscp 0x%p targetDscp 0x%p failed code 0x%x",
+ srcDscp, targetDscp, code);
+ smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
+ (*ResultCB)->ResultStatus = status;
+ (*ResultCB)->ResultBufferLength = 0;
+ }
+
+ cm_ReleaseSCache(srcScp);
+ if (srcDscp != targetDscp)
+ cm_ReleaseSCache(srcDscp);
+ cm_ReleaseSCache(targetDscp);
+ return;
+}
+
void
RDR_FlushFileEntry( IN cm_user_t *userp,
IN AFSFileID FileId,
char dbgstr[1024];
#endif
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_FlushFileEntry File FID cell 0x%x vol 0x%x vno 0x%x uniq 0x%x",
FileId.Cell, FileId.Volume,
cm_req_t req;
DWORD status;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_OpenFileEntry File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
FileId.Cell, FileId.Volume,
userp, &req, &ldp);
if (code == 0)
code = RDR_CheckAccess(scp, userp, &req, OpenCB->DesiredAccess, &pResultCB->GrantedAccess);
+
+
cm_CheckNTOpenDone(scp, userp, &req, &ldp);
} while (count < 100 && (code == CM_ERROR_RETRY || code == CM_ERROR_WOULDBLOCK));
}
cm_req_t req;
DWORD status;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_ReleaseFileAccess File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
FileId.Cell, FileId.Volume,
/* do the background fetch. */
afs_int32
-RDR_BkgFetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4,
- cm_user_t *userp, cm_req_t *reqp)
+RDR_BkgFetch(cm_scache_t *scp, void *rockp, cm_user_t *userp, cm_req_t *reqp)
{
osi_hyper_t length;
osi_hyper_t base;
FileId.Unique = scp->fid.unique;
FileId.Hash = scp->fid.hash;
- if ((GetTickCount() - reqp->startTime) / 1000 > HardDeadtimeout * 5) {
- RDR_SetFileStatus( &scp->fid, &userp->authgroup, STATUS_IO_TIMEOUT);
- return 0;
- }
-
fetched.LowPart = 0;
fetched.HighPart = 0;
tblocksize = ConvertLongToLargeInteger(cm_data.buf_blockSize);
- base.LowPart = p1;
- base.HighPart = p2;
- length.LowPart = p3;
- length.HighPart = p4;
-
+ base = ((rock_BkgFetch_t *)rockp)->base;
+ length = ((rock_BkgFetch_t *)rockp)->length;
end = LargeIntegerAdd(base, length);
osi_Log5(afsd_logp, "Starting BKG Fetch scp 0x%p offset 0x%x:%x length 0x%x:%x",
- scp, p2, p1, p4, p3);
+ scp, base.HighPart, base.LowPart, length.HighPart, length.LowPart);
/*
* Make sure we have a callback.
}
lock_ReleaseWrite(&scp->rw);
- dwResultBufferLength = (DWORD)(sizeof( AFSSetFileExtentsCB) + sizeof( AFSSetFileExtentsCB) * (length.QuadPart / cm_data.blockSize + 1));
+ dwResultBufferLength = (DWORD)(sizeof( AFSSetFileExtentsCB) + sizeof( AFSFileExtentCB) * (length.QuadPart / cm_data.blockSize + 1));
pResultCB = (AFSSetFileExtentsCB *)malloc( dwResultBufferLength );
if (!pResultCB)
return CM_ERROR_RETRY;
case RXKADNOAUTH:
case CM_ERROR_QUOTA:
case CM_ERROR_LOCK_CONFLICT:
+ case EIO:
+ case CM_ERROR_INVAL_NET_RESP:
+ case CM_ERROR_UNKNOWN:
/*
* these are fatal errors. deliver what we can
* and halt.
cm_req_t req;
BOOLEAN bBufRelease = TRUE;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
req.flags |= CM_REQ_NORETRY;
osi_Log4(afsd_logp, "RDR_RequestFileExtentsAsync File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
else
minLength = scp->length;
- if (!bHaveBuffer &&
- LargeIntegerGreaterThanOrEqualTo(bufp->offset, minLength)) {
- memset(bufp->datap, 0, cm_data.buf_blockSize);
- bufp->dataVersion = scp->dataVersion;
- bHaveBuffer = TRUE;
+ if (LargeIntegerGreaterThanOrEqualTo(bufp->offset, minLength)) {
+ if (!bHaveBuffer) {
+ memset(bufp->datap, 0, cm_data.buf_blockSize);
+ bufp->dataVersion = scp->dataVersion;
+ bHaveBuffer = TRUE;
+ }
+ else if (bufp->dataVersion == CM_BUF_VERSION_BAD) {
+ bufp->dataVersion = scp->dataVersion;
+ }
}
else if ((RequestExtentsCB->Flags & AFS_EXTENT_FLAG_CLEAN) &&
ByteOffset.QuadPart <= bufp->offset.QuadPart &&
buf_Release(bufp);
if (QueueLength) {
- cm_QueueBKGRequest(scp, RDR_BkgFetch, QueueOffset.LowPart, QueueOffset.HighPart,
- QueueLength, 0, userp, &req);
- osi_Log3(afsd_logp, "RDR_RequestFileExtentsAsync Queued a Background Fetch offset 0x%x:%x length 0x%x",
- QueueOffset.HighPart, QueueOffset.LowPart, QueueLength);
+ rock_BkgFetch_t * rockp = malloc(sizeof(*rockp));
+
+ if (rockp) {
+ req.flags &= ~CM_REQ_NORETRY;
+ rockp->base = QueueOffset;
+ rockp->length.LowPart = QueueLength;
+ rockp->length.HighPart = 0;
+
+ cm_QueueBKGRequest(scp, RDR_BkgFetch, rockp, userp, &req);
+ osi_Log3(afsd_logp, "RDR_RequestFileExtentsAsync Queued a Background Fetch offset 0x%x:%x length 0x%x",
+ QueueOffset.HighPart, QueueOffset.LowPart, QueueLength);
+ req.flags |= CM_REQ_NORETRY;
+ } else {
+ code = ENOMEM;
+ }
}
} else {
/* No error from buf_Get() can be fatal */
if (BeginOffset.QuadPart != EndOffset.QuadPart) {
afs_uint32 length = (afs_uint32)(EndOffset.QuadPart - BeginOffset.QuadPart);
+ rock_BkgFetch_t * rockp = malloc(sizeof(*rockp));
- cm_QueueBKGRequest(scp, RDR_BkgFetch, BeginOffset.LowPart, BeginOffset.HighPart,
- length, 0, userp, &req);
- osi_Log3(afsd_logp, "RDR_RequestFileExtentsAsync Queued a Background Fetch offset 0x%x:%x length 0x%x",
- BeginOffset.HighPart, BeginOffset.LowPart, length);
+ if (rockp) {
+ req.flags &= ~CM_REQ_NORETRY;
+ rockp->base = BeginOffset;
+ rockp->length.LowPart = length;
+ rockp->length.HighPart = 0;
+
+ cm_QueueBKGRequest(scp, RDR_BkgFetch, rockp, userp, &req);
+ osi_Log3(afsd_logp, "RDR_RequestFileExtentsAsync Queued a Background Fetch offset 0x%x:%x length 0x%x",
+ BeginOffset.HighPart, BeginOffset.LowPart, length);
+ } else {
+ code = ENOMEM;
+ }
}
cm_ReleaseSCache(scp);
int released = 0;
int deleted = 0;
DWORD status;
+ rock_BkgStore_t *rockp;
#ifdef ODS_DEBUG
#ifdef VALIDATE_CHECK_SUM
char md5dbg[33], md5dbg2[33], md5dbg3[33];
char dbgstr[1024];
#endif
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_ReleaseFileExtents File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
FileId.Cell, FileId.Volume,
pExtent->CacheOffset.LowPart);
osi_Log5( afsd_logp, "... belongs to bp 0x%p vol 0x%x vno 0x%x foffset 0x%x:%x",
wbp, wbp->fid.volume, wbp->fid.vnode, wbp->offset.HighPart, wbp->offset.LowPart);
-#ifdef DEBUG
- DebugBreak();
-#endif
}
buf_Release(bufp);
}
}
if (scp) {
- if (ReleaseExtentsCB->Flags & AFS_EXTENT_FLAG_FLUSH) {
+ if (deleted) {
+ code = 0;
+ } else if (ReleaseExtentsCB->Flags & AFS_EXTENT_FLAG_FLUSH) {
lock_ObtainWrite(&scp->rw);
code = cm_SyncOp(scp, NULL, userp, &req, PRSFS_WRITE,
CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ if (code == CM_ERROR_NOACCESS && scp->creator == userp) {
+ code = cm_SyncOp(scp, NULL, userp, &req, PRSFS_INSERT,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ }
lock_ReleaseWrite(&scp->rw);
if (code == 0)
code = cm_FSync(scp, userp, &req, FALSE);
lock_ObtainWrite(&scp->rw);
code = cm_SyncOp(scp, NULL, userp, &req, PRSFS_WRITE,
CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ if (code == CM_ERROR_NOACCESS && scp->creator == userp) {
+ code = cm_SyncOp(scp, NULL, userp, &req, PRSFS_INSERT,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ }
lock_ReleaseWrite(&scp->rw);
if (code == 0) {
/*
{
length += cm_data.buf_blockSize;
} else {
- if (!(offset.QuadPart == 0 && length == 0))
- cm_QueueBKGRequest(scp, cm_BkgStore, offset.LowPart, offset.HighPart,
- length, 0, userp, &req);
+ if (!(offset.QuadPart == 0 && length == 0)) {
+ rockp = malloc(sizeof(*rockp));
+ if (rockp) {
+ rockp->length = length;
+ rockp->offset = offset;
+
+ cm_QueueBKGRequest(scp, cm_BkgStore, rockp, userp, &req);
+
+ /* rock is freed by cm_BkgStore */
+ }
+ }
offset.QuadPart = ReleaseExtentsCB->FileExtents[count].FileOffset.QuadPart;
length = cm_data.buf_blockSize;
}
}
- cm_QueueBKGRequest(scp, cm_BkgStore, offset.LowPart, offset.HighPart,
- length, 0, userp, &req);
+
+ /* Store whatever is left */
+ rockp = malloc(sizeof(*rockp));
+ if (rockp) {
+ rockp->length = length;
+ rockp->offset = offset;
+
+ cm_QueueBKGRequest(scp, cm_BkgStore, rockp, userp, &req);
+
+ /* rock is freed by cm_BkgStore */
+ }
}
}
cm_ReleaseSCache(scp);
cm_buf_t *bufp;
unsigned int fileno, extentno, total_extents = 0;
AFSReleaseFileExtentsResultFileCB *pNextFileCB;
+ rock_BkgStore_t *rockp;
#ifdef ODS_DEBUG
#ifdef VALIDATE_CHECK_SUM
char md5dbg[33], md5dbg2[33], md5dbg3[33];
#endif
char dbgstr[1024];
#endif
- RDR_InitReq(&req);
+ RDR_InitReq(&req, FALSE);
for ( fileno = 0, pNextFileCB = &ReleaseFileExtentsResultCB->Files[0];
fileno < ReleaseFileExtentsResultCB->FileCount;
osi_Log2(afsd_logp, "... coffset 0x%x:%x",
pExtent->CacheOffset.HighPart,
pExtent->CacheOffset.LowPart);
-#ifdef DEBUG
- DebugBreak();
-#endif
- if (!deleted) {
+
+ if (!deleted) {
buf_SetDirty(bufp, &req, pExtent->DirtyOffset, pExtent->DirtyLength, userp);
dirty++;
}
wbp, wbp->fid.volume, wbp->fid.vnode, wbp->offset.HighPart, wbp->offset.LowPart);
else
osi_Log0(afsd_logp, "... coffset cannot be found");
-#ifdef DEBUG
- DebugBreak();
-#endif
}
buf_Release(bufp);
} else {
length < cm_chunkSize) {
length += cm_data.buf_blockSize;
} else {
- if (!(offset.QuadPart == 0 && length == 0))
- cm_QueueBKGRequest(scp, cm_BkgStore, offset.LowPart, offset.HighPart,
- length, 0, userp, &req);
+ if (!(offset.QuadPart == 0 && length == 0)) {
+ rockp = malloc(sizeof(*rockp));
+ if (rockp) {
+ rockp->offset = offset;
+ rockp->length = length;
+
+ cm_QueueBKGRequest(scp, cm_BkgStore, rockp, userp, &req);
+ } else {
+ code = ENOMEM;
+ }
+ }
offset.QuadPart = pExtent->FileOffset.QuadPart;
length = cm_data.buf_blockSize;
}
}
- cm_QueueBKGRequest(scp, cm_BkgStore, offset.LowPart, offset.HighPart,
- length, 0, userp, &req);
+
+ /* Background store the rest */
+ rockp = malloc(sizeof(*rockp));
+ if (rockp) {
+ rockp->offset = offset;
+ rockp->length = length;
+
+ cm_QueueBKGRequest(scp, cm_BkgStore, rockp, userp, &req);
+ } else {
+ code = ENOMEM;
+ }
}
osi_Log5(afsd_logp, "RDR_ProcessReleaseFileExtentsResult File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x Released %d",
cm_scache_t * scp = NULL;
int dirty = 0;
- RDR_InitReq(&req);
+ RDR_InitReq(&req, FALSE);
osi_Log4(afsd_logp, "RDR_ReleaseFailedSetFileExtents %d.%d.%d.%d",
SetFileExtentsResultCB->FileId.Cell, SetFileExtentsResultCB->FileId.Volume,
{
cm_fid_t ParentFid;
cm_fid_t RootFid;
+ cm_req_t req;
+
+ RDR_InitReq(&req, bWow64);
*ResultCB = (AFSCommResult *)malloc( sizeof( AFSCommResult));
if (!(*ResultCB))
RootFid.hash = pPioctlCB->RootId.Hash;
/* Create the pioctl index */
- RDR_SetupIoctl(pPioctlCB->RequestId, &ParentFid, &RootFid, userp);
+ RDR_SetupIoctl(pPioctlCB->RequestId, &ParentFid, &RootFid, userp, &req);
return;
}
cm_req_t req;
DWORD status;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
*ResultCB = (AFSCommResult *)malloc( sizeof( AFSCommResult) + sizeof(AFSPIOCtlIOResultCB));
if (!(*ResultCB))
pResultCB = (AFSPIOCtlIOResultCB *)(*ResultCB)->ResultData;
- code = RDR_IoctlWrite(userp, pPioctlCB->RequestId, pPioctlCB->BufferLength, pPioctlCB->MappedBuffer, &req);
+ code = RDR_IoctlWrite(userp, pPioctlCB->RequestId, pPioctlCB->BufferLength, pPioctlCB->MappedBuffer);
if (code) {
smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
(*ResultCB)->ResultStatus = status;
DWORD status;
afs_uint32 pflags = (bIsLocalSystem ? AFSCALL_FLAG_LOCAL_SYSTEM : 0);
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
*ResultCB = (AFSCommResult *)malloc( sizeof( AFSCommResult) + sizeof(AFSPIOCtlIOResultCB));
if (!(*ResultCB))
pResultCB = (AFSPIOCtlIOResultCB *)(*ResultCB)->ResultData;
code = RDR_IoctlRead(userp, pPioctlCB->RequestId, pPioctlCB->BufferLength, pPioctlCB->MappedBuffer,
- &pResultCB->BytesProcessed, &req, pflags);
+ &pResultCB->BytesProcessed, pflags);
if (code) {
smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
(*ResultCB)->ResultStatus = status;
ProcessId.QuadPart = pBRLRequestCB->ProcessId;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_ByteRangeLockSync File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
FileId.Cell, FileId.Volume,
ProcessId.QuadPart = pBRURequestCB->ProcessId;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_ByteRangeUnlock File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
FileId.Cell, FileId.Volume,
ProcessId.QuadPart = pBRURequestCB->ProcessId;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_ByteRangeUnlockAll File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
FileId.Cell, FileId.Volume,
DWORD Length;
cm_scache_t *scp = NULL;
cm_volume_t *volp = NULL;
- cm_vol_state_t *volstatep = NULL;
afs_uint32 volType;
- cm_cell_t *cellp = NULL;
cm_fid_t Fid;
afs_uint32 code;
cm_req_t req;
char *OfflineMsg;
char *MOTD;
struct rx_connection * rxconnp;
+ int sync_done = 0;
+ int scp_locked = 0;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_GetVolumeInfo File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
FileId.Cell, FileId.Volume,
return;
}
lock_ObtainWrite(&scp->rw);
-
- code = cm_SyncOp(scp, NULL, userp, &req, 0,
- CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
- if (code) {
- lock_ReleaseWrite(&scp->rw);
- smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
- (*ResultCB)->ResultStatus = status;
- (*ResultCB)->ResultBufferLength = 0;
- osi_Log3(afsd_logp, "RDR_GetVolumeInfo cm_SyncOp failure scp=0x%p code=0x%x status=0x%x",
- scp, code, status);
- return;
- }
+ scp_locked = 1;
pResultCB->SectorsPerAllocationUnit = 1;
pResultCB->BytesPerSector = 1024;
pResultCB->VolumeID = scp->fid.volume;
pResultCB->Characteristics = FILE_REMOTE_DEVICE;
pResultCB->FileSystemAttributes = FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK |
- FILE_SUPPORTS_REPARSE_POINTS;
+ FILE_SUPPORTS_HARD_LINKS | FILE_SUPPORTS_REPARSE_POINTS;
if (scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
scp->fid.volume==AFS_FAKE_ROOT_VOL_ID)
memcpy(&pResultCB->VolumeCreationTime, &ft, sizeof(ft));
pResultCB->AvailableAllocationUnits.QuadPart = 0;
- pResultCB->Characteristics |= FILE_READ_ONLY_DEVICE;
+ pResultCB->FileSystemAttributes |= FILE_READ_ONLY_VOLUME;
pResultCB->VolumeLabelLength = cm_Utf8ToUtf16( "Freelance.Local.Root", -1, pResultCB->VolumeLabel,
(sizeof(pResultCB->VolumeLabel) / sizeof(WCHAR)) + 1);
if ( pResultCB->VolumeLabelLength )
pResultCB->VolumeLabelLength--;
+
+ pResultCB->CellLength = cm_Utf8ToUtf16( "Freelance.Local", -1, pResultCB->Cell,
+ (sizeof(pResultCB->Cell) / sizeof(WCHAR)) + 1);
+ if ( pResultCB->CellLength )
+ pResultCB->CellLength--;
} else {
memcpy(&pResultCB->VolumeCreationTime, &ft, sizeof(ft));
code = CM_ERROR_NOSUCHVOLUME;
goto _done;
}
- volstatep = cm_VolumeStateByID(volp, scp->fid.volume);
volType = cm_VolumeType(volp, scp->fid.volume);
- pResultCB->Characteristics |= ((volType == ROVOL || volType == BACKVOL) ? FILE_READ_ONLY_DEVICE : 0);
+ if (volType == ROVOL || volType == BACKVOL)
+ pResultCB->FileSystemAttributes |= FILE_READ_ONLY_VOLUME;
- Name = volName;
- OfflineMsg = offLineMsg;
- MOTD = motd;
- lock_ReleaseWrite(&scp->rw);
- do {
- code = cm_ConnFromFID(&scp->fid, userp, &req, &connp);
- if (code) continue;
+ code = cm_SyncOp(scp, NULL, userp, &req, PRSFS_READ,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ if (code == 0)
+ {
+ sync_done = 1;
- rxconnp = cm_GetRxConn(connp);
- code = RXAFS_GetVolumeStatus(rxconnp, scp->fid.volume,
- &volStat, &Name, &OfflineMsg, &MOTD);
- rx_PutConnection(rxconnp);
+ Name = volName;
+ OfflineMsg = offLineMsg;
+ MOTD = motd;
+ lock_ReleaseWrite(&scp->rw);
+ scp_locked = 0;
+
+ do {
+ code = cm_ConnFromFID(&scp->fid, userp, &req, &connp);
+ if (code) continue;
+
+ rxconnp = cm_GetRxConn(connp);
+ code = RXAFS_GetVolumeStatus(rxconnp, scp->fid.volume,
+ &volStat, &Name, &OfflineMsg, &MOTD);
+ rx_PutConnection(rxconnp);
+
+ } while (cm_Analyze(connp, userp, &req, &scp->fid, NULL, 0, NULL, NULL, NULL, NULL, code));
+ code = cm_MapRPCError(code, &req);
+ }
- } while (cm_Analyze(connp, userp, &req, &scp->fid, 0, NULL, NULL, NULL, code));
- code = cm_MapRPCError(code, &req);
if (code == 0) {
- if (volStat.MaxQuota)
- {
- pResultCB->TotalAllocationUnits.QuadPart = volStat.MaxQuota;
- if (volType == ROVOL || volType == BACKVOL) {
- pResultCB->AvailableAllocationUnits.QuadPart = 0;
- }
- else
+ if (volType == ROVOL || volType == BACKVOL) {
+ pResultCB->TotalAllocationUnits.QuadPart = volStat.BlocksInUse;
+ pResultCB->AvailableAllocationUnits.QuadPart = 0;
+ } else {
+ if (volStat.MaxQuota)
{
+ pResultCB->TotalAllocationUnits.QuadPart = volStat.MaxQuota;
pResultCB->AvailableAllocationUnits.QuadPart =
min(volStat.MaxQuota - volStat.BlocksInUse, volStat.PartBlocksAvail);
}
- }
- else
- {
- pResultCB->TotalAllocationUnits.QuadPart = volStat.PartMaxBlocks;
- if (volType == ROVOL || volType == BACKVOL) {
- pResultCB->AvailableAllocationUnits.QuadPart = 0;
- }
else
{
+ pResultCB->TotalAllocationUnits.QuadPart = volStat.PartMaxBlocks;
pResultCB->AvailableAllocationUnits.QuadPart = volStat.PartBlocksAvail;
}
}
} else {
+ /*
+ * Lie about the available space. Out of quota errors will need
+ * detected when the file server rejects the store data.
+ */
pResultCB->TotalAllocationUnits.QuadPart = 0x7FFFFFFF;
pResultCB->AvailableAllocationUnits.QuadPart = (volType == ROVOL || volType == BACKVOL) ? 0 : 0x3F000000;
-
- pResultCB->VolumeLabelLength = cm_Utf8ToUtf16( volp->namep, -1, pResultCB->VolumeLabel,
- (sizeof(pResultCB->VolumeLabel) / sizeof(WCHAR)) + 1);
code = 0;
}
+
+ pResultCB->VolumeLabelLength = cm_Utf8ToUtf16( volp->namep, -1, pResultCB->VolumeLabel,
+ (sizeof(pResultCB->VolumeLabel) / sizeof(WCHAR)) + 1);
+
+ if ( pResultCB->VolumeLabelLength) {
+
+ /* add .readonly and .backup if appropriate */
+ switch ( volType) {
+ case ROVOL:
+ pResultCB->VolumeLabelLength--;
+ pResultCB->VolumeLabelLength += cm_Utf8ToUtf16( ".readonly", -1,
+ &pResultCB->VolumeLabel[ pResultCB->VolumeLabelLength],
+ (sizeof(pResultCB->VolumeLabel) / sizeof(WCHAR)) - pResultCB->VolumeLabelLength + 1);
+ break;
+
+ case BACKVOL:
+ pResultCB->VolumeLabelLength--;
+ pResultCB->VolumeLabelLength += cm_Utf8ToUtf16( ".backup", -1,
+ &pResultCB->VolumeLabel[ pResultCB->VolumeLabelLength],
+ (sizeof(pResultCB->VolumeLabel) / sizeof(WCHAR)) - pResultCB->VolumeLabelLength + 1);
+ break;
+ }
+ }
+
+ /* do not include the trailing nul */
if ( pResultCB->VolumeLabelLength )
pResultCB->VolumeLabelLength--;
- lock_ObtainWrite(&scp->rw);
+ pResultCB->CellLength = cm_Utf8ToUtf16( volp->cellp->name, -1, pResultCB->Cell,
+ (sizeof(pResultCB->Cell) / sizeof(WCHAR)) + 1);
+
+ /* do not include the trailing nul */
+ if ( pResultCB->CellLength )
+ pResultCB->CellLength--;
+
+ if (sync_done) {
+ if (!scp_locked) {
+ lock_ObtainWrite(&scp->rw);
+ scp_locked = 1;
+ }
+ cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ }
}
pResultCB->VolumeLabelLength *= sizeof(WCHAR); /* convert to bytes from chars */
-
- cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ pResultCB->CellLength *= sizeof(WCHAR); /* convert to bytes from chars */
_done:
- lock_ReleaseWrite(&scp->rw);
+ if (scp_locked)
+ lock_ReleaseWrite(&scp->rw);
if (volp)
cm_PutVolume(volp);
cm_ReleaseSCache(scp);
cm_scache_t *scp = NULL;
cm_volume_t *volp = NULL;
afs_uint32 volType;
- cm_cell_t *cellp = NULL;
cm_fid_t Fid;
afs_uint32 code;
cm_req_t req;
char *OfflineMsg;
char *MOTD;
struct rx_connection * rxconnp;
+ int sync_done = 0;
+ int scp_locked = 0;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
osi_Log4(afsd_logp, "RDR_GetVolumeSizeInfo File FID cell=0x%x vol=0x%x vn=0x%x uniq=0x%x",
FileId.Cell, FileId.Volume,
return;
}
lock_ObtainWrite(&scp->rw);
-
- code = cm_SyncOp(scp, NULL, userp, &req, 0,
- CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
- if (code) {
- lock_ReleaseWrite(&scp->rw);
- smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
- (*ResultCB)->ResultStatus = status;
- (*ResultCB)->ResultBufferLength = 0;
- osi_Log3(afsd_logp, "RDR_GetVolumeSizeInfo cm_SyncOp failure scp=0x%p code=0x%x status=0x%x",
- scp, code, status);
- return;
- }
+ scp_locked = 1;
pResultCB->SectorsPerAllocationUnit = 1;
pResultCB->BytesPerSector = 1024;
if (scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
- scp->fid.volume==AFS_FAKE_ROOT_VOL_ID)
+ scp->fid.volume==AFS_FAKE_ROOT_VOL_ID)
{
pResultCB->TotalAllocationUnits.QuadPart = 100;
pResultCB->AvailableAllocationUnits.QuadPart = 0;
}
volType = cm_VolumeType(volp, scp->fid.volume);
- Name = volName;
- OfflineMsg = offLineMsg;
- MOTD = motd;
- lock_ReleaseWrite(&scp->rw);
- do {
- code = cm_ConnFromFID(&scp->fid, userp, &req, &connp);
- if (code) continue;
-
- rxconnp = cm_GetRxConn(connp);
- code = RXAFS_GetVolumeStatus(rxconnp, scp->fid.volume,
- &volStat, &Name, &OfflineMsg, &MOTD);
- rx_PutConnection(rxconnp);
-
- } while (cm_Analyze(connp, userp, &req, &scp->fid, 0, NULL, NULL, NULL, code));
- code = cm_MapRPCError(code, &req);
+
+ code = cm_SyncOp(scp, NULL, userp, &req, PRSFS_READ,
+ CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ if (code == 0)
+ {
+ sync_done = 1;
+
+ Name = volName;
+ OfflineMsg = offLineMsg;
+ MOTD = motd;
+ lock_ReleaseWrite(&scp->rw);
+ scp_locked = 0;
+
+ do {
+ code = cm_ConnFromFID(&scp->fid, userp, &req, &connp);
+ if (code) continue;
+
+ rxconnp = cm_GetRxConn(connp);
+ code = RXAFS_GetVolumeStatus(rxconnp, scp->fid.volume,
+ &volStat, &Name, &OfflineMsg, &MOTD);
+ rx_PutConnection(rxconnp);
+
+ } while (cm_Analyze(connp, userp, &req, &scp->fid, NULL, 0, NULL, NULL, NULL, NULL, code));
+ code = cm_MapRPCError(code, &req);
+ }
+
if (code == 0) {
- if (volStat.MaxQuota)
- {
- pResultCB->TotalAllocationUnits.QuadPart = volStat.MaxQuota;
- if (volType == ROVOL || volType == BACKVOL) {
- pResultCB->AvailableAllocationUnits.QuadPart = 0;
- }
- else
+ if (volType == ROVOL || volType == BACKVOL) {
+ pResultCB->TotalAllocationUnits.QuadPart = volStat.BlocksInUse;
+ pResultCB->AvailableAllocationUnits.QuadPart = 0;
+ } else {
+ if (volStat.MaxQuota)
{
+ pResultCB->TotalAllocationUnits.QuadPart = volStat.MaxQuota;
pResultCB->AvailableAllocationUnits.QuadPart =
min(volStat.MaxQuota - volStat.BlocksInUse, volStat.PartBlocksAvail);
}
- }
- else
- {
- pResultCB->TotalAllocationUnits.QuadPart = volStat.PartMaxBlocks;
- if (volType == ROVOL || volType == BACKVOL) {
- pResultCB->AvailableAllocationUnits.QuadPart = 0;
- }
else
{
+ pResultCB->TotalAllocationUnits.QuadPart = volStat.PartMaxBlocks;
pResultCB->AvailableAllocationUnits.QuadPart = volStat.PartBlocksAvail;
}
}
} else {
-
+ /*
+ * Lie about the available space. Out of quota errors will need
+ * detected when the file server rejects the store data.
+ */
pResultCB->TotalAllocationUnits.QuadPart = 0x7FFFFFFF;
pResultCB->AvailableAllocationUnits.QuadPart = (volType == ROVOL || volType == BACKVOL) ? 0 : 0x3F000000;
code = 0;
}
- lock_ObtainWrite(&scp->rw);
- }
- cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ if (sync_done) {
+ if (!scp_locked) {
+ lock_ObtainWrite(&scp->rw);
+ scp_locked = 1;
+ }
+ cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+ }
+ }
_done:
- lock_ReleaseWrite(&scp->rw);
+ if (scp_locked)
+ lock_ReleaseWrite(&scp->rw);
if (volp)
cm_PutVolume(volp);
cm_ReleaseSCache(scp);
DWORD Length;
cm_req_t req;
- RDR_InitReq(&req);
+ RDR_InitReq(&req, FALSE);
osi_Log1(afsd_logp, "RDR_HoldFid Count=%u", pHoldFidCB->Count);
DWORD Length;
cm_req_t req;
- RDR_InitReq(&req);
+ RDR_InitReq(&req, FALSE);
osi_Log1(afsd_logp, "RDR_ReleaseFid Count=%u", pReleaseFidCB->Count);
cm_req_t req;
DWORD status;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
*ResultCB = (AFSCommResult *)malloc( sizeof( AFSCommResult) + sizeof(AFSPipeIOResultCB));
if (!(*ResultCB))
cm_req_t req;
DWORD status;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
*ResultCB = (AFSCommResult *)malloc( sizeof( AFSCommResult) + ResultBufferLength);
if (!(*ResultCB))
cm_req_t req;
DWORD status;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
*ResultCB = (AFSCommResult *)malloc( sizeof( AFSCommResult));
if (!(*ResultCB))
cm_req_t req;
DWORD status;
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
*ResultCB = (AFSCommResult *)malloc( sizeof( AFSCommResult) + ResultBufferLength);
if (!(*ResultCB))
DWORD status;
DWORD Length = ResultBufferLength + sizeof( AFSCommResult);
- RDR_InitReq(&req);
- if ( bWow64 )
- req.flags |= CM_REQ_WOW64;
+ RDR_InitReq(&req, bWow64);
*ResultCB = (AFSCommResult *)malloc( Length);
if (!(*ResultCB))