2 * <fcntl.h> wrapper functions.
5 * Jonathan Pryor (jonpryor@vt.edu)
7 * Copyright (C) 2004, 2006 Jonathan Pryor
14 #include <sys/types.h>
26 Mono_Posix_Syscall_fcntl (gint32 fd
, gint32 cmd
)
28 if (Mono_Posix_FromFcntlCommand (cmd
, &cmd
) == -1)
30 return fcntl (fd
, cmd
);
34 Mono_Posix_Syscall_fcntl_arg (gint32 fd
, gint32 cmd
, gint64 arg
)
39 mph_return_if_long_overflow (arg
);
42 if (cmd
== F_NOTIFY
) {
44 if (Mono_Posix_FromDirectoryNotifyFlags (arg
, &_argi
) == -1) {
53 if (Mono_Posix_FromFcntlCommand (cmd
, &_cmd
) == -1)
55 return fcntl (fd
, cmd
, _arg
);
59 Mono_Posix_Syscall_fcntl_lock (gint32 fd
, gint32 cmd
, struct Mono_Posix_Flock
*lock
)
69 if (Mono_Posix_FromFlock (lock
, &_lock
) == -1)
72 if (Mono_Posix_FromFcntlCommand (cmd
, &cmd
) == -1)
75 r
= fcntl (fd
, cmd
, &_lock
);
77 if (Mono_Posix_ToFlock (&_lock
, lock
) == -1)
84 Mono_Posix_Syscall_open (const char *pathname
, gint32 flags
)
86 if (Mono_Posix_FromOpenFlags (flags
, &flags
) == -1)
89 return open (pathname
, flags
);
93 Mono_Posix_Syscall_open_mode (const char *pathname
, gint32 flags
, guint32 mode
)
95 if (Mono_Posix_FromOpenFlags (flags
, &flags
) == -1)
97 if (Mono_Posix_FromFilePermissions (mode
, &mode
) == -1)
100 return open (pathname
, flags
, mode
);
104 Mono_Posix_Syscall_get_at_fdcwd ()
114 Mono_Posix_Syscall_creat (const char *pathname
, guint32 mode
)
116 if (Mono_Posix_FromFilePermissions (mode
, &mode
) == -1)
119 return creat (pathname
, mode
);
122 #ifdef HAVE_POSIX_FADVISE
124 Mono_Posix_Syscall_posix_fadvise (gint32 fd
, mph_off_t offset
, mph_off_t len
,
127 mph_return_if_off_t_overflow (offset
);
128 mph_return_if_off_t_overflow (len
);
130 if (Mono_Posix_FromPosixFadviseAdvice (advice
, &advice
) == -1)
133 return posix_fadvise (fd
, (off_t
) offset
, (off_t
) len
, advice
);
135 #endif /* ndef HAVE_POSIX_FADVISE */
137 #ifdef HAVE_POSIX_FALLOCATE
139 Mono_Posix_Syscall_posix_fallocate (gint32 fd
, mph_off_t offset
, mph_size_t len
)
141 mph_return_if_off_t_overflow (offset
);
142 mph_return_if_size_t_overflow (len
);
144 return posix_fallocate (fd
, (off_t
) offset
, (size_t) len
);
146 #endif /* ndef HAVE_POSIX_FALLOCATE */