xref: /csrg-svn/sys/stand.att/close.c (revision 63370)
149146Sbostic /*-
2*63370Sbostic  * Copyright (c) 1982, 1988, 1993
3*63370Sbostic  *	The Regents of the University of California.  All rights reserved.
449146Sbostic  *
549146Sbostic  * %sccs.include.proprietary.c%
649146Sbostic  *
7*63370Sbostic  *	@(#)close.c	8.1 (Berkeley) 06/11/93
849146Sbostic  */
949146Sbostic 
1049146Sbostic #include <sys/param.h>
1160328Smckusick #include <stand.att/saio.h>
1249146Sbostic 
close(fdesc)1349146Sbostic close(fdesc)
1449146Sbostic 	int fdesc;
1549146Sbostic {
1649146Sbostic #ifndef SMALL
1749146Sbostic 	struct iob *file;
1849146Sbostic 
1949146Sbostic 	fdesc -= 3;
2049146Sbostic 	if (fdesc < 0 || fdesc >= SOPEN_MAX ||
2149146Sbostic 	    ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0) {
2249146Sbostic 		errno = EBADF;
2349146Sbostic 		return (-1);
2449146Sbostic 	}
2549146Sbostic 	if ((file->i_flgs&F_FILE) == 0)
2649146Sbostic 		devclose(file);
2749146Sbostic 	file->i_flgs = 0;
2849146Sbostic #endif
2949146Sbostic 	return (0);
3049146Sbostic }
31