Date: Mon, 25 Sep 1995 13:20:17 PDT From: Bill Fenner <fenner@parc.xerox.com> To: Terry Lambert <terry@lambert.org> Cc: current@freebsd.org Subject: Re: kernel versions and config's rm -rf Message-ID: <95Sep25.132020pdt.177475@crevenia.parc.xerox.com> In-Reply-To: Your message of "Sun, 24 Sep 95 16:36:16 PDT." <199509242336.QAA04174@phaeton.artisoft.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
In message <199509242336.QAA04174@phaeton.artisoft.com> you write:
>> The other solution that I was considering was reading the number out of
>> the "version" file before the "rm -rf" and then writing it out again
>> afterwards.
>
>Yes, please.
Ok, new patch enclosed.
Bill
[-- Attachment #2 --]
--- usr.sbin/config/main.c.orig Sun Sep 24 12:53:43 1995
+++ usr.sbin/config/main.c Mon Sep 25 13:13:04 1995
@@ -46,6 +46,7 @@
#include <sys/file.h>
#include <stdio.h>
#include <ctype.h>
+#include <errno.h>
#include "y.tab.h"
#include "config.h"
@@ -117,10 +118,22 @@
exit(2);
}
else if (!no_config_clobber) {
- char tmp[strlen(p) + 8];
+ char tmp[strlen(p) + 9];
+ FILE *v;
+ int oversion = 0;
fprintf(stderr, "Removing old directory %s: ", p);
fflush(stderr);
+ sprintf(tmp, "%s/version", p);
+ if ((v = fopen(tmp, "r")) == NULL) {
+ if (errno != ENOENT) {
+ fprintf(stderr, "...couldn't read version\n");
+ perror(tmp);
+ }
+ } else {
+ fscanf(v, "%d", &oversion);
+ fclose(v);
+ }
sprintf(tmp, "rm -rf %s", p);
if (system(tmp)) {
fprintf(stderr, "Failed!\n");
@@ -131,6 +144,16 @@
if (mkdir(p, 0777)) {
perror(p);
exit(2);
+ }
+ sprintf(tmp, "%s/version", p);
+ if (oversion != 0) {
+ if ((v = fopen(tmp, "w")) == NULL) {
+ fprintf(stderr, "Couldn't restore kernel version!\n");
+ perror(tmp);
+ } else {
+ fprintf(v, "%d\n", oversion);
+ fclose(v);
+ }
}
}
loadaddress = -1;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?95Sep25.132020pdt.177475>
