Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!pyrnj!pyrdc!uunet!munnari!otc!metro!ipso!runx!brucee From: brucee@runx.ips.oz (Bruce Evans) Newsgroups: comp.os.minix Subject: Re: Useful new program and 1.3 checksums Message-ID: <1793@runx.ips.oz> Date: 16 Oct 88 02:41:17 GMT References: <1443@ast.cs.vu.nl> <430@gonzo.UUCP> <147@nlgvax.UUCP> <1461@ast.cs.vu.nl> Reply-To: brucee@runx.OZ (Bruce Evans) Organization: RUNX Un*x Timeshare. Sydney, Australia. Lines: 144 Andy Tanenbaum writes: >In article <147@nlgvax.UUCP> johan@nlgvax.UUCP (Johan Stevenson) writes: >>The big question is: can we standardize on either crc(1) or inodes(1)? >I think we should use crc. What I want to be able to do is go to a >directory on one machine and type: > crc * >and then do it on another machine, and then run diff on the two files. Except you don't want want to go to _every_ directory one by one. There are about 30 in 1.3c, and the crc list posted show what happens when it is done by hand: some get omitted. We also need fairly complete pathnames to give diff enough context, e.g. ./minix/lib/* or ./lib/* or lib/*, and this fails due to the exec limit. No doubt it works on a Sun. Wouldn't Minix be better off if all development and maintenance were forced on it? My solution was to make a small modification to crc so I could say cd /user; find include src -type f -print | sort | crc > my_crclist to get a canonical output, i.e., crc now reads filenames from stdin if no arguments are given, and works as before with arguments. In future, the argument '-' should probably mean stdin. Lots of other commands would benefit from this interface but the old ones are probably stuck in the mud. I am keeping 1.3c in /user and local changes in /usr but such absolute names are undesirable in the crc list. I had to edit and sort the master crc list to match. There were fancy headers :-(. The find strips out directories with "-type f", since directories usually contain junk relating to deleted files which makes their crc's useless. Executable files should be ignored too since they depend on local things like library order and stack sizes. There does not seem to be an option in find to do this. I think the source directories should be cleaned up so they contain no executable files anyway. The main offenders are test and tools. I have begun moving files from them to /etc and /etc/system. Find will also expose rubbish in the master directories. Like treecmp. Previously I posted something in favour of inodes (make it this crc with file permissions as well) but needed a simpler solution to handle the current crc list. Actually the inodes output could be readily converted to the crc output with a filter to extract the fields (in C or maybe sed; we don't have awk and sh is too slow). Given this, the official crc list could contain lots of other fields. It would be nice to duplicate the original time stamps. The current inodes is far too slow on large lists. It is probably just searching for links. Minor changes to crc follow. I cleaned it up a bit too. The cdiff was done with -c1 to give only 1 line of context. I think this is the best compromise between ambiguous diffs and large cdiffs produced with -c3. *** /user/sys/commands/crc.c Wed Oct 5 22:40:20 1988 --- crc.c Sat Oct 15 00:24:39 1988 *************** *** 2,7 **** ! ! #include ! ! int errs; --- 2,8 ---- ! #include ! #include ! ! int errs; ! char line[256]; *************** *** 12,20 **** if (argc <= 1) ! crc((char *)0); ! else ! do { ! if (freopen(argv[1], "r", stdin) == NULL) ! error("cannot open %s", argv[1]); ! else ! crc(argv[1]); argv++; --- 13,23 ---- if (argc <= 1) ! while (fgets(line, sizeof line, stdin) != NULL) ! { ! if (index(line, '\n') != NULL) ! *index(line, '\n') = 0; ! crc(line); ! } ! else ! do { ! crc(argv[1]); argv++; *************** *** 78,81 **** { ! register int c; ! register int i; register long len = 0; --- 81,84 ---- { ! register FILE *fp; ! register int c; register long len = 0; *************** *** 83,85 **** ! while ((c = getc(stdin)) != EOF) { len++; --- 86,92 ---- ! if ((fp = fopen(fname, "r")) == NULL) { ! fprintf(stderr, "crc: cannot open %s\n", fname); ! errs++; ! } ! while ((c = getc(fp)) != EOF) { len++; *************** *** 87,102 **** } ! printf("%05u %6ld", crc, len, fname); ! if (fname) ! printf(" %s", fname); ! printf("\n"); ! } ! ! error(s, a1, a2, a3, a4) ! char *s; ! { ! ! fprintf(stderr, "crc: "); ! fprintf(stderr, s, a1, a2, a3, a4); ! fprintf(stderr, "\n"); ! errs++; ! } --- 94,97 ---- } ! fclose(fp); ! printf("%05u %6ld %s\n", crc, len, fname); ! } Bruce Evans Internet: brucee@runx.ips.oz.au UUCP: uunet!runx.ips.oz.au!brucee