[comp.protocols.appletalk] CAP Bug reports #0010, #0011

cck@CUNIXC.COLUMBIA.EDU.UUCP (10/30/87)

Two more bug reports.  The first is fairly low priority.  The second
is of medium impact.

Charlie C. Kim
User Services
Columbia University


*******************************************************************************
CAP Pre-Release Distribution 4.00 with Patches 5,6,7
Bug Report: 0010

 Date: Oct 1, 1987
 Problem: Volume space usage data is wrong for the first 3 seconds or so after
          a volume is mounted.  Only affects "System" volumes.
 Reported by: Rob Cartolano
 Priority: Low
 Diagnosis: Systems volumes are scanned by server on startup.  This includes
            getting disk space info, etc.  This may well change between
	    Aufs startup and the time the "child" forks off.  In fact, the
	    latency here may be days!
 Solution: The fix is to make openvol get the volume information
           again.  Here's the fix along with some cleanup.
%%%START OF PATCH%%%
*** /tmp/,RCSt1019604	Tue Oct 13 09:11:08 1987
--- afpvols.c	Wed Oct  7 14:09:59 1987
***************
*** 1,7
  /*
!  * $Author: cck $ $Date: 87/09/06 16:52:26 $
!  * $Header: afpvols.c,v 1.17 87/09/06 16:52:26 cck Exp $
!  * $Revision: 1.17 $
  */
  
  /*

--- 1,7 -----
  /*
!  * $Author: cck $ $Date: 87/10/07 14:09:44 $
!  * $Header: afpvols.c,v 1.18 87/10/07 14:09:44 cck Exp $
!  * $Revision: 1.18 $
  */
  
  /*
***************
*** 351,356
    OpenVolPkt ovl;
    char pwd[MAXPASSWD+1];		/* null terminated password */
    int v;
    
    ovl.ovl_pass[0] = '\0';		/* zero optional password */
    ntohPackX(PsOpenVol,p,l,(byte *) &ovl); /* decode packet */

--- 351,358 -----
    OpenVolPkt ovl;
    char pwd[MAXPASSWD+1];		/* null terminated password */
    int v;
+   OSErr err;
+   VolPtr vp;
    
    ovl.ovl_pass[0] = '\0';		/* zero optional password */
    ntohPackX(PsOpenVol,p,l,(byte *) &ovl); /* decode packet */
***************
*** 368,375
    if (v >= VolCnt)			/* did we find a vol in the scan? */
      return(aeParamErr);			/* no... unknown volume name */
  
!   if (*VolTbl[v]->v_pwd != '\0') 	/* password exists on volume? */
!     if (strcmp(VolTbl[v]->v_pwd,pwd) != 0) /* yes, check for match */
        return(aeAccessDenied);		/* not the same... return failure */
  
    if (DBVOL)

--- 370,378 -----
    if (v >= VolCnt)			/* did we find a vol in the scan? */
      return(aeParamErr);			/* no... unknown volume name */
  
!   vp = VolTbl[v];			/* dereference */
!   if (*vp->v_pwd != '\0') 	/* password exists on volume? */
!     if (strcmp(vp->v_pwd,pwd) != 0) /* yes, check for match */
        return(aeAccessDenied);		/* not the same... return failure */
  
    if (DBVOL)
***************
*** 373,380
        return(aeAccessDenied);		/* not the same... return failure */
  
    if (DBVOL)
!     printf("FPOpenVol: name=%s volid=%d\n",
! 	   VolTbl[v]->v_name,VolTbl[v]->v_volid);
  
    VolTbl[v]->v_mounted = TRUE;		/* now it is opened... */
    

--- 376,382 -----
        return(aeAccessDenied);		/* not the same... return failure */
  
    if (DBVOL)
!     printf("FPOpenVol: name=%s volid=%d\n", vp->v_name,vp->v_volid);
  
    vp->v_mounted = TRUE;		/* now it is opened... */
    
***************
*** 376,382
      printf("FPOpenVol: name=%s volid=%d\n",
  	   VolTbl[v]->v_name,VolTbl[v]->v_volid);
  
!   VolTbl[v]->v_mounted = TRUE;		/* now it is opened... */
    
    VolTbl[v]->v_bitmap = ovl.ovl_bitmap;	/* bitmap for packing result */
  

--- 378,384 -----
    if (DBVOL)
      printf("FPOpenVol: name=%s volid=%d\n", vp->v_name,vp->v_volid);
  
!   vp->v_mounted = TRUE;		/* now it is opened... */
    
    /* update volume info */
    if ((err = OSVolInfo(vp->v_path,vp,VP_ALL)) != noErr)
***************
*** 378,384
  
    VolTbl[v]->v_mounted = TRUE;		/* now it is opened... */
    
