/* this should really be in an init daemon from here on down */
if (!cm_freelanceEnabled) {
+ osi_Log0(afsd_logp, "Loading Root Volume from cell");
code = cm_GetVolumeByName(cm_rootCellp, cm_rootVolumeName, cm_rootUserp,
&req, CM_FLAG_CREATE, &cm_rootVolumep);
afsi_log("cm_GetVolumeByName code %x root vol %x", code,
/* read/write lock for all global storage in this module */
osi_rwlock_t cm_callbackLock;
-/*
-#ifdef AFS_FREELANCE_CLIENT
-extern int cm_fakeDirCallback;
-extern int cm_fakeGettingCallback;
-#endif
-*/
#ifdef AFS_FREELANCE_CLIENT
extern osi_mutex_t cm_Freelance_Lock;
#endif
// good shape and we simply return true, provided no change is detected.
int fdc, fgc;
- if (cm_freelanceEnabled && scp->fid.cell==0x1 && scp->fid.volume==0x20000001) { // if it's something on /afs
+ if (cm_freelanceEnabled && scp->fid.cell==0x1 && scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) { // if it's something on /afs
if (!(scp->fid.vnode==0x1 && scp->fid.unique==0x1)) // if it's not root.afs
return 1;
else {
// cm_MergeStatus and mark that cm_fakeDirCallback is 2
if (cm_freelanceEnabled &&
scp->fid.cell==0x1 &&
- scp->fid.volume==0x20000001 &&
+ scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
scp->fid.unique==0x1 &&
scp->fid.vnode==0x1) {
// Start by indicating that we're in the process
return 0;
}
- /*if (scp->fid.cell==0x1 && scp->fid.volume==0x20000001) {
- afsi_log("cm_getcallback should NEVER EVER get here... ");
- }*/
+ if (scp->fid.cell==0x1 && scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) {
+ osi_Log0(afsd_logp,"cm_getcallback should NEVER EVER get here... ");
+ }
// yj: end of getcallback modifications ---------------
#endif /* AFS_FREELANCE_CLIENT */
// handle it differently, since it's local rather than on any
// server
- getroot = (scp==cm_rootSCachep) ;
+ getroot = (scp==cm_rootSCachep);
+ if (getroot)
+ osi_Log1(afsd_logp,"GetBuffer returns cm_rootSCachep=%x",cm_rootSCachep);
#endif
cm_AFSFidFromFid(&tfid, &scp->fid);
// 0.
lock_ObtainMutex(&cm_Freelance_Lock);
-#ifdef DEBUG
- afsi_log("bufp->offset is %d", bufp->offset);
-#endif
t1 = bufp->offset.LowPart;
qdp = biod.bufListEndp;
while (qdp) {
memset(bufferp, 0, buf_bufferSize);
t2 = cm_fakeDirSize - t1;
if (t2>buf_bufferSize) t2=buf_bufferSize;
-#ifdef DEBUG
- afsi_log("t1:%d, t2:%d", t1, t2);
-#endif
if (t2 > 0) {
memcpy(bufferp, cm_FakeRootDir+t1, t2);
} else {
biod.length);
/* now copy the data out of the pipe and put it in the buffer */
- temp = rx_Read(callp, &nbytes, 4);
+ temp = rx_Read(callp, (char *)&nbytes, 4);
if (temp == 4) {
nbytes = ntohl(nbytes);
if (nbytes > biod.length)
void cm_InitFreelance() {
+#ifdef COMMENT
+ while ( !IsDebuggerPresent() ) {
+ Sleep(1000);
+ }
+#endif
+
lock_InitializeMutex(&cm_Freelance_Lock, "Freelance Lock");
// yj: first we make a call to cm_initLocalMountPoints
cm_FakeRootDir = malloc(dirSize);
cm_fakeDirSize = dirSize;
-
-
// yj: when we get here, we've figured out how much memory we need and
// allocated the appropriate space for it. we now prceed to fill
// it up with entries.
cm_fakeDirCallback=1;
// when we get here, we've set up everything! done!
-
-
}
int cm_FakeRootFid(cm_fid_t *fidp)
{
fidp->cell = 0x1; /* root cell */
- fidp->volume = 0x20000001; /* root.afs ? */
+ fidp->volume = AFS_FAKE_ROOT_VOL_ID; /* root.afs ? */
fidp->vnode = 0x1;
fidp->unique = 0x1;
return 0;
cm_scache_t *scp, **lscpp, *tscp;
- printf("\n\n----- reinitialization starts ----- \n");
-
+ osi_Log0(afsd_logp,"----- freelance reinitialization starts ----- ");
// first we invalidate all the SCPs that were created
// for the local mount points
- printf("Invalidating local mount point scp... ");
+ osi_Log0(afsd_logp,"Invalidating local mount point scp... ");
aFid.cell = 0x1;
- aFid.volume=0x20000001;
+ aFid.volume=AFS_FAKE_ROOT_VOL_ID;
aFid.unique=0x1;
aFid.vnode=0x2;
aFid.vnode = aFid.vnode + 1;
}
lock_ReleaseWrite(&cm_scacheLock);
- printf("\tall old scp cleared!\n");
+ osi_Log0(afsd_logp,"\tall old scp cleared!");
// we must free the memory that was allocated in the prev
// cm_InitLocalMountPoints call
- printf("Removing old localmountpoints... ");
+ osi_Log0(afsd_logp,"Removing old localmountpoints... ");
free(cm_localMountPoints);
- printf("\tall old localmountpoints cleared!\n");
+ osi_Log0(afsd_logp,"\tall old localmountpoints cleared!");
// now re-init the localmountpoints
- printf("Creating new localmountpoints... ");
+ osi_Log0(afsd_logp,"Creating new localmountpoints... ");
cm_InitLocalMountPoints();
- printf("\tcreated new set of localmountpoints!\n");
+ osi_Log0(afsd_logp,"\tcreated new set of localmountpoints!");
// now we have to free the memory allocated in cm_initfakerootdir
- printf("Removing old fakedir... ");
+ osi_Log0(afsd_logp,"Removing old fakedir... ");
free(cm_FakeRootDir);
- printf("\t\told fakedir removed!\n");
+ osi_Log0(afsd_logp,"\t\told fakedir removed!");
// then we re-create that dir
- printf("Creating new fakedir... ");
+ osi_Log0(afsd_logp,"Creating new fakedir... ");
cm_InitFakeRootDir();
- printf("\t\tcreated new fakedir!\n");
+ osi_Log0(afsd_logp,"\t\tcreated new fakedir!");
lock_ReleaseMutex(&cm_Freelance_Lock);
- printf("----- reinit complete -----\n\n");
+ osi_Log0(afsd_logp,"----- freelance reinit complete -----");
return 0;
}
}
// we successfully opened the file
-#ifdef DEBUG
- fprintf(stderr, "opened afs_freelance.ini\n");
-#endif
+ osi_Log0(afsd_logp,"opened afs_freelance.ini");
// now we read the first line to see how many entries
// there are
aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1);
memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-2);
*(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-2)) = 0;
-#ifdef DEBUG
- fprintf(stderr, "found mount point: name %s, string %s\n",
+
+ osi_Log2(afsd_logp,"found mount point: name %s, string %s",
aLocalMountPoint->namep,
aLocalMountPoint->mountPointStringp);
-#endif
-
- aLocalMountPoint++;
+ aLocalMountPoint++;
}
fclose(fp);
return 0;
char line[200];
char fullname[200];
int n;
+ int alias = 0;
/* before adding, verify the cell name; if it is not a valid cell,
- don't add the mount point */
+ don't add the mount point.
+ allow partial matches as a means of poor man's alias. */
/* major performance issue? */
- if (!cm_GetCell_Gen(cellname, fullname, CM_FLAG_CREATE))
- return -1;
-#if 0
- if (strcmp(cellname, fullname) != 0) /* no partial matches allowed */
- return -1;
-#endif
+ osi_Log3(afsd_logp,"Freelance Add Mount request: filename=%s cellname=%s volume=%s",
+ filename, cellname, volume);
+ if (cellname[0] == '.') {
+ if (!cm_GetCell_Gen(&cellname[1], &fullname[1], CM_FLAG_CREATE))
+ return -1;
+ fullname[0]='.';
+ } else {
+ if (!cm_GetCell_Gen(cellname, fullname, CM_FLAG_CREATE))
+ return -1;
+ }
+ osi_Log1(afsd_logp,"Freelance Adding Mount for Cell: %s", cellname);
+
lock_ObtainMutex(&cm_Freelance_Lock);
cm_GetConfigDir(hfile);
fclose(fp);
lock_ReleaseMutex(&cm_Freelance_Lock);
- /*cm_reInitLocalMountPoints(&vnode);*/
+ /* cm_reInitLocalMountPoints(); */
if (fidp) {
fidp->unique = 1;
fidp->vnode = cm_noLocalMountPoints + 1; /* vnode value of last mt pt */
}
cm_noteLocalMountPointChange();
-
+
return 0;
}
extern int cm_getLocalMountPointChange();
extern int cm_reInitLocalMountPoints();
extern cm_localMountPoint_t* cm_getLocalMountPoint(int vnode);
+extern void cm_InitFreelance();
+extern long cm_FreelanceRemoveMount(char *toremove);
+extern long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, cm_fid_t *fidp);
#define AFS_FREELANCE_INI "afs_freelance.ini"
-
+#define AFS_FAKE_ROOT_VOL_ID 0x00000001
#endif // _CM_FREELANCE_H
if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
/* we are adding the mount point to the root dir., so call
the freelance code to do the add. */
+ osi_Log0(afsd_logp,"IoctlCreateMountPoint within Freelance root dir");
code = cm_FreelanceAddMount(leaf, fullCell, volume, NULL);
return code;
}
cm_req_t *reqp)
{
long hash;
- cm_scache_t *scp;
- long code;
- cm_volume_t *volp;
- cm_cell_t *cellp;
+ cm_scache_t *scp;
+ long code;
+ cm_volume_t *volp;
+ cm_cell_t *cellp;
char* mp;
int special; // yj: boolean variable to test if file is on root.afs
int isRoot;
- hash = CM_SCACHE_HASH(fidp);
+ hash = CM_SCACHE_HASH(fidp);
osi_assert(fidp->cell != 0);
// yj: check if we have the scp, if so, we don't need
// to do anything else
- lock_ObtainWrite(&cm_scacheLock);
+ lock_ObtainWrite(&cm_scacheLock);
for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (cm_FidCmp(fidp, &scp->fid) == 0) {
scp->refCount++;
- *outScpp = scp;
- cm_AdjustLRU(scp);
- lock_ReleaseWrite(&cm_scacheLock);
+ *outScpp = scp;
+ cm_AdjustLRU(scp);
+ lock_ReleaseWrite(&cm_scacheLock);
return 0;
- }
}
+ }
// yj: when we get here, it means we don't have an scp
// so we need to either load it or fake it, depending
// because we have to fill in the status stuff 'coz we
// don't want trybulkstat to fill it in for us
#ifdef AFS_FREELANCE_CLIENT
- special = (fidp->cell==0x1 && fidp->volume==0x20000001 &&
+ special = (fidp->cell==0x1 && fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
!(fidp->vnode==0x1 && fidp->unique==0x1));
- isRoot = (fidp->cell==0x1 && fidp->volume==0x20000001 &&
+ isRoot = (fidp->cell==0x1 && fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
fidp->vnode==0x1 && fidp->unique==0x1);
if (cm_freelanceEnabled && isRoot) {
+ osi_Log0(afsd_logp,"cm_getSCache Freelance and isRoot");
/* freelance: if we are trying to get the root scp for the first
time, we will just put in a place holder entry. */
- volp = NULL;
+ volp = NULL;
}
if (cm_freelanceEnabled && special) {
- /*afsi_log("cm_getscache: special"); */
- lock_ObtainMutex(&cm_Freelance_Lock);
+ osi_Log0(afsd_logp,"cm_getSCache Freelance and special");
+ lock_ObtainMutex(&cm_Freelance_Lock);
mp =(cm_localMountPoints+fidp->vnode-2)->mountPointStringp;
lock_ReleaseMutex(&cm_Freelance_Lock);
if (scp->dotdotFidp == (cm_fid_t *) NULL)
scp->dotdotFidp = (cm_fid_t *) malloc (sizeof(cm_fid_t));
scp->dotdotFidp->cell=0x1;
- scp->dotdotFidp->volume=0x20000001;
+ scp->dotdotFidp->volume=AFS_FAKE_ROOT_VOL_ID;
scp->dotdotFidp->unique=1;
scp->dotdotFidp->vnode=1;
scp->flags |= (CM_SCACHEFLAG_PURERO | CM_SCACHEFLAG_RO);
// end of yj code
#endif /* AFS_FREELANCE_CLIENT */
- /* otherwise, we need to find the volume */
+ /* otherwise, we need to find the volume */
if (!cm_freelanceEnabled || !isRoot) {
- lock_ReleaseWrite(&cm_scacheLock); /* for perf. reasons */
- cellp = cm_FindCellByID(fidp->cell);
- if (!cellp) return CM_ERROR_NOSUCHCELL;
-
- code = cm_GetVolumeByID(cellp, fidp->volume, userp, reqp, &volp);
- if (code) return code;
- lock_ObtainWrite(&cm_scacheLock);
+ lock_ReleaseWrite(&cm_scacheLock); /* for perf. reasons */
+ cellp = cm_FindCellByID(fidp->cell);
+ if (!cellp)
+ return CM_ERROR_NOSUCHCELL;
+
+ code = cm_GetVolumeByID(cellp, fidp->volume, userp, reqp, &volp);
+ if (code)
+ return code;
+ lock_ObtainWrite(&cm_scacheLock);
}
/* otherwise, we have the volume, now reverify that the scp doesn't
for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (cm_FidCmp(fidp, &scp->fid) == 0) {
scp->refCount++;
- cm_AdjustLRU(scp);
- lock_ReleaseWrite(&cm_scacheLock);
- cm_PutVolume(volp);
- *outScpp = scp;
+ cm_AdjustLRU(scp);
+ lock_ReleaseWrite(&cm_scacheLock);
+ cm_PutVolume(volp);
+ *outScpp = scp;
return 0;
- }
}
+ }
- /* now, if we don't have the fid, recycle something */
+ /* now, if we don't have the fid, recycle something */
scp = cm_GetNewSCache();
osi_assert(!(scp->flags & CM_SCACHEFLAG_INHASH));
scp->fid = *fidp;
}
scp->nextp = cm_hashTablep[hash];
cm_hashTablep[hash] = scp;
- scp->flags |= CM_SCACHEFLAG_INHASH;
+ scp->flags |= CM_SCACHEFLAG_INHASH;
scp->refCount = 1;
- lock_ReleaseWrite(&cm_scacheLock);
+ lock_ReleaseWrite(&cm_scacheLock);
- /* now we have a held scache entry; just return it */
- *outScpp = scp;
-
- return 0;
+ /* now we have a held scache entry; just return it */
+ *outScpp = scp;
+ return 0;
}
/* synchronize a fetch, store, read, write, fetch status or store status.
&& (!cm_freelanceEnabled || !(!(scp->fid.vnode==0x1 &&
scp->fid.unique==0x1) &&
scp->fid.cell==0x1 &&
- scp->fid.volume==0x20000001))
+ scp->fid.volume==AFS_FAKE_ROOT_VOL_ID))
#endif /* AFS_FREELANCE_CLIENT */
) {
if (!cm_HaveCallback(scp)) {
// entries under that directory
#ifdef AFS_FREELANCE_CLIENT
if (cm_freelanceEnabled && scp == cm_rootSCachep) {
+ osi_Log0(afsd_logp,"cm_MergeStatus Freelance cm_rootSCachep");
statusp->InterfaceVersion = 0x1;
statusp->FileType = 0x2;
statusp->LinkCount = scp->linkCount;
return CM_ERROR_NOSUCHFILE;
}
else { /* nonexistent dir on freelance root, so add it */
+ osi_Log1(afsd_logp,"cm_Lookup adding mount for non-existent directory: %s", namep);
code = cm_FreelanceAddMount(namep, namep, "root.cell.",
&rock.fid);
if (code < 0) { /* add mount point failed, so give up */
// to be bulkstat-ed, instead, we call getSCache directly and under
// getSCache, it is handled specially.
if (cm_freelanceEnabled &&
- tfid.cell==0x1 && tfid.volume==0x20000001 &&
+ tfid.cell==0x1 && tfid.volume==AFS_FAKE_ROOT_VOL_ID &&
!(tfid.vnode==0x1 && tfid.unique==0x1) )
{
- osi_Log0(afsd_logp, "cm_TryBulkProc calling cm_GetSCache to avoid BulkStat");
+ osi_Log0(afsd_logp, "cm_TryBulkProc Freelance calls cm_SCache on root.afs mountpoint");
return cm_GetSCache(&tfid, &tscp, NULL, NULL);
}
#endif /* AFS_FREELANCE_CLIENT */