lock_InitializeMutex(&cm_Freelance_Lock, "Freelance Lock", LOCK_HIERARCHY_FREELANCE_GLOBAL);
+ lock_ObtainMutex(&cm_Freelance_Lock);
// yj: first we make a call to cm_initLocalMountPoints
// to read all the local mount points from the registry
cm_InitLocalMountPoints();
// a fake root directory based on the local mount points
cm_InitFakeRootDir();
// --- end of yj code
+ lock_ReleaseMutex(&cm_Freelance_Lock);
/* Start the registry monitor */
phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceChangeNotifier,
}
/* yj: Initialization of the fake root directory */
-/* to be called while holding freelance lock unless during init. */
+/* to be called while holding freelance lock. */
void cm_InitFakeRootDir() {
int i, t1, t2;
char* currentPos;
osi_Log0(afsd_logp,"Invalidating local mount point scp... ");
-
lock_ObtainWrite(&cm_scacheLock);
lock_ObtainMutex(&cm_Freelance_Lock); /* always scache then freelance lock */
- for (i=1; i<=cm_noLocalMountPoints; i++) {
- cm_SetFid(&aFid, AFS_FAKE_ROOT_CELL_ID, AFS_FAKE_ROOT_VOL_ID, i, 1);
+ for (i=0; i<=cm_noLocalMountPoints; i++) {
+ if (i == 0)
+ cm_SetFid(&aFid, AFS_FAKE_ROOT_CELL_ID, AFS_FAKE_ROOT_VOL_ID, 1, 1);
+ else
+ cm_SetFid(&aFid, AFS_FAKE_ROOT_CELL_ID, AFS_FAKE_ROOT_VOL_ID, i*2, i);
hash = CM_SCACHE_HASH(&aFid);
for (scp=cm_data.scacheHashTablep[hash]; scp; scp=scp->nextp) {
if (scp != cm_data.rootSCachep && cm_FidCmp(&scp->fid, &aFid) == 0) {
// yj: open up the registry and read all the local mount
// points that are stored there. Part of the initialization
// process for the freelance client.
-/* to be called while holding freelance lock unless during init. */
+/* to be called while holding freelance lock. */
long cm_InitLocalMountPoints() {
FILE *fp;
int i;
&ftLastWriteTime /* lpftLastWriteTime */
);
- smb_UnixTimeFromLargeSearchTime(&FakeFreelanceModTime, &ftLastWriteTime);
+ cm_UnixTimeFromLargeSearchTime(&FakeFreelanceModTime, &ftLastWriteTime);
if ( dwMountPoints == 0 ) {
rootCellName[0] = '.';
code = cm_GetRootCellName(&rootCellName[1]);
if (code == 0) {
+ lock_ReleaseMutex(&cm_Freelance_Lock);
cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL);
cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL);
cm_FreelanceAddMount(".root", &rootCellName[1], "root.afs.", 1, NULL);
+ lock_ObtainMutex(&cm_Freelance_Lock);
dwMountPoints = 3;
}
}
rootCellName[0] = '.';
code = cm_GetRootCellName(&rootCellName[1]);
if (code == 0) {
+ lock_ReleaseMutex(&cm_Freelance_Lock);
cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL);
cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL);
cm_FreelanceAddMount(".root", &rootCellName[1], "root.afs.", 1, NULL);
+ lock_ObtainMutex(&cm_Freelance_Lock);
}
return 0;
}
fprintf(fp, "%s#%s:%s\n", filename, fullname, volume);
fclose(fp);
}
+
+ /* Do this while we are holding the lock */
+ cm_data.fakeDirVersion++;
+ cm_localMountPointChangeFlag = 1;
lock_ReleaseMutex(&cm_Freelance_Lock);
- /* cm_reInitLocalMountPoints(); */
- if (fidp)
- cm_SetFid(fidp, fidp->cell, fidp->volume, ++cm_noLocalMountPoints, 1);
- cm_noteLocalMountPointChange();
+ if (fidp) {
+ cm_req_t req;
+ afs_uint32 code;
+ cm_scache_t *scp;
+ clientchar_t *cpath;
+
+ cm_InitReq(&req);
+
+ cpath = cm_FsStringToClientStringAlloc(filename, -1, NULL);
+ if (!cpath)
+ return CM_ERROR_NOSUCHPATH;
+ code = cm_NameI(cm_data.rootSCachep, cpath,
+ CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD | CM_FLAG_DFS_REFERRAL,
+ cm_rootUserp, NULL, &req, &scp);
+ free(cpath);
+ if (code)
+ return code;
+ *fidp = scp->fid;
+ cm_ReleaseSCache(scp);
+ }
+
return 0;
}
rename(hfile2, hfile);
}
}
-
- lock_ReleaseMutex(&cm_Freelance_Lock);
+
if (found) {
- cm_noteLocalMountPointChange();
- return 0;
- } else
- return CM_ERROR_NOSUCHFILE;
+ /* Do this while we are holding the lock */
+ cm_data.fakeDirVersion++;
+ cm_localMountPointChangeFlag = 1;
+ }
+ lock_ReleaseMutex(&cm_Freelance_Lock);
+ return (found ? 0 : CM_ERROR_NOSUCHFILE);
}
long cm_FreelanceAddSymlink(char *filename, char *destination, cm_fid_t *fidp)
}
RegCloseKey(hkFreelanceSymlinks);
}
+
+ /* Do this while we are holding the lock */
+ cm_data.fakeDirVersion++;
+ cm_localMountPointChangeFlag = 1;
lock_ReleaseMutex(&cm_Freelance_Lock);
- /* cm_reInitLocalMountPoints(); */
- if (fidp)
- cm_SetFid(fidp, fidp->cell, fidp->volume, ++cm_noLocalMountPoints, 1);
- cm_noteLocalMountPointChange();
+ if (fidp) {
+ cm_req_t req;
+ afs_uint32 code;
+ cm_scache_t *scp;
+ clientchar_t *cpath;
+
+ cm_InitReq(&req);
+
+ cpath = cm_FsStringToClientStringAlloc(filename, -1, NULL);
+ if (!cpath)
+ return CM_ERROR_NOSUCHPATH;
+ code = cm_NameI(cm_data.rootSCachep, cpath,
+ CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD | CM_FLAG_DFS_REFERRAL,
+ cm_rootUserp, NULL, &req, &scp);
+ free(cpath);
+ if (code)
+ return code;
+ *fidp = scp->fid;
+ cm_ReleaseSCache(scp);
+ }
+
return 0;
}
RegCloseKey(hkFreelanceSymlinks);
}
- lock_ReleaseMutex(&cm_Freelance_Lock);
if (found) {
- cm_noteLocalMountPointChange();
- return 0;
- } else
- return CM_ERROR_NOSUCHFILE;
+ /* Do this while we are holding the lock */
+ cm_data.fakeDirVersion++;
+ cm_localMountPointChangeFlag = 1;
+ }
+ lock_ReleaseMutex(&cm_Freelance_Lock);
+ return (found ? 0 : CM_ERROR_NOSUCHFILE);
}
long