!   VolTbl[v]->v_bitmap = ovl.ovl_bitmap;	/* bitmap for packing result */
  
    *rl = htonPackX(VolPackR,(byte *) VolTbl[v],r);
    return(noErr);			/* return ok */

--- 380,388 -----
  
    vp->v_mounted = TRUE;		/* now it is opened... */
    
!   /* update volume info */
!   if ((err = OSVolInfo(vp->v_path,vp,VP_ALL)) != noErr)
!     return(err);
  
    vp->v_bitmap = ovl.ovl_bitmap;	/* bitmap for packing result */
  
***************
*** 380,386
    
    VolTbl[v]->v_bitmap = ovl.ovl_bitmap;	/* bitmap for packing result */
  
!   *rl = htonPackX(VolPackR,(byte *) VolTbl[v],r);
    return(noErr);			/* return ok */
  }
  

--- 384,392 -----
    if ((err = OSVolInfo(vp->v_path,vp,VP_ALL)) != noErr)
      return(err);
  
!   vp->v_bitmap = ovl.ovl_bitmap;	/* bitmap for packing result */
! 
!   *rl = htonPackX(VolPackR,(byte *) vp,r);
    return(noErr);			/* return ok */
  }
  

%%%END OF PATCH%%%

*******************************************************************************
CAP Pre-Release Distribution 4.00 with Patches 5,6,7
Bug Report: 0011

 Date: Oct 21, 1987
 Problem: "Change Priviledges" changes the protection of the data
files, the .finderinfo file for the directory, and the protections on
the directory and its .finderinfo and .resource directories, but not
the finderinfo and resource files.  This is a problem!
 Reported by: Rob Cartolano, User Services, Columbia U.
 Priority: Medium
 Diagnosis: Awk!  I messed up Bill's code (or it was never right in the
first place :-)
 Solution:  Apply the following patch:
%%% START OF PATCH %%%
*** /tmp/,RCSt1004901	Wed Oct 21 14:06:27 1987
--- afpos.c	Wed Oct 21 14:05:18 1987
***************
*** 122,127
  private OSErr unix_chown(),unix_chmod(),unix_stat();
  private OSErr ItoEErr();
  
  /*
   * OwnerID = 0 means that the folder is "unowned" or owned by
   * <any user>.  The owner bit of the User Rights summary is always 

--- 122,129 -----
  private OSErr unix_chown(),unix_chmod(),unix_stat();
  private OSErr ItoEErr();
  
+ private void os_chmod_all();
+ 
  /*
   * OwnerID = 0 means that the folder is "unowned" or owned by
   * <any user>.  The owner bit of the User Rights summary is always 
***************
*** 1184,1189
  
      if ((err = os_chmod(ipdir,fn,acc,F_DATA)) != noErr)
        return(err);
      if ((err = os_chmod(ipdir,fn,acc,F_RSRC)) != noErr &&
  	err != aeObjectNotFound)
        return(err);

--- 1186,1194 -----
  
      if ((err = os_chmod(ipdir,fn,acc,F_DATA)) != noErr)
        return(err);
+     os_chmod_all(ipdir, fn, acc, F_DATA); /* change all file protections */
+     os_chmod_all(ipdir, fn, acc, F_RSRC);
+     os_chmod_all(ipdir, fn, acc, F_FNDR);
      if ((err = os_chmod(ipdir,fn,acc,F_RSRC)) != noErr &&
  	err != aeObjectNotFound)
        return(err);
***************
*** 1224,1232
   * Directory id (idir), and type (typ) specify a directory name.
   * Internal access bits are mode.
   *
!  * Change the protection of the directory to eacc.  Also since
!  * unix has file protection and AFP does not, change the protection
!  * of each file in the directory as well.
   *
   * Do not change the protection of directories contained within
   * the directory... 

--- 1229,1235 -----
   * Directory id (idir), and type (typ) specify a directory name.
   * Internal access bits are mode.
   *
!  * Change the protection of the directory to eacc.  
   *
   */
  private OSErr
***************
*** 1228,1236
   * unix has file protection and AFP does not, change the protection
   * of each file in the directory as well.
   *
-  * Do not change the protection of directories contained within
-  * the directory... 
-  *
   */
  private OSErr
  os_chmod(idir,fn,mode,typ)

--- 1231,1236 -----
   *
   * Change the protection of the directory to eacc.  
   *
   */
  private OSErr
  os_chmod(idir,fn,mode,typ)
