From:	AITGW::"robin@LSL.CO.UK" "Robin Fairbairns"  8-MAR-1992 20:17:41.69
To:	Multiple recipients of list ANU-NEWS <ANU-NEWS@VM1.NoDak.EDU>
CC:	
Subj:	Another little idea re. shortage of disc space

Received: by AITGW.DECnet (utk-mail11 v1.5) ; Sun, 8 Mar 92 20:17:38 EST
Received: from vm1.NoDak.edu by aitgw.ge.com (5.65/GE Gateway 1.4)
	id AA09216; Sun, 8 Mar 92 20:17:31 -0500
Message-Id: <9203090117.AA09216@aitgw.ge.com>
Received: from NDSUVM1.BITNET by VM1.NoDak.EDU (IBM VM SMTP V2R2)
   with BSMTP id 0022; Sun, 08 Mar 92 19:00:29 CST
Received: from NDSUVM1.BITNET by NDSUVM1.BITNET (Mailer R2.07) with BSMTP id
 3550; Sun, 08 Mar 92 18:58:33 CST
Date:         Thu, 5 Mar 1992 10:01:53 GMT
Reply-To: Robin Fairbairns <robin@LSL.CO.UK>
Sender: ANU-NEWS Discussion <ANU-NEWS@VM1.NoDak.EDU>
From: Robin Fairbairns <robin@LSL.CO.UK>
Subject:      Another little idea re. shortage of disc space
To: Multiple recipients of list ANU-NEWS <ANU-NEWS@VM1.NoDak.EDU>
 
I've wittered in this group in the past about how hard life is with no
disc space.  Yesterday, _again_, a runaway job filled up the user's root
disc, this time with a netserver log (unusual!).  The following little
bit of code, which I inserted into my copy of V6.0-3 NEWSRC.C, saved my
bacon for the first time (I invented it after a previous instance of the
same fantasy).
 
The problem is that if there are 0 blocks free on the device that
NEWSRC points to, NEWS happily exits having created a NEWSRC. file of 0
blocks.  Thus one has lost all one's registrations, lists of articles
read, and so on ...  This is a _real_ pain if you read `by thread' (as I
do) and typically don't actually catch up in the biggest news groups
(e.g., comp.os.vms).
 
Now obviously NEWS could detect the writing error, and refuse to exit.
There are two reasons why I didn't do that.  The first was that this
code was written some time ago, when I was still taking my first
tentative steps in this funny language (:').  The second is that
_sometimes_ one has to exit from NEWS regardless (e.g., system manager
is shutting down the system to do something to sort out the disc space
problem...).
 
What the code does is to rename the current NEWSRC. as NEWSRC.OLD, and
then to purge NEWSRC.OLD (effectively) /keep=2.  The code fails if the
merry user has defined NEWSRC to something jolly like
ELEPHANT.HIPPOPOTAMUS, but my users here aren't that sophisticated...
 
I offer the code in the spirit that it works in most cases, not that
it's an ideal solution for immediate inclusion in V6.1 (I _still_
haven't even got round to bringing 6.1\alpha up here, but I'm getting
ever so good at wrestling with alligators :-).
 
========================================================================
 
  rename(n_r_n,n_r_c);          /* rename tmp to newsrc name */
  while (!delete(n_r_n));       /* delete all tmp versions */
/************************************************************************/
/* a new bittlet of code to perform the analogue of rn's .newsrc ->     */
/* .oldnewsrc: rename older newsrc to newsrc.old and purge that         */
/* this does the required thing, but the code isn't yet robust enough   */
/* to post                                                              */
/************************************************************************/
  strcpy(n_r_n,n_r_c);          /* fin with tmp name - copy newsrc name */
  sprintf(inline,"n_r_n is %s",n_r_n);
  err_line(inline);
  if (n_r_n[strlen(n_r_n)-1] == '.')
     strcat(n_r_n,"old");       /* make up `save' version name */
  else
     strcat(n_r_n,".old");
  strcat(n_r_c,";-1");          /* point to next older version */
  rename(n_r_c,n_r_n);          /* rename next older version to .old */
  strcat(n_r_n,";-2");          /* potentially retain two versions of .old */
  while (!delete(n_r_n));       /* purge .old/keep=2 */
  while (!delete(n_r_c));       /* purge newsrc file */
  n_r_c[strlen(n_r_c)-3] = '\0'; /* rename newsrc to version 1 */
  strcpy(n_r_n,n_r_c);          /* finished with all that faffing around -
                                   resume Geoff's code */
/************************************************************************/
/* end of patched bit of code                                           */
/************************************************************************/
  strcat(n_r_n,";1");
  rename(n_r_c,n_r_n);
 
--
Robin Fairbairns, Senior Consultant, postmaster and general dogsbody
Laser-Scan Ltd., Science Park, Milton Rd., Cambridge CB4 4FY, UK
Email: robin@lsl.co.uk  --or--  rf@cl.cam.ac.uk
