more-must-returns-20031207
[openafs.git] / src / WINNT / afsd / cm_freelance.c
index 6ae0889..62ec62e 100644 (file)
@@ -18,6 +18,8 @@
 #include "cm_freelance.h"
 #include "stdio.h"
 
+extern void afsi_log(char *pattern, ...);
+
 int cm_noLocalMountPoints;
 int cm_fakeDirSize;
 int cm_fakeDirCallback=0;
@@ -49,11 +51,9 @@ void cm_InitFreelance() {
 /* 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;
@@ -82,7 +82,9 @@ void cm_InitFakeRootDir() {
        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);
@@ -90,7 +92,7 @@ void cm_InitFakeRootDir() {
                        (curDirEntryInPage + 1 >= CM_DIR_EPP)) {
                        curPage++;
                        curDirEntryInPage = 0;
-                       curChunk = 0;
+                       curChunk = 1;
                }
                curChunk += sizeOfCurEntry;
                curDirEntry++;
@@ -227,10 +229,11 @@ void cm_InitFakeRootDir() {
 
 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() {
@@ -239,6 +242,7 @@ int cm_getLocalMountPointChange() {
 
 int cm_clearLocalMountPointChange() {
   cm_localMountPointChangeFlag = 0;
+  return 0;
 }
 
 /* called directly from ioctl */
@@ -253,7 +257,7 @@ int cm_noteLocalMountPointChange() {
 
 int cm_reInitLocalMountPoints() {
        cm_fid_t aFid;
-       int i, j, hash;
+       int i, hash;
        cm_scache_t *scp, **lscpp, *tscp;
 
        
@@ -330,6 +334,7 @@ int cm_reInitLocalMountPoints() {
        lock_ReleaseMutex(&cm_Freelance_Lock);
 
        printf("----- reinit complete -----\n\n");
+       return 0;
 }
 
 
@@ -341,7 +346,7 @@ long cm_InitLocalMountPoints() {
        
        FILE *fp;
        char line[200];
-       int n, i;
+       int i;
        char* t;
        cm_localMountPoint_t* aLocalMountPoint;
        char hdir[120];
@@ -435,13 +440,24 @@ cm_localMountPoint_t* cm_getLocalMountPoint(int vnode) {
        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);
@@ -455,24 +471,28 @@ long cm_FreelanceAddMount(char *filename, char *cellname, char *volume)
      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);