[10358] in Athena Bugs

home help back first fref pref prev next nref lref last post

Re: track - bogus error message

daemon@ATHENA.MIT.EDU (epeisach@Athena.MIT.EDU)
Sat Mar 13 10:41:14 1993

From: epeisach@Athena.MIT.EDU
To: haynes@cats.UCSC.EDU (Jim Haynes)
Cc: bugs@Athena.MIT.EDU
In-Reply-To: Your message of Fri, 12 Mar 93 15:24:08 -0800.
Date: Sat, 13 Mar 93 10:41:03 EST

I can tell your why track bombs out - the memory allocation scheme
sucks. Essentially you allocate space for N filenames, and everytime you
run out, you double it. Sounds good - well the space/filename is 2K. I(
made some changes at one time for the subscription aspect (making the
library file), but never did the other part, the loading up of the stat
file and tracking changes. (The reason was I wanted to compare to srvd's
at separate times, so making two stat files and running diff was
sufficient - or filtering through awk to get rid of less interesting
aspects of the line).

If you do get the other part working, I would be interested in the
changes. (This of course is not currently in our release). This will at
least get you started. If I remember correctly, alot of the code is
redundant - the library generator and subscription code is duplicated...
I actually cheated by using the same string for the filename and the
sort key, applying so stat_cmp would do the right thing.

	Ezra

*** /tmp/,RCSt1a24640	Sat Mar 13 10:37:18 1993
--- track.h	Sat Aug 10 12:11:35 1991
***************
*** 75,82 ****
  } Currentness;
  
  typedef struct statline {
! 	char sortkey[ LINELEN];
! 	char line[ LINELEN];
  } Statline ;
  
  extern Statline *statfilebufs;
--- 75,81 ----
  } Currentness;
  
  typedef struct statline {
! 	char *line;
  } Statline ;
  
  extern Statline *statfilebufs;
*** /tmp/,RCSt1a24650	Sat Mar 13 10:37:37 1993
--- stamp.c	Sat Aug 10 12:31:10 1991
***************
*** 1,6 ****
  /*
!  *	$Source: /afs/athena.mit.edu/astaff/project/opssrc/ezra/track/RCS/stamp.c,v $
!  *	$Header: /afs/athena.mit.edu/astaff/project/opssrc/ezra/track/RCS/stamp.c,v 4.9 91/02/28 11:32:57 epeisach Exp Locker: epeisach $
   *
   *	$Log:	stamp.c,v $
   * Revision 4.9  91/02/28  11:32:57  epeisach
--- 1,6 ----
  /*
!  *	$Source: /var/epeisach/RCS/stamp.c,v $
!  *	$Header: /var/epeisach/RCS/stamp.c,v 4.9 91/02/28 11:32:57 epeisach Exp Locker: epeisach $
   *
   *	$Log:	stamp.c,v $
   * Revision 4.9  91/02/28  11:32:57  epeisach
***************
*** 95,101 ****
   */
  
  #ifndef lint
! static char *rcsid_header_h = "$Header: /afs/athena.mit.edu/astaff/project/opssrc/ezra/track/RCS/stamp.c,v 4.9 91/02/28 11:32:57 epeisach Exp Locker: epeisach $";
  #endif lint
  
  #include "mit-copyright.h"
--- 95,101 ----
   */
  
  #ifndef lint
! static char *rcsid_header_h = "$Header: /var/epeisach/RCS/stamp.c,v 4.9 91/02/28 11:32:57 epeisach Exp Locker: epeisach $";
  #endif lint
  
  #include "mit-copyright.h"
***************
*** 119,125 ****
  	int same_name;
  	unsigned int type;
  	struct stat fromstat, *s;
! 	unsigned size, curr1 = 0, extra = 0;
  
  	if ( cur_line >= maxlines) {
  		maxlines += MAXLINES;
--- 119,125 ----
  	int same_name;
  	unsigned int type;
  	struct stat fromstat, *s;
! 	unsigned size, curr1 = 0, extra = 0, space=0;
  
  	if ( cur_line >= maxlines) {
  		maxlines += MAXLINES;
***************
*** 147,152 ****
--- 147,153 ----
  		break;
  	case S_IFLNK:
  		curr1 = (unsigned int) c->link;
+ 		space = strlen(c->link);
  		break;
  	case S_IFDIR:
  		curr1 = 0;
***************
*** 175,183 ****
  	name = path[ NAME];
  	if ( !*name) name = "/";
  
! 	KEYCPY( statfilebufs[ cur_line].sortkey, name);
! 
  	linebuf = statfilebufs[ cur_line].line;
  
  	/* if this entry's fromfile != cmpfile,
  	 * the subscribing machine needs to know:
--- 176,188 ----
  	name = path[ NAME];
  	if ( !*name) name = "/";
  
! 	statfilebufs[ cur_line].line = malloc(strlen(name) + space + 100);
  	linebuf = statfilebufs[ cur_line].line;
+ 	if(linebuf == NULL) {
+ 		sprintf( errmsg, "malloc failed: %d statfile lines\n",
+ 			cur_line);
+ 		do_panic();
+ 	}
  
  	/* if this entry's fromfile != cmpfile,
  	 * the subscribing machine needs to know:
***************
*** 230,243 ****
  	c->sbuf.st_mode = S_IFLNK;
  }
  
  sort_stat() {
  	int i;
  
- 	/* NOTE: this qsort call assumes that each statfilebufs[] element
- 	 * begins with a sortkey as its first field.
- 	 */
          qsort( (char *) statfilebufs, cur_line,
! 		sizeof( statfilebufs[ 0]), strcmp);
  
          for ( i = 0; i < cur_line; i++) {
                  fputs( statfilebufs[ i].line, statfile);
--- 235,263 ----
  	c->sbuf.st_mode = S_IFLNK;
  }
  
+ int stat_cmp(ain, bin) 
+ char **ain, **bin;
+ {
+ 	char *a, *b, c, d;
+ 	a = *ain;
+ 	b = *bin;
+ 	/* Skip over first character which refers to file type */
+ 	a++; b++;
+ 	while (*a && *b) {
+ 		c = (*a == '/') ? '\001' : *a; a++;
+ 		d = (*b == '/') ? '\001' : *b; b++;
+ 		if (c != d) return (c - d);
+ 	}
+ 	c = (*a == '/') ? '\001' : *a;
+ 	d = (*b == '/') ? '\001' : *b;
+ 	return(c-d);
+ }
+ 
  sort_stat() {
  	int i;
  
          qsort( (char *) statfilebufs, cur_line,
! 		sizeof( statfilebufs[ 0]), stat_cmp);
  
          for ( i = 0; i < cur_line; i++) {
                  fputs( statfilebufs[ i].line, statfile);



home help back first fref pref prev next nref lref last post