[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2095.0. "partial writes?" by CSC32::J_HENSON (Don't get even, get ahead!) Tue Feb 18 1997 14:09

dec c, ovms v6.1, vax

I have a somewhat unusual question, and am not sure that it's even a
c issue.  I will post a similar question in the rms notes conference.

A customer's concern is that either all of a record/write will be
written to disk, or none of it will.  She wants to be able to
deal with disk full errors in a consistent way.

According to her (I haven't verified), if she uses fopen without
specifying any rms options (in other words, creates a stream_lf file),
and attempts to write 2k bytes when there is only room on the disk
for 1k, the write fails but 1k of the write is written to the file.

She further claims that her testing is showing that if she opens
using fopen(..."rfm=var","ctx=bin"), and encounters the same
situation, the write (fwrite) still fails, but that none of the
data is written to the file.  This is the behavior she wants, but
she is not sure that she can depend on this behavior and wants us
to verify that this is indeed the way it's supposed to work.

In all my years of programming on VMS systems, I've never ran into
this situation, nor had anyone ask me this, so I'm not sure what to
tell her.  I can't find anything in either the C RTL documentation
or the RMS documentation that addresses this, so I thought I had
better ask.

Thanks,

Jerry
T.RTitleUserPersonal
Name
DateLines
2095.1Is disk-full the only interesting error?WIBBIN::NOYCEPulling weeds, pickin' stonesTue Feb 18 1997 14:436
You should also look at the hardware documentation for the
disk drive(s) she will be using.  Some disks guarantee to
complete the current 512-byte block if something goes wrong
(such as a power failure), while others don't.  I doubt if
any disks we support provide such a guarantee for larger
chunks.
2095.2DECCXX::WIBECANThat's the way it is, in Engineering!Tue Feb 18 1997 14:484
I don't see anything obvious in the documentation, myself.  I'll ask one of the
RTL folks to respond.

						Brian
2095.3could not reproduce the problemTAVENG::BORISBoris Gubenko, ISETue Feb 18 1997 16:4855
  I was not able to reproduce the problem. The cluster size of the device
  is 4, so in the example below I tried to write 5 blocks when only 4 blocks
  were available.

  I'm not sure, that fwrite() must fail if there is no room on the device
  because on [f]write() the data usually are copied to the internal CRTL
  buffer which is big enough to hold a number of 512-byte blocks. What fails
  is fflush(), fsync() or fclose() when an attempt is made to transfer the data
  from the buffer to the file.

  Boris

$ say f$getsy("version")
V6.1    
$ say f$getsy("hw_name")
VAXstation 4000-VLC
$ show dev sys$disk

Device                  Device           Error    Volume         Free  Trans Mnt
 Name                   Status           Count     Label        Blocks Count Cnt
$1$DKB106:    (xxxxxx)  Mounted              0  xxxxxxx              4     5  30
$ run x
fsync: no space left on device

$ dir junk.out

Directory DISK:[DIRECTORY]

JUNK.OUT;14                0/0        18-FEB-1997 23:12:23.72  (RWED,RWED,RWED,)

Total of 1 file, 0/0 blocks.

X.C
===
#include <stdio.h>
#include <stdlib.h>

main()
{
  FILE *fp;
  char buf[512*5];

  if ( (fp = fopen("junk.out","w")) == NULL ) {
    perror("fopen");
    exit(EXIT_FAILURE);
  }

  if ( fwrite(buf,sizeof(buf),1,fp) != 1 )
    perror("fwrite");
  else if ( fsync(fileno(fp)) )
    perror("fsync");

  exit(EXIT_SUCCESS);
}
2095.4Use Direct RMS, Use RMS Journaling...XDELTA::HOFFMANSteve, OpenVMS EngineeringWed Feb 19 1997 12:0416
   If the customer is worried about this stuff, I'd look at a combination
   of direct RMS calls and RMS Journaling -- with direct use of RMS, one
   has much better control over file allocation and file extensions, and
   rather better control over RMS processing errors.

   With C, you're looking to get a routine that emulates UNIX behaviour to
   do something very platform-specific...

   With RMS journaling, one gets a consistent view of files around processing
   errors, particularly around recovery from errors.

   I've since noted that .0 was cross-posted in the RMS notes conference,
   and that I had previously butchered the spelling of `journaling'...
   (This is a reposting.)

2095.5ThanksCSC32::J_HENSONDon&#039;t get even, get ahead!Wed Feb 19 1997 14:440