Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/distrib/utils/sysinst Added error checking to log and script...
details: https://anonhg.NetBSD.org/src/rev/88593bbef358
branches: trunk
changeset: 480215:88593bbef358
user: jeremy <jeremy%NetBSD.org@localhost>
date: Fri Jan 07 02:02:05 2000 +0000
description:
Added error checking to log and script file creation functions.
Prevents sysinst from coredumping should the root filesystem be accidentally
mounted read-only.
diffstat:
distrib/utils/sysinst/run.c | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diffs (52 lines):
diff -r a682f3046f06 -r 88593bbef358 distrib/utils/sysinst/run.c
--- a/distrib/utils/sysinst/run.c Fri Jan 07 01:49:42 2000 +0000
+++ b/distrib/utils/sysinst/run.c Fri Jan 07 02:02:05 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: run.c,v 1.24 1999/07/14 16:30:58 abs Exp $ */
+/* $NetBSD: run.c,v 1.25 2000/01/07 02:02:05 jeremy Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -117,11 +117,15 @@
fflush(log);
fclose(log);
} else {
- sprintf(log_text[0], "Logging: On");
- logging = 1;
log = fopen("sysinst.log", "a");
- fprintf(log, "Log started at: %s\n", asctime(localtime(&tloc)));
- fflush(log);
+ if (log != NULL) {
+ sprintf(log_text[0], "Logging: On");
+ logging = 1;
+ fprintf(log, "Log started at: %s\n", asctime(localtime(&tloc)));
+ fflush(log);
+ } else {
+ msg_display(MSG_openfail, "log file", strerror(errno));
+ }
}
return(0);
}
@@ -139,12 +143,17 @@
fflush(script);
fclose(script);
} else {
- sprintf(log_text[1], "Scripting: On");
- scripting = 1;
script = fopen("sysinst.sh", "w");
- fprintf(script, "#!/bin/sh\n");
- fprintf(script, "# Script started at: %s\n", asctime(localtime(&tloc)));
- fflush(script);
+ if (script != NULL) {
+ sprintf(log_text[1], "Scripting: On");
+ scripting = 1;
+ fprintf(script, "#!/bin/sh\n");
+ fprintf(script, "# Script started at: %s\n",
+ asctime(localtime(&tloc)));
+ fflush(script);
+ } else {
+ msg_display(MSG_openfail, "script file", strerror(errno));
+ }
}
return(0);
}
Home |
Main Index |
Thread Index |
Old Index