minor corrections by M.Taguchi
[reactos.git] / posix / lib / psxdll / unistd / close.c
1 /* $Id: close.c,v 1.4 2002/10/29 04:45:46 rex Exp $
2 */
3 /*
4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS POSIX+ Subsystem
6 * FILE: subsys/psx/lib/psxdll/unistd/close.c
7 * PURPOSE: Close a file descriptor
8 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
9 * UPDATE HISTORY:
10 * 13/02/2002: Created
11 */
12
13 #include <ddk/ntddk.h>
14 #include <unistd.h>
15 #include <fcntl.h>
16 #include <psx/errno.h>
17 #include <psx/stdlib.h>
18 #include <psx/fdtable.h>
19
20 int close(int fildes)
21 {
22 __fildes_t fdDescriptor;
23 NTSTATUS nErrCode;
24
25 if(fcntl(fildes, F_DELFD, &fdDescriptor) == -1)
26 return (-1);
27
28 __free(fdDescriptor.ExtraData);
29
30 nErrCode = NtClose(fdDescriptor.FileHandle);
31
32 if(!NT_SUCCESS(nErrCode))
33 {
34 errno = __status_to_errno(nErrCode);
35 return (-1);
36 }
37
38 return (0);
39 }
40
41 /* EOF */
42