Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!bu-cs!budd From: budd@bu-cs.BU.EDU (Philip Budne) Newsgroups: net.sources Subject: file command which identifies core files Message-ID: <3615@bu-cs.BU.EDU> Date: Tue, 20-Jan-87 16:22:34 EST Article-I.D.: bu-cs.3615 Posted: Tue Jan 20 16:22:34 1987 Date-Received: Wed, 21-Jan-87 02:03:51 EST Organization: Boston U. Comp. Sci. Lines: 54 Keywords: file core diff 4.3 Here is a context diff to 4.3 file.c that tries to identify a core file, and type out the name of the command which dumped. The idea comes from SUNos (!) but SUN core files are different (they start with a magic number for one thing). Its less than full graceful, since it re-reads the top of the file, but hey, it works. *** file.c.orig Thu Mar 6 19:34:29 1986 --- file.c Tue Jan 20 12:14:30 1987 *************** *** 6,11 **** --- 6,13 ---- */ #include + #include /* budd for user.h */ + #include /* budd */ #include #include #include *************** *** 288,295 **** for(i=0; i < in; i++)if(buf[i]&0200){ if (buf[0]=='\100' && buf[1]=='\357') printf("troff (CAT) output\n"); ! else ! printf("data\n"); return; } if (mbuf.st_mode&((S_IEXEC)|(S_IEXEC>>3)|(S_IEXEC>>6))) { --- 290,311 ---- for(i=0; i < in; i++)if(buf[i]&0200){ if (buf[0]=='\100' && buf[1]=='\357') printf("troff (CAT) output\n"); ! else { /* budd ... */ ! union { ! struct user us; ! char pad[UPAGES][NBPG]; ! } u_; ! # define u u_.us ! lseek( ifile, 0L, 0); ! if( read(ifile, &u_, sizeof u_ ) == sizeof u_ ) { ! int p = UPAGES + u.u_dsize + u.u_ssize; ! if( p * NBPG == mbuf.st_size ) { ! printf("core from %s\n", u.u_comm ); ! return; ! } ! } ! printf("data\n"); ! } /* ... budd */ return; } if (mbuf.st_mode&((S_IEXEC)|(S_IEXEC>>3)|(S_IEXEC>>6))) {