[net.unix] UNIX 4.2 file system query

divy@sbcs.UUCP (Divyakant Agrawal) (04/21/85)

	 UNIX 4.2 allows files to be opened in append mode. I would 
	 like to know if this is "Atomic Append". 

	 For example, if two programs open the same file in append mode,
	 and append few blocks to the file then is it true that the blocks
         will be appended in order (that is first all the blocks of first 
         program followed by the blocks of the second program, or vice-versa).
	 
	 Also, if this is true then is the granularity of atomicity is at
	 block level or is arbitrary. 
	
	 Thanks in advance.

divy

wood@rtp47.UUCP (Tom Wood) (04/24/85)

> 	 UNIX 4.2 allows files to be opened in append mode. I would 
> 	 like to know if this is "Atomic Append". 
> 
> 	 For example, if two programs open the same file in append mode,
> 	 and append few blocks to the file then is it true that the blocks
>          will be appended in order (that is first all the blocks of first 
>          program followed by the blocks of the second program, or vice-versa).
> 	 
> 	 Also, if this is true then is the granularity of atomicity is at
> 	 block level or is arbitrary. 
> divy

Having a file open in append mode (O_APPEND in BSD 4.2 and FAPPEND
in Sys V) causes the file pointer to be set to the current file size
at each write operation.  Since write operations to the same file do
not overlap in time, each process will append data to the file at
the time the write system call is invoked.  The data written to the
file in a given write operation will appear as a contiguous sequence
within the file.  If the processes do not cooperate, the sequences
of write operations by each process can be arbitrarily interspersed.

-- 
Tom Wood	Data General, Research Triangle Park, NC
{the known world}!mcnc!rti-sel!rtp47!wood

guy@sun.uucp (Guy Harris) (04/27/85)

> Having a file open in append mode (O_APPEND in BSD 4.2 and FAPPEND
> in Sys V) ...

No, please, O_APPEND both in 4.2BSD and System III/V.  The various flavors
of UNIX differ in too many ways already; let's be grateful that there's one
extension which was done the same way in more than one variant...
(<fcntl.h>, which is what you're supposed to include, defines O_APPEND;
<sys/file.h>, which you're not supposed to include unless you're rummaging
through the kernel's file descriptor table, defines FAPPEND.  On 4.2BSD they
reference one another, so you get both with either include.)

	Guy Harris