***************
*** 1240,1250
  int typ;
  {
    char path[MAXPATHLEN];
!   struct timeval ut[2];
!   struct stat stb;
!   struct direct *dp;
!   DIR *dirp;
!   int pl,err;
  
    OSfname(path,idir,fn,typ);		/* convert unix name */
    if (DBOSI)

--- 1240,1246 -----
  int typ;
  {
    char path[MAXPATHLEN];
!   int err;
  
    OSfname(path,idir,fn,typ);		/* convert unix name */
    if (DBOSI)
***************
*** 1254,1266
    if (err != noErr)
      return(err);
  
- #ifdef notdef
-   time(&ut[0]);			/* set mod time for dir */
-   ut[1] = ut[0];
-   if (utimes(path,&ut[0]) != 0)
-     if (DBOSI)
-       printf("os_chmod: utimes failed %s\n",syserr());
- #endif
    EModified(idir);
  
    dirp = opendir(path);

--- 1250,1255 -----
    if (err != noErr)
      return(err);
  
    EModified(idir);
    return(noErr);
  }
***************
*** 1262,1267
        printf("os_chmod: utimes failed %s\n",syserr());
  #endif
    EModified(idir);
  
    dirp = opendir(path);
    if (dirp == NULL) {

--- 1251,1258 -----
      return(err);
  
    EModified(idir);
+   return(noErr);
+ }
  
  /*
   * Change file protection for all files in directory
***************
*** 1263,1268
  #endif
    EModified(idir);
  
    dirp = opendir(path);
    if (dirp == NULL) {
      if (DBOSI)

--- 1254,1300 -----
    return(noErr);
  }
  
+ /*
+  * Change file protection for all files in directory
+  *
+  * Have to do because:
+  * unix has file protection and AFP does not, change the protection
+  * of each file in the directory as well.
+  *
+  * Do not change the protection of directories contained within
+  * the directory... 
+  *
+ */
+ private void
+ os_chmod_all(idir,fn,mode,typ)
+ IDirP idir;
+ char *fn;
+ u_short mode;
+ int typ;
+ {
+   char path[MAXPATHLEN];
+   struct stat stb;
+   struct direct *dp;
+   DIR *dirp;
+   int pl,err;
+ 
+   OSfname(path,idir,fn,F_DATA);		/* convert unix name */
+   pl = strlen(path);
+   switch (typ) {
+   case F_DATA:
+     break;
+   case F_RSRC:
+     path[pl] = '/';
+     strcpy(path+pl+1, RFDIRFN);
+     break;
+   case F_FNDR:
+     path[pl] = '/';
+     strcpy(path+pl+1, FIDIRFN);
+     break;
+   }
+   if (DBOSI)
+     printf("os_chmod: setting %o for %s\n",mode,path);
+ 
    dirp = opendir(path);
    if (dirp == NULL) {
      if (DBOSI)
***************
*** 1267,1273
    if (dirp == NULL) {
      if (DBOSI)
        printf("os_chmod: opendir failed on %s\n",path);
!     return(aeObjectNotFound);		/* screwy */
    }
  
    pl = strlen(path);			/* length of the path */

--- 1299,1305 -----
    if (dirp == NULL) {
      if (DBOSI)
        printf("os_chmod: opendir failed on %s\n",path);
!     return;
    }
  
    pl = strlen(path);			/* length of the path */
***************
*** 1283,1289
        if (dp->d_name[0] != '.')
  	continue;
        /* if not .resource or .finderinfo then skip */
!       if (strcmp(dp->d_name,RFDIRFN) != 0 && strcmp(dp->d_name, FIDIRFN) != 0)
  	continue;
      }
      err = unix_chmod(path,mode);	/* set the mode for this file */

--- 1315,1322 -----
        if (dp->d_name[0] != '.')
  	continue;
        /* if not .resource or .finderinfo then skip */
!       if (typ != F_DATA &&
! 	  strcmp(dp->d_name,RFDIRFN) != 0 && strcmp(dp->d_name, FIDIRFN) != 0)
  	continue;
      }
      err = unix_chmod(path,mode);	/* set the mode for this file */
***************
*** 1287,1293
  	continue;
      }
      err = unix_chmod(path,mode);	/* set the mode for this file */
- #ifdef notdef
      /* ignore errors */
      if (err != noErr)			/*  and if error, then stop */
        break;

--- 1320,1325 -----
  	continue;
      }
      err = unix_chmod(path,mode);	/* set the mode for this file */
      /* ignore errors */
    }
    closedir(dirp);			/* close the directory */
***************
*** 1289,1297
      err = unix_chmod(path,mode);	/* set the mode for this file */
  #ifdef notdef
      /* ignore errors */
-     if (err != noErr)			/*  and if error, then stop */
-       break;
- #endif
    }
    closedir(dirp);			/* close the directory */
    return(err);				/* return the last error */

--- 1321,1326 -----
      }
      err = unix_chmod(path,mode);	/* set the mode for this file */
      /* ignore errors */
    }
    closedir(dirp);			/* close the directory */
  }
***************
*** 1294,1300
  #endif
    }
    closedir(dirp);			/* close the directory */
-   return(err);				/* return the last error */
  }
  
  

--- 1323,1328 -----
      /* ignore errors */
    }
    closedir(dirp);			/* close the directory */
  }
  
  
%%% END OF PATCH %%%
*******************************************************************************