From owner-freebsd-current Mon Sep 25 13:21:36 1995 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id NAA20836 for current-outgoing; Mon, 25 Sep 1995 13:21:36 -0700 Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93]) by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id NAA20831 for ; Mon, 25 Sep 1995 13:21:33 -0700 Received: from crevenia.parc.xerox.com ([13.2.116.11]) by alpha.xerox.com with SMTP id <15166(6)>; Mon, 25 Sep 1995 13:20:25 PDT Received: from localhost by crevenia.parc.xerox.com with SMTP id <177475>; Mon, 25 Sep 1995 13:20:20 -0700 X-Mailer: exmh version 1.6.1 5/23/95 To: Terry Lambert cc: current@freebsd.org Subject: Re: kernel versions and config's rm -rf In-reply-to: Your message of "Sun, 24 Sep 95 16:36:16 PDT." <199509242336.QAA04174@phaeton.artisoft.com> Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="===_0_Mon_Sep_25_13:11:00_PDT_1995" Date: Mon, 25 Sep 1995 13:20:17 PDT From: Bill Fenner Message-Id: <95Sep25.132020pdt.177475@crevenia.parc.xerox.com> Sender: owner-current@freebsd.org Precedence: bulk This is a multipart MIME message. --===_0_Mon_Sep_25_13:11:00_PDT_1995 Content-Type: text/plain 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 --===_0_Mon_Sep_25_13:11:00_PDT_1995 Content-Type: text/plain Content-Description: main.c.diff --- 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 #include #include +#include #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; --===_0_Mon_Sep_25_13:11:00_PDT_1995--