File:  [XINU] / xinu / sys / LSI / lfclose.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:39:04 2018 UTC (8 years, 3 months ago) by root
Branches: xinu, MAIN
CVS tags: xinu-19870308, HEAD
Xinu for VAX

/* lfclose.c - lfclose */

#include <conf.h>
#include <kernel.h>
#include <proc.h>
#include <disk.h>
#include <lfile.h>

/*------------------------------------------------------------------------
 *  lfclose  --  close a file by flushing output and freeing device slot
 *------------------------------------------------------------------------
 */
lfclose(devptr)
struct	devsw	*devptr;
{
	struct	dsblk	*dsptr;
	struct	dir	*dirptr;
	struct	flblk	*flptr;
	int	diskdev;
	char	ps;

	disable(ps);
	flptr = (struct flblk *) devptr->dvioblk;
	if (flptr->fl_pid != currpid) {
		restore(ps);
		return(SYSERR);
	}
	diskdev = flptr->fl_dev;
	dsptr = (struct dsblk *)devtab[diskdev].dvioblk;
	dirptr = (struct dir *) dsptr->ddir;
	if ( (flptr->fl_mode & FLWRITE) && flptr->fl_dch)
		lfsflush(flptr);
	flptr->fl_pid = 0;
	dsptr->dnfiles--;
	write(diskdev, dskbcpy(dirptr), DIRBLK);
	restore(ps);
	return(OK);
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.