validate_prefix_locations

Add the actual value of the prefix, and the error returned by the system
to the paniclog file entry.
This commit is contained in:
nethack.allison
2002-07-05 14:42:49 +00:00
parent fff14e7eed
commit 895199a83b

View File

@@ -167,9 +167,8 @@ char *reasonbuf;
FILE *fp; FILE *fp;
const char *filename; const char *filename;
int prefcnt, failcount = 0; int prefcnt, failcount = 0;
char failbuf[BUFSZ]; char panicbuf1[BUFSZ], panicbuf2[BUFSZ];
failbuf[0] = '\0';
if (reasonbuf) reasonbuf[0] = '\0'; if (reasonbuf) reasonbuf[0] = '\0';
for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) { for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) {
/* don't test writing to configdir or datadir; they're readonly */ /* don't test writing to configdir or datadir; they're readonly */
@@ -179,20 +178,20 @@ char *reasonbuf;
fclose(fp); fclose(fp);
(void) unlink(filename); (void) unlink(filename);
} else { } else {
if (failcount) { if (reasonbuf) {
Strcat(failbuf,", "); if (failcount) Strcat(reasonbuf,", ");
if (reasonbuf) Strcat(reasonbuf,", "); Strcat(reasonbuf, fqn_prefix_names[prefcnt]);
} }
/* the paniclog entry gets the value of errno */ /* the paniclog entry gets the value of errno as well */
Sprintf(eos(failbuf), "%s:%d", fqn_prefix_names[prefcnt], errno); Sprintf(panicbuf1,"Invalid %s", fqn_prefix_names[prefcnt]);
if (reasonbuf) Strcat(reasonbuf, fqn_prefix_names[prefcnt]); Sprintf(panicbuf2,"\"%s\" (errno=%d)", fqn_prefix[prefcnt], errno);
paniclog(panicbuf1, panicbuf2);
failcount++; failcount++;
} }
} }
if (failcount) { if (failcount)
paniclog("Invalid locations", failbuf);
return 0; return 0;
} else
#endif #endif
return 1; return 1;
} }