[4456] in Athena Bugs

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

/bin/ld error messages

daemon@ATHENA.MIT.EDU (John Carr)
Thu Mar 8 02:18:38 1990

To: bugs@ATHENA.MIT.EDU
Date: Thu, 08 Mar 90 02:18:17 EST
From: John Carr <jfc@ATHENA.MIT.EDU>

This patch makes /bin/ld on the RT print more useful error messages
(e.g. "output write error: Disc quota exceeded" instead of "output
write error").  It also adds a check that closing the output file
succeeded.

[Reference: changes.70 #161]

*** /source/bsd-4.3/rt/bin/ld.c	Fri Jan 27 16:32:34 1989
--- ld.c	Thu Mar  8 02:13:49 1990
***************
*** 35,40 ****
--- 35,41 ----
  
  #include <sys/types.h>
  #include <sys/signal.h>
+ #include <sys/errno.h>
  #include <stdio.h>
  #include <ctype.h>
  #include <ar.h>
***************
*** 42,47 ****
--- 43,50 ----
  #include <ranlib.h>
  #include <sys/stat.h>
  
+ #define errstr(x) ((x) < sys_nerr ? sys_errlist[x] : "unknown error")
+ 
  /* Set maximum clock skew for comparing archive dates.
   * John Kubiatowicz, MIT Project Athena, 09/09/87
   * (Original hack by treese@athena)
***************
*** 821,828 ****
         size = round(stbuf.st_size, BLKSIZE);
         if (!rflag && size > stbuf.st_size) {
                 lseek(biofd, size - 1, 0);
!                write(biofd, &c, 1);
         }
         exit (delarg);
  }
  
--- 824,840 ----
         size = round(stbuf.st_size, BLKSIZE);
         if (!rflag && size > stbuf.st_size) {
                 lseek(biofd, size - 1, 0);
!                if(write(biofd, &c, 1) == -1) {
! 		 fprintf(stderr, "ld: write: %s\n", errstr(errno));
! 		 if(delarg == 0)
! 		   delarg = 1;
! 	       }
         }
+        if(close(biofd) < 0) {
+ 	 fprintf(stderr, "ld: close: %s\n", errstr(errno));
+ 	 if(delarg == 0)
+ 	   delarg = 1;
+        }
         exit (delarg);
  }
  
***************
*** 1594,1601 ****
  setupout()
  {
         int bss;
-        extern char *sys_errlist[];
-        extern int errno;
  
         ofilemode = 0777 & ~umask(0);
         biofd = creat(ofilename, 0666 & ofilemode);
--- 1606,1611 ----
***************
*** 1602,1608 ****
         if (biofd < 0) {
                 filname = ofilename;            /* kludge */
                 archdr.ar_name[0] = 0;          /* kludge */
!                error(1, sys_errlist[errno]);   /* kludge */
         } else {
                 struct stat mybuf;              /* kls kludge */
                 fstat(biofd, &mybuf);           /* suppose file exists, wrong*/
--- 1612,1618 ----
         if (biofd < 0) {
                 filname = ofilename;            /* kludge */
                 archdr.ar_name[0] = 0;          /* kludge */
!                error(1, errstr(errno));		/* kludge */
         } else {
                 struct stat mybuf;              /* kls kludge */
                 fstat(biofd, &mybuf);           /* suppose file exists, wrong*/
***************
*** 2599,2612 ****
  {
  
         if (errlev==0)
!                printf("ld:");
         if (filname) {
!                printf("%s", filname);
                 if (n != -1 && archdr.ar_name[0])
!                        printf("(%s)", archdr.ar_name);
!                printf(": ");
         }
!        printf("%s\n", s);
         if (n == -1)
                 return;
         if (n)
--- 2609,2622 ----
  {
  
         if (errlev==0)
!                fprintf(stderr, "ld:");
         if (filname) {
!                fprintf(stderr, "%s", filname);
                 if (n != -1 && archdr.ar_name[0])
!                        fprintf(stderr, "(%s)", archdr.ar_name);
!                fprintf(stderr, ": ");
         }
!        fprintf(stderr, "%s\n", s);
         if (n == -1)
                 return;
         if (n)
***************
*** 2717,2724 ****
                 if (boffset != bp->b_off)
                         lseek(biofd, bp->b_off, 0);
                 if (write(biofd, p, put) != put) {
!                        bwrerror = 1;
!                        error(1, "output write error");
                 }
                 bp->b_off += put;
                 boffset = bp->b_off;
--- 2727,2736 ----
                 if (boffset != bp->b_off)
                         lseek(biofd, bp->b_off, 0);
                 if (write(biofd, p, put) != put) {
! 			char tmp[128];
! 			sprintf(tmp, "output write error: %s", errstr(errno));
! 			bwrerror = 1;
! 			error(1, tmp);
                 }
                 bp->b_off += put;
                 boffset = bp->b_off;


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