[gnu.emacs.help] Patch for VMS emacs.

youngdale@V6550C.NRL.NAVY.MIL (Eric Youngdale) (03/16/91)

	A problem has been discovered with Emacs running on VMS which has to do
with the way that Emacs writes back the file with the C-x C-s command.  The
problem is that Emacs will overwrite the old file if it is unable to create a
new one (if the directory protection is not set to allow write for example).
This can be made worse if the owner of the file is over their disk quota,
in which case Emacs will truncate the file and then be unable to write it back.

	I have made a patch that I would like people to try, which will disable
Emacs's ability to overwrite the old file.  Emacs will still be able to write
new files, of course. This patch is in a VMS specific section of code, so
non-VMS users do not need to bother trying this.

	I am concerned that there may be unforseen side effects to disabling
this, and this is the reason that I am asking people to try this.  This patch
was made for Emacs version 18.57, although I think that it will also work for
18.55.

	If there are no unforseen side effects, these changes will be
incorporated into Emacs in a later release.

------------------------------------------------------------------
Eric Youngdale          INTERNET:  YOUNGDALE@V6550C.NRL.NAVY.MIL
Naval Research Lab     	    SPAN:  11.13 (or 11277::)
Washington, DC	       FLAME-NET:  NLA0:
	Disclaimer:  The opinions expressed herein are my own and not
necessarily those of my employer.


*** fileio.c-orig
--- fileio.c
**************
*** 1710,1715
  		fn = fname;
  		fname = 0;
  		desc = creat (fn, 0666);
  		if (desc < 0)
  		  {
  		    /* We can't make a new version;
--- 1711,1722 -----
  		fn = fname;
  		fname = 0;
  		desc = creat (fn, 0666);
+ #if 0
+  /* this code is a baaaad idea.  If we cannot write a new file, there is
+   * usually a good reason (i.e. protections of some sort).  This can fail
+   * rather dramatically if the user running emacs is over his/her disk quota.
+   * The user can be left with a zero-length file (thus losing both the original
+   * file *and* the modified one. */
  		if (desc < 0)
  		  {
  		    /* We can't make a new version;
**************
*** 1717,1722
  		    vms_truncate (fn);
  		    desc = open (fn, O_RDWR);
  		  }
  	      }
  	  }
  	else
--- 1724,1730 -----
  		    vms_truncate (fn);
  		    desc = open (fn, O_RDWR);
  		  }
+ #endif
  	      }
  	  }
  	else

glover@CIS.OHIO-STATE.EDU (glover) (03/18/91)

mark