#include "cm_freelance.h"
#include "stdio.h"
+extern void afsi_log(char *pattern, ...);
+
int cm_noLocalMountPoints;
int cm_fakeDirSize;
int cm_fakeDirCallback=0;
/* to be called while holding freelance lock unless during init. */
void cm_InitFakeRootDir() {
- int i, j, t1, t2;
+ int i, t1, t2;
char* currentPos;
int noChunks;
- char mask;
-
// allocate space for the fake info
cm_dirHeader_t fakeDirHeader;
int curDirEntryInPage = 0;
int sizeOfCurEntry;
int dirSize;
-
+
+ /* Reserve 2 directory chunks for "." and ".." */
+ curChunk += 2;
while (curDirEntry!=cm_noLocalMountPoints) {
sizeOfCurEntry = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
(curDirEntryInPage + 1 >= CM_DIR_EPP)) {
curPage++;
curDirEntryInPage = 0;
- curChunk = 0;
+ curChunk = 1;
}
curChunk += sizeOfCurEntry;
curDirEntry++;
int cm_FakeRootFid(cm_fid_t *fidp)
{
- fidp->cell = 0x1; /* root cell */
- fidp->volume = 0x20000001; /* root.afs ? */
- fidp->vnode = 0x1;
- fidp->unique = 0x1;
+ fidp->cell = 0x1; /* root cell */
+ fidp->volume = 0x20000001; /* root.afs ? */
+ fidp->vnode = 0x1;
+ fidp->unique = 0x1;
+ return 0;
}
int cm_getLocalMountPointChange() {
int cm_clearLocalMountPointChange() {
cm_localMountPointChangeFlag = 0;
+ return 0;
}
/* called directly from ioctl */
int cm_reInitLocalMountPoints() {
cm_fid_t aFid;
- int i, j, hash;
+ int i, hash;
cm_scache_t *scp, **lscpp, *tscp;
lock_ReleaseMutex(&cm_Freelance_Lock);
printf("----- reinit complete -----\n\n");
+ return 0;
}
FILE *fp;
char line[200];
- int n, i;
+ int i;
char* t;
cm_localMountPoint_t* aLocalMountPoint;
char hdir[120];
return 0;
}
-long cm_FreelanceAddMount(char *filename, char *cellname, char *volume)
+long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, cm_fid_t *fidp)
{
FILE *fp;
char hfile[120];
char line[200];
+ char fullname[200];
int n;
+ /* before adding, verify the cell name; if it is not a valid cell,
+ don't add the mount point */
+ /* 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
+
lock_ObtainMutex(&cm_Freelance_Lock);
cm_GetConfigDir(hfile);
fseek(fp, 0, SEEK_SET);
fprintf(fp, "%d", n);
fseek(fp, 0, SEEK_END);
- fprintf(fp, "%s#%s:%s\n", filename, cellname, volume);
+ fprintf(fp, "%s#%s:%s\n", filename, fullname, volume);
fclose(fp);
lock_ReleaseMutex(&cm_Freelance_Lock);
+ /*cm_reInitLocalMountPoints(&vnode);*/
+ if (fidp) {
+ fidp->unique = 1;
+ fidp->vnode = cm_noLocalMountPoints + 1; /* vnode value of last mt pt */
+ }
cm_noteLocalMountPointChange();
-
+
return 0;
}
long cm_FreelanceRemoveMount(char *toremove)
{
- int i, n, t1, t2;
+ int i, n;
char* cp;
char line[200];
char shortname[200];
char hfile[120], hfile2[120];
FILE *fp1, *fp2;
- char cmd[200];
int found=0;
lock_ObtainMutex(&cm_Freelance_Lock);