[comp.os.minix] Little patch for file.c

card@masi.ibp.fr (Remy CARD) (09/10/90)

   Hi,

   I currently use Minix 1.5.10 with Bruce Evans' 32 bits kernel.

   I have modified file.c to print if an executable file is in 16
or 32 bits mode. This allows one to distinct 16 and 32 bits programs.

   This patch is relative to the patch posted here to avoid core dump
when file reads an empty file.

---------------------------- CUT HERE -------------------------------
*** file.c.old	Mon Sep 10 07:49:36 1990
--- file.c	Mon Sep 10 07:46:40 1990
***************
*** 15,20 ****
--- 15,22 ----
  #else
  #define A_OUT 001401		/* magic number for executables */
  #define SPLIT 002040		/* second word on split I/D binaries */
+ #define A_I8086 0x04		/* 8086 cpu id */
+ #define A_I80386 0x10		/* 80386 cpu id */
  #endif
  #define XBITS 00111		/* rwXrwXrwX (x bits in the mode) */
  #define ENGLISH 25		/* cutoff for determining if text is Eng. */
***************
*** 41,46 ****
--- 43,49 ----
    int symbols;
    long engpct;
    char c;
+   int cpuid;
    struct stat st_buf;
  
    printf("%s: ", name);
***************
*** 111,118 ****
    /* Check to see if file is an executable binary. */
  #if (CHIP != M68000)
    if (magic == A_OUT) {
! 	/* File is executable.  Check for split I/D. */
! 	printf("MINIX/PC executable");
  	second = (buf[3] << 8) | (buf[2] & 0377);
  	if (second == SPLIT)
  		printf("   separate I & D space");
--- 114,134 ----
    /* Check to see if file is an executable binary. */
  #if (CHIP != M68000)
    if (magic == A_OUT) {
! 	/* File is executable.  Check pour CPU Id */
! 	cpuid = (int) buf[3];
! 	switch (cpuid)
! 	{
! 		case A_I8086:
! 			printf ("16 bits ");
! 			break;
! 		case A_I80386:
! 			printf ("32 bits ");
! 			break;
! 		default:
! 			break;
! 	}
! 	printf("MINIX/PC executable");
! 	/* Check for split I/D. */
  	second = (buf[3] << 8) | (buf[2] & 0377);
  	if (second == SPLIT)
  		printf("   separate I & D space");
---------------------------- END OF PATCH ------------------------------

+-----------------------------------o--------------------------------------+
| Remy CARD                         | E-mail : card@masi.ibp.fr            |
| Universite Pierre et Marie Curie  |                                      |
| Laboratoire MASI, CNRS UA 818     |                                      |
| 4 Place Jussieu                   | Tel : +33 (1) 44.27.43.63            |
| F-75252 PARIS CEDEX 05            | Fax : +33 (1) 46.34.19.27            |
| FRANCE                            | Telex : UPMCSIX 200-145 F            |
+-----------------------------------o--------------------------------------+