[2047] in Athena Bugs
ranlib
daemon@ATHENA.MIT.EDU (Ilhamuddin Ahmed)
Thu Apr 6 12:41:43 1989
Date: Thu, 6 Apr 89 12:41:09 EDT
From: Ilhamuddin Ahmed <ilham@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
Cc: mar@ATHENA.MIT.EDU, ilham@ATHENA.MIT.EDU
Reply-To: ilham@ATHENA.MIT.EDU
mar > From: <mar@ATHENA.MIT.EDU>
mar > Date: Tue, 21 Mar 89 12:15:43 EST
mar > To: bugs@ATHENA.MIT.EDU
mar > Subject: ranlib: VS2 6.1B (probably others as well)
mar >
mar > I tried to ranlib a library on a full filesystem, which produced the
mar > following errors:
mar > ranlib libsmsglue.a
mar > ar write error: I/O error
mar > ranlib: ``ar rl libsmsglue.a __.SYMDEF
mar > '' failed
mar > However the make that invoked that kept going, implying that ranlib
mar > exited with a zero status.
mar > -Mark
ranlib can be run on many archives so what it did was continue to the
next archive and finally returned with exit(0). The fix is to keep track
of the exit_flag and return that at the end. The attached fix will exit
with 1 if there was an error in any of the archives (but go though all
the other archives first). It does not set exit_flag to 0 if there was a
warning. in any of the archives.
- Ilhamuddin Ahmed
Project Athena `Watchmaker'
===============================================================================
*** /minos/source/4.3/usr.bin/ranlib.c Mon Aug 1 17:07:51 1988
--- ranlib.c Thu Apr 6 12:30:19 1989
***************
*** 70,75 ****
--- 70,76 ----
register int just_touch = 0;
register struct tabsegment *ptab;
register struct strsegment *pstr;
+ int exit_flag = 0;
/* check for the "-t" flag" */
if (argc > 1 && strcmp(argv[1], "-t") == 0) {
***************
*** 83,88 ****
--- 84,90 ----
fi = fopen(*++argv,"r");
if (fi == NULL) {
fprintf(stderr, "ranlib: cannot open %s\n", *argv);
+ exit_flag = 1;
continue;
}
off = SARMAG;
***************
*** 93,98 ****
--- 95,101 ----
else
fprintf(stderr, "not an ");
fprintf(stderr, "archive: %s\n", *argv);
+ exit_flag = 1;
continue;
}
if (just_touch) {
***************
*** 102,107 ****
--- 105,111 ----
if (fread(cmdbuf, sizeof archdr.ar_name, 1, fi) != 1) {
fprintf(stderr, "malformed archive: %s\n",
*argv);
+ exit_flag = 1;
continue;
}
len = strlen(tempnm);
***************
*** 108,117 ****
if (bcmp(cmdbuf, tempnm, len) != 0 ||
cmdbuf[len] != ' ') {
fprintf(stderr, "no symbol table: %s\n", *argv);
continue;
}
fclose(fi);
! fixdate(*argv);
continue;
}
fseek(fi, 0L, 0);
--- 112,122 ----
if (bcmp(cmdbuf, tempnm, len) != 0 ||
cmdbuf[len] != ' ') {
fprintf(stderr, "no symbol table: %s\n", *argv);
+ exit_flag = 1;
continue;
}
fclose(fi);
! if (fixdate(*argv)) exit_flag = 1;
continue;
}
fseek(fi, 0L, 0);
***************
*** 204,216 ****
sprintf(cmdbuf, "ar rlb %s %s %s\n", firstname, *argv, tempnm);
else
sprintf(cmdbuf, "ar rl %s %s\n", *argv, tempnm);
! if(system(cmdbuf))
fprintf(stderr, "ranlib: ``%s'' failed\n", cmdbuf);
else
! fixdate(*argv);
unlink(tempnm);
}
! exit(0);
}
nextel(af)
--- 209,223 ----
sprintf(cmdbuf, "ar rlb %s %s %s\n", firstname, *argv, tempnm);
else
sprintf(cmdbuf, "ar rl %s %s\n", *argv, tempnm);
! if(system(cmdbuf)) {
fprintf(stderr, "ranlib: ``%s'' failed\n", cmdbuf);
+ exit_flag = 1;
+ }
else
! if (fixdate(*argv)) exit_flag = 1;
unlink(tempnm);
}
! exit(exit_flag);
}
nextel(af)
***************
*** 377,383 ****
fd = open(s, 1);
if(fd < 0) {
fprintf(stderr, "ranlib: can't reopen %s\n", s);
! return;
}
sprintf(buf, "%-*ld", sizeof(archdr.ar_date), time((long *)NULL)+5);
lseek(fd, (long)SARMAG + ((char *)archdr.ar_date-(char *)&archdr), 0);
--- 384,390 ----
fd = open(s, 1);
if(fd < 0) {
fprintf(stderr, "ranlib: can't reopen %s\n", s);
! return (1);
}
sprintf(buf, "%-*ld", sizeof(archdr.ar_date), time((long *)NULL)+5);
lseek(fd, (long)SARMAG + ((char *)archdr.ar_date-(char *)&archdr), 0);
***************
*** 390,396 ****
fd = open(s, O_RDWR); /* Reopen, to reread time stamps */
if(fd < 0) {
fprintf(stderr, "ranlib: can't rereopen %s (%d)\n", s, fd);
! return;
}
lseek(fd, (long)SARMAG + ((char *)archdr.ar_date-(char *)&archdr), 0);
read(fd, buf, sizeof(archdr.ar_date)); /* grab the __.SYMDEF time */
--- 397,403 ----
fd = open(s, O_RDWR); /* Reopen, to reread time stamps */
if(fd < 0) {
fprintf(stderr, "ranlib: can't rereopen %s (%d)\n", s, fd);
! return (1);
}
lseek(fd, (long)SARMAG + ((char *)archdr.ar_date-(char *)&archdr), 0);
read(fd, buf, sizeof(archdr.ar_date)); /* grab the __.SYMDEF time */
***************
*** 412,415 ****
--- 419,423 ----
* unlikely.
*/
close(fd);
+ return(0);
}