Cygwin: access: Fix X_OK behaviour for backup operators and admins
[newlib-cygwin.git] / newlib / libc / sys / mmixware / write.c
blob89247895ea0be61fcb6535b392c15f23c8161e90
1 /* write for MMIXware.
3 Copyright (C) 2001, 2023 Hans-Peter Nilsson
5 Permission to use, copy, modify, and distribute this software is
6 freely granted, provided that the above copyright notice, this notice
7 and the following disclaimer are preserved with no changes.
9 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
10 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
12 PURPOSE. */
14 #include <_ansi.h>
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include "sys/syscall.h"
18 #include <errno.h>
20 int
21 _write ( int file,
22 const void *ptr,
23 size_t len)
25 long ret;
27 if ((unsigned int) file >= 32 || _MMIX_allocated_filehandle[file] == 0)
29 errno = EBADF;
30 return -1;
33 ret = TRAP3f (SYS_Fwrite, file, ptr, len);
35 if (ret < 0)
37 errno = EIO;
38 return -1;
41 return len;