11 #include <WINNT/afsreg.h>
15 #ifdef AFS_FREELANCE_CLIENT
16 #include "cm_freelance.h"
19 extern void afsi_log(char *pattern, ...);
21 static int cm_noLocalMountPoints = 0;
22 char * cm_FakeRootDir = NULL;
23 int cm_fakeDirSize = 0;
24 int cm_fakeDirCallback=0;
25 int cm_fakeGettingCallback=0;
26 static cm_localMountPoint_t* cm_localMountPoints;
27 osi_mutex_t cm_Freelance_Lock;
28 static int cm_localMountPointChangeFlag = 0;
29 int cm_freelanceEnabled = 1;
30 time_t FakeFreelanceModTime = 0x3b49f6e2;
32 static int freelance_ShutdownFlag = 0;
33 static HANDLE hFreelanceChangeEvent = 0;
34 static HANDLE hFreelanceSymlinkChangeEvent = 0;
36 void cm_InitFakeRootDir();
38 void cm_FreelanceChangeNotifier(void * parmp) {
41 if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,
42 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance",
45 &hkFreelance) == ERROR_SUCCESS) {
47 hFreelanceChangeEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
48 if (hFreelanceChangeEvent == NULL) {
49 RegCloseKey(hkFreelance);
55 /* check hFreelanceChangeEvent to see if it is set.
56 * if so, call cm_noteLocalMountPointChange()
58 if (RegNotifyChangeKeyValue( hkFreelance, /* hKey */
59 FALSE, /* bWatchSubtree */
60 REG_NOTIFY_CHANGE_LAST_SET, /* dwNotifyFilter */
61 hFreelanceChangeEvent, /* hEvent */
62 TRUE /* fAsynchronous */
64 RegCloseKey(hkFreelance);
65 CloseHandle(hFreelanceChangeEvent);
66 hFreelanceChangeEvent = 0;
70 if (WaitForSingleObject(hFreelanceChangeEvent, INFINITE) == WAIT_OBJECT_0)
72 if (freelance_ShutdownFlag == 1) {
73 RegCloseKey(hkFreelance);
74 CloseHandle(hFreelanceChangeEvent);
75 hFreelanceChangeEvent = 0;
78 cm_noteLocalMountPointChange();
83 void cm_FreelanceSymlinkChangeNotifier(void * parmp) {
86 if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,
87 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance\\Symlinks",
90 &hkFreelance) == ERROR_SUCCESS) {
92 hFreelanceSymlinkChangeEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
93 if (hFreelanceSymlinkChangeEvent == NULL) {
94 RegCloseKey(hkFreelance);
100 /* check hFreelanceSymlinkChangeEvent to see if it is set.
101 * if so, call cm_noteLocalMountPointSymlinkChange()
103 if (RegNotifyChangeKeyValue( hkFreelance, /* hKey */
104 FALSE, /* bWatchSubtree */
105 REG_NOTIFY_CHANGE_LAST_SET, /* dwNotifyFilter */
106 hFreelanceSymlinkChangeEvent, /* hEvent */
107 TRUE /* fAsynchronous */
108 ) != ERROR_SUCCESS) {
109 RegCloseKey(hkFreelance);
110 CloseHandle(hFreelanceSymlinkChangeEvent);
111 hFreelanceSymlinkChangeEvent = 0;
115 if (WaitForSingleObject(hFreelanceSymlinkChangeEvent, INFINITE) == WAIT_OBJECT_0)
117 if (freelance_ShutdownFlag == 1) {
118 RegCloseKey(hkFreelance);
119 CloseHandle(hFreelanceSymlinkChangeEvent);
120 hFreelanceSymlinkChangeEvent = 0;
123 cm_noteLocalMountPointChange();
129 cm_FreelanceShutdown(void)
131 freelance_ShutdownFlag = 1;
132 if (hFreelanceChangeEvent != 0)
133 thrd_SetEvent(hFreelanceChangeEvent);
134 if (hFreelanceSymlinkChangeEvent != 0)
135 thrd_SetEvent(hFreelanceSymlinkChangeEvent);
138 void cm_InitFreelance() {
142 lock_InitializeMutex(&cm_Freelance_Lock, "Freelance Lock", LOCK_HIERARCHY_FREELANCE_GLOBAL);
144 lock_ObtainMutex(&cm_Freelance_Lock);
145 // yj: first we make a call to cm_initLocalMountPoints
146 // to read all the local mount points from the registry
147 cm_InitLocalMountPoints();
149 // then we make a call to InitFakeRootDir to create
150 // a fake root directory based on the local mount points
151 cm_InitFakeRootDir();
152 // --- end of yj code
153 lock_ReleaseMutex(&cm_Freelance_Lock);
155 /* Start the registry monitor */
156 phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceChangeNotifier,
157 NULL, 0, &lpid, "cm_FreelanceChangeNotifier");
158 osi_assertx(phandle != NULL, "cm_FreelanceChangeNotifier thread create failure");
159 thrd_CloseHandle(phandle);
161 phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceSymlinkChangeNotifier,
162 NULL, 0, &lpid, "cm_FreelanceSymlinkChangeNotifier");
163 osi_assertx(phandle != NULL, "cm_FreelanceSymlinkChangeNotifier thread create failure");
164 thrd_CloseHandle(phandle);
167 /* yj: Initialization of the fake root directory */
168 /* to be called while holding freelance lock. */
169 void cm_InitFakeRootDir() {
174 // allocate space for the fake info
175 cm_dirHeader_t fakeDirHeader;
176 cm_dirEntry_t fakeEntry;
177 cm_pageHeader_t fakePageHeader;
179 // i'm going to calculate how much space is needed for
180 // this fake root directory. we have these rules:
181 // 1. there are cm_noLocalMountPoints number of entries
182 // 2. each page is CM_DIR_PAGESIZE in size
183 // 3. the first 13 chunks of the first page are used for
185 // 4. the first chunk of all subsequent pages are used
186 // for page header stuff
187 // 5. a max of CM_DIR_EPP entries are allowed per page
188 // 6. each entry takes 1 or more chunks, depending on
189 // the size of the mount point string, as determined
191 // 7. each chunk is CM_DIR_CHUNKSIZE bytes
193 int CPP = CM_DIR_PAGESIZE / CM_DIR_CHUNKSIZE;
194 int curChunk = 13; // chunks 0 - 12 are used for header stuff
195 // of the first page in the directory
198 int curDirEntryInPage = 0;
202 /* Reserve 2 directory chunks for "." and ".." */
205 while (curDirEntry<cm_noLocalMountPoints) {
206 sizeOfCurEntry = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
207 if ((curChunk + sizeOfCurEntry >= CPP) ||
208 (curDirEntryInPage + 1 >= CM_DIR_EPP)) {
210 curDirEntryInPage = 0;
213 curChunk += sizeOfCurEntry;
218 dirSize = (curPage+1) * CM_DIR_PAGESIZE;
219 if (cm_fakeDirSize != dirSize) {
221 free(cm_FakeRootDir);
222 cm_FakeRootDir = malloc(dirSize);
223 cm_fakeDirSize = dirSize;
226 // yj: when we get here, we've figured out how much memory we need and
227 // allocated the appropriate space for it. we now prceed to fill
228 // it up with entries.
231 curDirEntryInPage = 0;
234 // fields in the directory entry that are unused.
236 fakeEntry.length = 0;
238 fakeEntry.fid.unique = htonl(1);
240 // the first page is special, it uses fakeDirHeader instead of fakePageHeader
241 // we fill up the page with dirEntries that belong there and we make changes
242 // to the fakeDirHeader.header.freeBitmap along the way. Then when we're done
243 // filling up the dirEntries in this page, we copy the fakeDirHeader into
244 // the top of the page.
246 // init the freeBitmap array
248 fakeDirHeader.header.freeBitmap[i]=0;
250 fakeDirHeader.header.freeBitmap[0] = 0xff;
251 fakeDirHeader.header.freeBitmap[1] = 0x7f;
254 // we start counting at 13 because the 0th to 12th chunks are used for header
257 // stick the first 2 entries "." and ".." in
258 fakeEntry.fid.vnode = htonl(1);
259 strcpy(fakeEntry.name, ".");
260 currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
261 memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
262 curChunk++; curDirEntryInPage++;
263 strcpy(fakeEntry.name, "..");
264 currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
265 memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
266 curChunk++; curDirEntryInPage++;
268 // keep putting stuff into page 0 if
269 // 1. we're not done with all entries
270 // 2. we have less than CM_DIR_EPP entries in page 0
271 // 3. we're not out of chunks in page 0
273 while( (curDirEntry<cm_noLocalMountPoints) &&
274 (curDirEntryInPage < CM_DIR_EPP) &&
275 (curChunk + cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0) <= CPP))
278 noChunks = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
279 /* enforce the rule that only directories have odd vnode values */
280 fakeEntry.fid.vnode = htonl((curDirEntry + 1) * 2);
281 fakeEntry.fid.unique = htonl(curDirEntry + 1);
282 currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
284 memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
285 strcpy(currentPos + 12, (cm_localMountPoints+curDirEntry)->namep);
288 for (i=0; i<noChunks; i++) {
289 t1 = (curChunk + i) / 8;
290 t2 = curChunk + i - (t1*8);
291 fakeDirHeader.header.freeBitmap[t1] |= (1 << t2);
296 // when we get here, we're done with filling in the entries for page 0
297 // copy in the header info
299 memcpy(cm_FakeRootDir, &fakeDirHeader, 13 * CM_DIR_CHUNKSIZE);
303 // ok, page 0's done. Move on to the next page.
304 while (curDirEntry<cm_noLocalMountPoints) {
306 curChunk = 1; // the zeroth chunk is reserved for page header
307 curDirEntryInPage = 0;
308 for (i=0; i<8; i++) {
309 fakePageHeader.freeBitmap[i]=0;
311 fakePageHeader.freeCount = 0;
312 fakePageHeader.pgcount = 0;
313 fakePageHeader.tag = htons(1234);
315 // while we're on the same page...
316 while ( (curDirEntry<cm_noLocalMountPoints) &&
317 (curDirEntryInPage < CM_DIR_EPP) &&
318 (curChunk + cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0) <= CPP))
320 // add an entry to this page
322 noChunks = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
323 /* enforce the rule that only directories have odd vnode values */
324 fakeEntry.fid.vnode = htonl((curDirEntry + 1) * 2);
325 fakeEntry.fid.unique = htonl(curDirEntry + 1);
326 currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
327 memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
328 strcpy(currentPos + 12, (cm_localMountPoints+curDirEntry)->namep);
331 for (i=0; i<noChunks; i++) {
332 t1 = (curChunk + i) / 8;
333 t2 = curChunk + i - (t1*8);
334 fakePageHeader.freeBitmap[t1] |= (1 << t2);
338 memcpy(cm_FakeRootDir + curPage * CM_DIR_PAGESIZE, &fakePageHeader, sizeof(fakePageHeader));
343 // we know the fakeDir is setup properly, so we claim that we have callback
344 osi_Log0(afsd_logp,"cm_InitFakeRootDir fakeDirCallback=1");
345 cm_fakeDirCallback=1;
347 // when we get here, we've set up everything! done!
350 int cm_FakeRootFid(cm_fid_t *fidp)
353 AFS_FAKE_ROOT_CELL_ID, /* root cell */
354 AFS_FAKE_ROOT_VOL_ID, /* root.afs ? */
359 /* called directly from ioctl */
360 /* called while not holding freelance lock */
361 int cm_noteLocalMountPointChange(void) {
362 lock_ObtainMutex(&cm_Freelance_Lock);
363 cm_data.fakeDirVersion++;
364 cm_localMountPointChangeFlag = 1;
365 lock_ReleaseMutex(&cm_Freelance_Lock);
369 int cm_getLocalMountPointChange() {
370 return cm_localMountPointChangeFlag;
373 int cm_clearLocalMountPointChange() {
374 cm_localMountPointChangeFlag = 0;
378 int cm_reInitLocalMountPoints() {
381 cm_scache_t *scp, **lscpp, *tscp;
383 osi_Log0(afsd_logp,"----- freelance reinitialization starts ----- ");
385 // first we invalidate all the SCPs that were created
386 // for the local mount points
388 osi_Log0(afsd_logp,"Invalidating local mount point scp... ");
390 lock_ObtainWrite(&cm_scacheLock);
391 lock_ObtainMutex(&cm_Freelance_Lock); /* always scache then freelance lock */
392 for (i=0; i<=cm_noLocalMountPoints; i++) {
394 cm_SetFid(&aFid, AFS_FAKE_ROOT_CELL_ID, AFS_FAKE_ROOT_VOL_ID, 1, 1);
396 cm_SetFid(&aFid, AFS_FAKE_ROOT_CELL_ID, AFS_FAKE_ROOT_VOL_ID, i*2, i);
397 hash = CM_SCACHE_HASH(&aFid);
398 for (scp=cm_data.scacheHashTablep[hash]; scp; scp=scp->nextp) {
399 if (scp != cm_data.rootSCachep && cm_FidCmp(&scp->fid, &aFid) == 0) {
400 // mark the scp to be reused
401 cm_HoldSCacheNoLock(scp);
402 lock_ReleaseMutex(&cm_Freelance_Lock);
403 lock_ReleaseWrite(&cm_scacheLock);
404 lock_ObtainWrite(&scp->rw);
405 cm_DiscardSCache(scp);
407 // take the scp out of the hash
408 lock_ObtainWrite(&cm_scacheLock);
409 for (lscpp = &cm_data.scacheHashTablep[hash], tscp = cm_data.scacheHashTablep[hash];
411 lscpp = &tscp->nextp, tscp = tscp->nextp) {
415 scp->flags &= ~CM_SCACHEFLAG_INHASH;
420 lock_ReleaseWrite(&scp->rw);
421 lock_ReleaseWrite(&cm_scacheLock);
422 cm_CallbackNotifyChange(scp);
423 lock_ObtainWrite(&cm_scacheLock);
424 cm_ReleaseSCacheNoLock(scp);
425 lock_ObtainMutex(&cm_Freelance_Lock);
429 lock_ReleaseWrite(&cm_scacheLock);
430 osi_Log0(afsd_logp,"\tall old scp cleared!");
432 // we must free the memory that was allocated in the prev
433 // cm_InitLocalMountPoints call
434 osi_Log0(afsd_logp,"Removing old localmountpoints... ");
435 free(cm_localMountPoints);
436 cm_localMountPoints = NULL;
437 cm_noLocalMountPoints = 0;
438 osi_Log0(afsd_logp,"\tall old localmountpoints cleared!");
440 // now re-init the localmountpoints
441 osi_Log0(afsd_logp,"Creating new localmountpoints... ");
442 cm_InitLocalMountPoints();
443 osi_Log0(afsd_logp,"\tcreated new set of localmountpoints!");
445 // then we re-create that dir
446 osi_Log0(afsd_logp,"Creating new fakedir... ");
447 cm_InitFakeRootDir();
448 osi_Log0(afsd_logp,"\t\tcreated new fakedir!");
450 lock_ReleaseMutex(&cm_Freelance_Lock);
452 osi_Log0(afsd_logp,"----- freelance reinit complete -----");
457 // yj: open up the registry and read all the local mount
458 // points that are stored there. Part of the initialization
459 // process for the freelance client.
460 /* to be called while holding freelance lock. */
461 long cm_InitLocalMountPoints() {
466 cm_localMountPoint_t* aLocalMountPoint;
469 char rootCellName[256];
470 HKEY hkFreelance = 0, hkFreelanceSymlinks = 0;
471 DWORD dwType, dwSize;
472 DWORD dwMountPoints = 0;
474 DWORD dwSymlinks = 0;
475 FILETIME ftLastWriteTime;
477 if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,
478 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance",
480 KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
481 &hkFreelance) == ERROR_SUCCESS) {
483 RegQueryInfoKey( hkFreelance,
486 NULL, /* lpReserved */
487 NULL, /* lpcSubKeys */
488 NULL, /* lpcMaxSubKeyLen */
489 NULL, /* lpcMaxClassLen */
490 &dwMountPoints, /* lpcValues */
491 NULL, /* lpcMaxValueNameLen */
492 NULL, /* lpcMaxValueLen */
493 NULL, /* lpcbSecurityDescriptor */
494 &ftLastWriteTime /* lpftLastWriteTime */
497 cm_UnixTimeFromLargeSearchTime(&FakeFreelanceModTime, &ftLastWriteTime);
499 if ( dwMountPoints == 0 ) {
500 rootCellName[0] = '.';
501 code = cm_GetRootCellName(&rootCellName[1]);
503 lock_ReleaseMutex(&cm_Freelance_Lock);
504 cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL);
505 cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL);
506 cm_FreelanceAddMount(".root", &rootCellName[1], "root.afs.", 1, NULL);
507 lock_ObtainMutex(&cm_Freelance_Lock);
512 if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
513 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance\\Symlinks",
516 REG_OPTION_NON_VOLATILE,
517 KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
519 &hkFreelanceSymlinks,
520 NULL) == ERROR_SUCCESS) {
522 RegQueryInfoKey( hkFreelanceSymlinks,
525 NULL, /* lpReserved */
526 NULL, /* lpcSubKeys */
527 NULL, /* lpcMaxSubKeyLen */
528 NULL, /* lpcMaxClassLen */
529 &dwSymlinks, /* lpcValues */
530 NULL, /* lpcMaxValueNameLen */
531 NULL, /* lpcMaxValueLen */
532 NULL, /* lpcbSecurityDescriptor */
533 NULL /* lpftLastWriteTime */
537 // get the number of entries there are from the first line
539 cm_noLocalMountPoints = dwMountPoints + dwSymlinks;
541 // create space to store the local mount points
542 cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints);
543 aLocalMountPoint = cm_localMountPoints;
545 // now we read n lines and parse them into local mount points
546 // where n is the number of local mount points there are, as
548 // Each line in the ini file represents 1 local mount point and
549 // is in the format xxx#yyy:zzz, where xxx is the directory
550 // entry name, yyy is the cell name and zzz is the volume name.
551 // #yyy:zzz together make up the mount point.
552 for ( dwIndex = 0 ; dwIndex < dwMountPoints; dwIndex++ ) {
553 TCHAR szValueName[16];
554 DWORD dwValueSize = 16;
555 dwSize = sizeof(line);
556 if (RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
557 &dwType, line, &dwSize))
559 afsi_log("RegEnumValue(hkFreelance) failed");
560 cm_noLocalMountPoints--;
564 afsi_log("Mountpoint[%d] = %s",dwIndex, line);
566 /* find the trailing dot; null terminate after it */
567 t2 = strrchr(line, '.');
571 for ( t=line;*t;t++ ) {
572 if ( !isprint(*t) ) {
573 afsi_log("error occurred while parsing mountpoint entry [%d]: non-printable character", dwIndex);
574 fprintf(stderr, "error occurred while parsing mountpoint entry [%d]: non-printable character", dwIndex);
575 cm_noLocalMountPoints--;
580 // line is not empty, so let's parse it
581 t = strchr(line, '#');
583 t = strchr(line, '%');
584 // make sure that there is a '#' or '%' separator in the line
586 afsi_log("error occurred while parsing mountpoint entry [%d]: no # or %% separator", dwIndex);
587 fprintf(stderr, "error occurred while parsing mountpoint entry [%d]: no # or %% separator", dwIndex);
588 cm_noLocalMountPoints--;
592 aLocalMountPoint->fileType = CM_SCACHETYPE_MOUNTPOINT;
593 aLocalMountPoint->namep=malloc(t-line+1);
594 strncpy(aLocalMountPoint->namep, line, t-line);
595 aLocalMountPoint->namep[t-line] = '\0';
597 /* copy the mount point string */
598 aLocalMountPoint->mountPointStringp=malloc(strlen(t));
599 strncpy(aLocalMountPoint->mountPointStringp, t, strlen(t)-1);
600 aLocalMountPoint->mountPointStringp[strlen(t)-1] = '\0';
602 osi_Log2(afsd_logp,"found mount point: name %s, string %s",
603 osi_LogSaveString(afsd_logp,aLocalMountPoint->namep),
604 osi_LogSaveString(afsd_logp,aLocalMountPoint->mountPointStringp));
609 for ( dwIndex = 0 ; dwIndex < dwSymlinks; dwIndex++ ) {
610 TCHAR szValueName[16];
611 DWORD dwValueSize = 16;
612 dwSize = sizeof(line);
613 if (RegEnumValue( hkFreelanceSymlinks, dwIndex, szValueName, &dwValueSize, NULL,
614 &dwType, line, &dwSize))
616 afsi_log("RegEnumValue(hkFreelanceSymlinks) failed");
617 cm_noLocalMountPoints--;
621 afsi_log("Symlink[%d] = %s",dwIndex, line);
623 /* find the trailing dot; null terminate after it */
624 t2 = strrchr(line, '.');
628 for ( t=line;*t;t++ ) {
629 if ( !isprint(*t) ) {
630 afsi_log("error occurred while parsing symlink entry [%d]: non-printable character", dwIndex);
631 fprintf(stderr, "error occurred while parsing symlink entry [%d]: non-printable character", dwIndex);
632 cm_noLocalMountPoints--;
637 // line is not empty, so let's parse it
638 t = strchr(line, ':');
640 // make sure that there is a ':' separator in the line
642 afsi_log("error occurred while parsing symlink entry [%d]: no ':' separator", dwIndex);
643 fprintf(stderr, "error occurred while parsing symlink entry [%d]: no ':' separator", dwIndex);
644 cm_noLocalMountPoints--;
648 aLocalMountPoint->fileType = CM_SCACHETYPE_SYMLINK;
649 aLocalMountPoint->namep=malloc(t-line+1);
650 strncpy(aLocalMountPoint->namep, line, t-line);
651 aLocalMountPoint->namep[t-line] = '\0';
653 /* copy the symlink string */
654 aLocalMountPoint->mountPointStringp=malloc(strlen(t)-1);
655 strncpy(aLocalMountPoint->mountPointStringp, t+1, strlen(t)-2);
656 aLocalMountPoint->mountPointStringp[strlen(t)-2] = '\0';
658 osi_Log2(afsd_logp,"found symlink: name %s, string %s",
659 osi_LogSaveString(afsd_logp,aLocalMountPoint->namep),
660 osi_LogSaveString(afsd_logp,aLocalMountPoint->mountPointStringp));
665 if ( hkFreelanceSymlinks )
666 RegCloseKey( hkFreelanceSymlinks );
667 RegCloseKey(hkFreelance);
671 /* What follows is the old code to read freelance mount points
672 * out of a text file modified to copy the data into the registry
674 cm_GetConfigDir(hdir, sizeof(hdir));
675 strcat(hdir, AFS_FREELANCE_INI);
676 // open the ini file for reading
677 fp = fopen(hdir, "r");
679 /* look in the Windows directory where we used to store the file */
680 GetWindowsDirectory(hdir, sizeof(hdir));
682 strcat(hdir, AFS_FREELANCE_INI);
683 fp = fopen(hdir, "r");
686 RegCreateKeyEx( HKEY_LOCAL_MACHINE,
687 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance",
690 REG_OPTION_NON_VOLATILE,
698 RegCloseKey(hkFreelance);
699 rootCellName[0] = '.';
700 code = cm_GetRootCellName(&rootCellName[1]);
702 lock_ReleaseMutex(&cm_Freelance_Lock);
703 cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL);
704 cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL);
705 cm_FreelanceAddMount(".root", &rootCellName[1], "root.afs.", 1, NULL);
706 lock_ObtainMutex(&cm_Freelance_Lock);
711 // we successfully opened the file
712 osi_Log0(afsd_logp,"opened afs_freelance.ini");
714 // now we read the first line to see how many entries
716 fgets(line, sizeof(line), fp);
718 // if the line is empty at any point when we're reading
719 // we're screwed. report error and return.
721 afsi_log("error occurred while reading afs_freelance.ini");
722 fprintf(stderr, "error occurred while reading afs_freelance.ini");
726 // get the number of entries there are from the first line
728 cm_noLocalMountPoints = atoi(line);
730 if (cm_noLocalMountPoints > 0) {
731 // create space to store the local mount points
732 cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints);
733 aLocalMountPoint = cm_localMountPoints;
736 // now we read n lines and parse them into local mount points
737 // where n is the number of local mount points there are, as
739 // Each line in the ini file represents 1 local mount point and
740 // is in the format xxx#yyy:zzz, where xxx is the directory
741 // entry name, yyy is the cell name and zzz is the volume name.
742 // #yyy:zzz together make up the mount point.
743 for (i=0; i<cm_noLocalMountPoints; i++) {
744 fgets(line, sizeof(line), fp);
745 // check that the line is not empty
747 afsi_log("error occurred while parsing entry in %s: empty line in line %d", AFS_FREELANCE_INI, i);
748 fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: empty line in line %d", i);
752 /* find the trailing dot; null terminate after it */
753 t2 = strrchr(line, '.');
759 /* we are migrating to the registry */
760 sprintf(szIndex,"%d",dwIndex++);
762 dwSize = (DWORD)strlen(line) + 1;
763 RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
766 // line is not empty, so let's parse it
767 t = strchr(line, '#');
769 t = strchr(line, '%');
770 // make sure that there is a '#' or '%' separator in the line
772 afsi_log("error occurred while parsing entry in %s: no # or %% separator in line %d", AFS_FREELANCE_INI, i);
773 fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: no # or %% separator in line %d", i);
776 aLocalMountPoint->namep=malloc(t-line+1);
777 memcpy(aLocalMountPoint->namep, line, t-line);
778 *(aLocalMountPoint->namep + (t-line)) = 0;
780 aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1);
781 memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-1);
782 *(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-1)) = 0;
784 osi_Log2(afsd_logp,"found mount point: name %s, string %s",
785 aLocalMountPoint->namep,
786 aLocalMountPoint->mountPointStringp);
792 RegCloseKey(hkFreelance);
798 int cm_getNoLocalMountPoints() {
799 return cm_noLocalMountPoints;
802 long cm_FreelanceMountPointExists(char * filename, int prefix_ok)
808 HKEY hkFreelance = 0;
809 DWORD dwType, dwSize;
813 lock_ObtainMutex(&cm_Freelance_Lock);
815 if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,
816 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance",
818 KEY_READ|KEY_QUERY_VALUE,
819 &hkFreelance) == ERROR_SUCCESS)
821 RegQueryInfoKey( hkFreelance,
824 NULL, /* lpReserved */
825 NULL, /* lpcSubKeys */
826 NULL, /* lpcMaxSubKeyLen */
827 NULL, /* lpcMaxClassLen */
828 &dwMountPoints, /* lpcValues */
829 NULL, /* lpcMaxValueNameLen */
830 NULL, /* lpcMaxValueLen */
831 NULL, /* lpcbSecurityDescriptor */
832 NULL /* lpftLastWriteTime */
835 for ( dwIndex = 0; dwIndex < dwMountPoints; dwIndex++ ) {
836 TCHAR szValueName[16];
837 DWORD dwValueSize = 16;
838 dwSize = sizeof(line);
839 RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
840 &dwType, line, &dwSize);
842 cp=strchr(line, '#');
844 cp=strchr(line, '%');
845 memcpy(shortname, line, cp-line);
846 shortname[cp-line]=0;
848 if (!strcmp(shortname, filename)) {
853 for ( dwIndex = 0; dwIndex < dwMountPoints; dwIndex++ ) {
854 TCHAR szValueName[16];
855 DWORD dwValueSize = 16;
856 dwSize = sizeof(line);
857 RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
858 &dwType, line, &dwSize);
860 cp=strchr(line, '#');
862 cp=strchr(line, '%');
863 memcpy(shortname, line, cp-line);
864 shortname[cp-line]=0;
866 if (!cm_stricmp_utf8(shortname, filename)) {
871 if (prefix_ok && strlen(shortname) - strlen(filename) == 1 && !strncmp(shortname, filename, strlen(filename))) {
876 RegCloseKey(hkFreelance);
879 lock_ReleaseMutex(&cm_Freelance_Lock);
884 long cm_FreelanceSymlinkExists(char * filename, int prefix_ok)
890 HKEY hkFreelance = 0;
891 DWORD dwType, dwSize;
895 lock_ObtainMutex(&cm_Freelance_Lock);
897 if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,
898 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance\\Symlinks",
900 KEY_READ|KEY_QUERY_VALUE,
901 &hkFreelance) == ERROR_SUCCESS)
903 RegQueryInfoKey( hkFreelance,
906 NULL, /* lpReserved */
907 NULL, /* lpcSubKeys */
908 NULL, /* lpcMaxSubKeyLen */
909 NULL, /* lpcMaxClassLen */
910 &dwSymlinks, /* lpcValues */
911 NULL, /* lpcMaxValueNameLen */
912 NULL, /* lpcMaxValueLen */
913 NULL, /* lpcbSecurityDescriptor */
914 NULL /* lpftLastWriteTime */
917 for ( dwIndex = 0; dwIndex < dwSymlinks; dwIndex++ ) {
918 TCHAR szValueName[16];
919 DWORD dwValueSize = 16;
920 dwSize = sizeof(line);
921 RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
922 &dwType, line, &dwSize);
924 cp=strchr(line, ':');
925 memcpy(shortname, line, cp-line);
926 shortname[cp-line]=0;
928 if (!strcmp(shortname, filename)) {
933 if (prefix_ok && strlen(shortname) - strlen(filename) == 1 && !strncmp(shortname, filename, strlen(filename))) {
938 for ( dwIndex = 0; dwIndex < dwSymlinks; dwIndex++ ) {
939 TCHAR szValueName[16];
940 DWORD dwValueSize = 16;
941 dwSize = sizeof(line);
942 RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
943 &dwType, line, &dwSize);
945 cp=strchr(line, ':');
946 memcpy(shortname, line, cp-line);
947 shortname[cp-line]=0;
949 if (!cm_stricmp_utf8(shortname, filename)) {
954 RegCloseKey(hkFreelance);
957 lock_ReleaseMutex(&cm_Freelance_Lock);
962 long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp)
967 char fullname[CELL_MAXNAMELEN];
970 HKEY hkFreelance = 0;
971 DWORD dwType, dwSize;
975 /* before adding, verify the cell name; if it is not a valid cell,
976 don't add the mount point.
977 allow partial matches as a means of poor man's alias. */
978 /* major performance issue? */
979 osi_Log4(afsd_logp,"Freelance Add Mount request: filename=%s cellname=%s volume=%s %s",
980 osi_LogSaveString(afsd_logp,filename),
981 osi_LogSaveString(afsd_logp,cellname),
982 osi_LogSaveString(afsd_logp,volume),
985 if ( filename[0] == '\0' || cellname[0] == '\0' || volume[0] == '\0' )
988 if (cellname[0] == '.') {
989 if (!cm_GetCell_Gen(&cellname[1], fullname, CM_FLAG_CREATE))
992 if (!cm_GetCell_Gen(cellname, fullname, CM_FLAG_CREATE))
996 if ( cm_FreelanceMountPointExists(filename, 0) ||
997 cm_FreelanceSymlinkExists(filename, 0) )
1000 osi_Log1(afsd_logp,"Freelance Adding Mount for Cell: %s",
1001 osi_LogSaveString(afsd_logp,cellname));
1003 lock_ObtainMutex(&cm_Freelance_Lock);
1005 if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,
1006 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance",
1008 KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
1009 &hkFreelance) == ERROR_SUCCESS) {
1011 RegQueryInfoKey( hkFreelance,
1013 NULL, /* lpcClass */
1014 NULL, /* lpReserved */
1015 NULL, /* lpcSubKeys */
1016 NULL, /* lpcMaxSubKeyLen */
1017 NULL, /* lpcMaxClassLen */
1018 &dwMountPoints, /* lpcValues */
1019 NULL, /* lpcMaxValueNameLen */
1020 NULL, /* lpcMaxValueLen */
1021 NULL, /* lpcbSecurityDescriptor */
1022 NULL /* lpftLastWriteTime */
1026 sprintf(line, "%s%%%s:%s", filename, fullname, volume);
1028 sprintf(line, "%s#%s:%s", filename, fullname, volume);
1030 /* If we are adding a new value, there must be an unused name
1031 * within the range 0 to dwMountPoints
1033 for ( dwIndex = 0; dwIndex <= dwMountPoints; dwIndex++ ) {
1037 dwSize = sizeof(szMount);
1038 sprintf(szIndex, "%d", dwIndex);
1039 if (RegQueryValueEx( hkFreelance, szIndex, 0, &dwType, szMount, &dwSize) != ERROR_SUCCESS) {
1040 /* found an unused value */
1042 dwSize = (DWORD)strlen(line) + 1;
1043 RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
1046 int len = (int)strlen(filename);
1047 if ( dwType == REG_SZ && !strncmp(filename, szMount, len) &&
1048 (szMount[len] == '%' || szMount[len] == '#')) {
1049 /* Replace the existing value */
1051 dwSize = (DWORD)strlen(line) + 1;
1052 RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
1057 RegCloseKey(hkFreelance);
1060 cm_GetConfigDir(hfile, sizeof(hfile));
1061 strcat(hfile, AFS_FREELANCE_INI);
1062 fp = fopen(hfile, "r+");
1064 return CM_ERROR_INVAL;
1065 fgets(line, sizeof(line), fp);
1068 fseek(fp, 0, SEEK_SET);
1069 fprintf(fp, "%d", n);
1070 fseek(fp, 0, SEEK_END);
1072 fprintf(fp, "%s%%%s:%s\n", filename, fullname, volume);
1074 fprintf(fp, "%s#%s:%s\n", filename, fullname, volume);
1078 /* Do this while we are holding the lock */
1079 cm_data.fakeDirVersion++;
1080 cm_localMountPointChangeFlag = 1;
1081 lock_ReleaseMutex(&cm_Freelance_Lock);
1087 clientchar_t *cpath;
1091 cpath = cm_FsStringToClientStringAlloc(filename, -1, NULL);
1093 return CM_ERROR_NOSUCHPATH;
1094 code = cm_NameI(cm_data.rootSCachep, cpath,
1095 CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD | CM_FLAG_DFS_REFERRAL,
1096 cm_rootUserp, NULL, &req, &scp);
1101 cm_ReleaseSCache(scp);
1107 long cm_FreelanceRemoveMount(char *toremove)
1112 char shortname[200];
1113 char hfile[260], hfile2[260];
1116 HKEY hkFreelance = 0;
1117 DWORD dwType, dwSize;
1118 DWORD dwMountPoints;
1121 lock_ObtainMutex(&cm_Freelance_Lock);
1123 if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,
1124 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance",
1126 KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
1127 &hkFreelance) == ERROR_SUCCESS) {
1129 RegQueryInfoKey( hkFreelance,
1131 NULL, /* lpcClass */
1132 NULL, /* lpReserved */
1133 NULL, /* lpcSubKeys */
1134 NULL, /* lpcMaxSubKeyLen */
1135 NULL, /* lpcMaxClassLen */
1136 &dwMountPoints, /* lpcValues */
1137 NULL, /* lpcMaxValueNameLen */
1138 NULL, /* lpcMaxValueLen */
1139 NULL, /* lpcbSecurityDescriptor */
1140 NULL /* lpftLastWriteTime */
1143 for ( dwIndex = 0; dwIndex < dwMountPoints; dwIndex++ ) {
1144 TCHAR szValueName[16];
1145 DWORD dwValueSize = 16;
1146 dwSize = sizeof(line);
1147 RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
1148 &dwType, line, &dwSize);
1150 cp=strchr(line, '#');
1152 cp=strchr(line, '%');
1153 memcpy(shortname, line, cp-line);
1154 shortname[cp-line]=0;
1156 if (!strcmp(shortname, toremove)) {
1157 RegDeleteValue( hkFreelance, szValueName );
1162 RegCloseKey(hkFreelance);
1165 cm_GetConfigDir(hfile, sizeof(hfile));
1166 strcat(hfile, AFS_FREELANCE_INI);
1167 strcpy(hfile2, hfile);
1168 strcat(hfile2, "2");
1169 fp1=fopen(hfile, "r+");
1171 return CM_ERROR_INVAL;
1172 fp2=fopen(hfile2, "w+");
1175 return CM_ERROR_INVAL;
1178 fgets(line, sizeof(line), fp1);
1180 fprintf(fp2, "%d\n", n-1);
1182 for (i=0; i<n; i++) {
1183 fgets(line, sizeof(line), fp1);
1184 cp=strchr(line, '#');
1186 cp=strchr(line, '%');
1187 memcpy(shortname, line, cp-line);
1188 shortname[cp-line]=0;
1190 if (strcmp(shortname, toremove)==0) {
1202 rename(hfile2, hfile);
1207 /* Do this while we are holding the lock */
1208 cm_data.fakeDirVersion++;
1209 cm_localMountPointChangeFlag = 1;
1211 lock_ReleaseMutex(&cm_Freelance_Lock);
1212 return (found ? 0 : CM_ERROR_NOSUCHFILE);
1215 long cm_FreelanceAddSymlink(char *filename, char *destination, cm_fid_t *fidp)
1218 char fullname[CELL_MAXNAMELEN];
1220 HKEY hkFreelanceSymlinks = 0;
1221 DWORD dwType, dwSize;
1225 /* before adding, verify the filename. If it is already in use, either as
1226 * as mount point or a cellname, do not permit the creation of the symlink.
1228 osi_Log2(afsd_logp,"Freelance Add Symlink request: filename=%s destination=%s",
1229 osi_LogSaveString(afsd_logp,filename),
1230 osi_LogSaveString(afsd_logp,destination));
1232 if ( filename[0] == '\0' || destination[0] == '\0' )
1233 return CM_ERROR_INVAL;
1236 if (filename[0] == '.') {
1237 cm_GetCell_Gen(&filename[1], fullname, CM_FLAG_CREATE);
1238 if (cm_stricmp_utf8(&filename[1],fullname) == 0)
1239 return CM_ERROR_EXISTS;
1241 cm_GetCell_Gen(filename, fullname, CM_FLAG_CREATE);
1242 if (cm_stricmp_utf8(filename,fullname) == 0)
1243 return CM_ERROR_EXISTS;
1246 if ( cm_FreelanceMountPointExists(filename, 0) ||
1247 cm_FreelanceSymlinkExists(filename, 0) )
1248 return CM_ERROR_EXISTS;
1250 lock_ObtainMutex(&cm_Freelance_Lock);
1252 if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
1253 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance\\Symlinks",
1256 REG_OPTION_NON_VOLATILE,
1257 KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
1259 &hkFreelanceSymlinks,
1260 NULL) == ERROR_SUCCESS) {
1262 RegQueryInfoKey( hkFreelanceSymlinks,
1264 NULL, /* lpcClass */
1265 NULL, /* lpReserved */
1266 NULL, /* lpcSubKeys */
1267 NULL, /* lpcMaxSubKeyLen */
1268 NULL, /* lpcMaxClassLen */
1269 &dwSymlinks, /* lpcValues */
1270 NULL, /* lpcMaxValueNameLen */
1271 NULL, /* lpcMaxValueLen */
1272 NULL, /* lpcbSecurityDescriptor */
1273 NULL /* lpftLastWriteTime */
1276 sprintf(line, "%s:%s.", filename, destination);
1278 /* If we are adding a new value, there must be an unused name
1279 * within the range 0 to dwSymlinks
1281 for ( dwIndex = 0; dwIndex <= dwSymlinks; dwIndex++ ) {
1285 dwSize = sizeof(szLink);
1286 sprintf(szIndex, "%d", dwIndex);
1287 if (RegQueryValueEx( hkFreelanceSymlinks, szIndex, 0, &dwType, szLink, &dwSize) != ERROR_SUCCESS) {
1288 /* found an unused value */
1290 dwSize = (DWORD)strlen(line) + 1;
1291 RegSetValueEx( hkFreelanceSymlinks, szIndex, 0, dwType, line, dwSize);
1294 int len = (int)strlen(filename);
1295 if ( dwType == REG_SZ && !strncmp(filename, szLink, len) && szLink[len] == ':') {
1296 /* Replace the existing value */
1298 dwSize = (DWORD)strlen(line) + 1;
1299 RegSetValueEx( hkFreelanceSymlinks, szIndex, 0, dwType, line, dwSize);
1304 RegCloseKey(hkFreelanceSymlinks);
1307 /* Do this while we are holding the lock */
1308 cm_data.fakeDirVersion++;
1309 cm_localMountPointChangeFlag = 1;
1310 lock_ReleaseMutex(&cm_Freelance_Lock);
1316 clientchar_t *cpath;
1320 cpath = cm_FsStringToClientStringAlloc(filename, -1, NULL);
1322 return CM_ERROR_NOSUCHPATH;
1323 code = cm_NameI(cm_data.rootSCachep, cpath,
1324 CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD | CM_FLAG_DFS_REFERRAL,
1325 cm_rootUserp, NULL, &req, &scp);
1330 cm_ReleaseSCache(scp);
1336 long cm_FreelanceRemoveSymlink(char *toremove)
1340 char shortname[200];
1342 HKEY hkFreelanceSymlinks = 0;
1343 DWORD dwType, dwSize;
1347 lock_ObtainMutex(&cm_Freelance_Lock);
1349 if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,
1350 AFSREG_CLT_OPENAFS_SUBKEY "\\Freelance\\Symlinks",
1352 KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
1353 &hkFreelanceSymlinks) == ERROR_SUCCESS) {
1355 RegQueryInfoKey( hkFreelanceSymlinks,
1357 NULL, /* lpcClass */
1358 NULL, /* lpReserved */
1359 NULL, /* lpcSubKeys */
1360 NULL, /* lpcMaxSubKeyLen */
1361 NULL, /* lpcMaxClassLen */
1362 &dwSymlinks, /* lpcValues */
1363 NULL, /* lpcMaxValueNameLen */
1364 NULL, /* lpcMaxValueLen */
1365 NULL, /* lpcbSecurityDescriptor */
1366 NULL /* lpftLastWriteTime */
1369 for ( dwIndex = 0; dwIndex < dwSymlinks; dwIndex++ ) {
1370 TCHAR szValueName[16];
1371 DWORD dwValueSize = 16;
1372 dwSize = sizeof(line);
1373 RegEnumValue( hkFreelanceSymlinks, dwIndex, szValueName, &dwValueSize, NULL,
1374 &dwType, line, &dwSize);
1376 cp=strchr(line, ':');
1377 memcpy(shortname, line, cp-line);
1378 shortname[cp-line]=0;
1380 if (!strcmp(shortname, toremove)) {
1381 RegDeleteValue( hkFreelanceSymlinks, szValueName );
1386 RegCloseKey(hkFreelanceSymlinks);
1390 /* Do this while we are holding the lock */
1391 cm_data.fakeDirVersion++;
1392 cm_localMountPointChangeFlag = 1;
1394 lock_ReleaseMutex(&cm_Freelance_Lock);
1395 return (found ? 0 : CM_ERROR_NOSUCHFILE);
1399 cm_FreelanceFetchMountPointString(cm_scache_t *scp)
1401 lock_ObtainMutex(&cm_Freelance_Lock);
1402 if (!scp->mountPointStringp[0] &&
1403 scp->fid.cell == AFS_FAKE_ROOT_CELL_ID &&
1404 scp->fid.volume == AFS_FAKE_ROOT_VOL_ID &&
1405 scp->fid.unique <= cm_noLocalMountPoints) {
1406 strncpy(scp->mountPointStringp, cm_localMountPoints[scp->fid.unique-1].mountPointStringp, MOUNTPOINTLEN);
1407 scp->mountPointStringp[MOUNTPOINTLEN-1] = 0; /* null terminate */
1409 lock_ReleaseMutex(&cm_Freelance_Lock);
1415 cm_FreelanceFetchFileType(cm_scache_t *scp)
1417 lock_ObtainMutex(&cm_Freelance_Lock);
1418 if (scp->fid.cell == AFS_FAKE_ROOT_CELL_ID &&
1419 scp->fid.volume == AFS_FAKE_ROOT_VOL_ID &&
1420 scp->fid.unique <= cm_noLocalMountPoints)
1422 scp->fileType = cm_localMountPoints[scp->fid.unique-1].fileType;
1424 if ( scp->fileType == CM_SCACHETYPE_SYMLINK &&
1425 !strnicmp(cm_localMountPoints[scp->fid.unique-1].mountPointStringp, "msdfs:", strlen("msdfs:")) )
1427 scp->fileType = CM_SCACHETYPE_DFSLINK;
1430 scp->fileType = CM_SCACHETYPE_INVALID;
1432 lock_ReleaseMutex(&cm_Freelance_Lock);
1436 #endif /* AFS_FREELANCE_CLIENT */