David van Moolenbroek 232819dd49 VFS: store process suspension state as union
Previously, VFS would use various subsets of a number of fproc
structure fields to store state when the process is blocked
(suspended) for various reasons.  As a result, there was a fair
amount of abuse of fields, hidden state, and confusion as to
which fields were used with which suspension states.

Instead, the suspension state is now split into per-state
structures, which are then stored in a union.  Each of the union's
structures should be accessed only right before, during, and right
after the fp_blocked_on field is set to the corresponding blocking
type.  As a result, it is now very clear which fields are in use
at which times, and we even save a bit of memory as a side effect.

Change-Id: I5c24e353b6cb0c32eb41c70f89c5cfb23f6c93df
2016-08-05 11:15:15 +00:00

26 lines
814 B
C

/* This file is the counterpart of "read.c". It contains the code for writing
* insofar as this is not contained in read_write().
*
* The entry points into this file are
* do_write: call read_write to perform the WRITE system call
*/
#include "fs.h"
#include "file.h"
#include <minix/callnr.h>
/*===========================================================================*
* do_write *
*===========================================================================*/
int do_write(void)
{
/* Perform the write(fd, buffer, nbytes) system call. */
/* See the comment in do_read(). */
if (job_m_in.m_lc_vfs_readwrite.cum_io != 0)
return(EINVAL);
return(do_read_write_peek(WRITING, job_m_in.m_lc_vfs_readwrite.fd,
job_m_in.m_lc_vfs_readwrite.buf, job_m_in.m_lc_vfs_readwrite.len));
}