(NEW_FUNCTIONS): Add fcntl64.
* cygwin.din: Export fcntl64. Make fcntl being SIGFE.
* fcntl.cc (fcntl_worker): New function.
(fcntl64): New function.
(_fcntl): Call fcntl_worker. Convert 32 bit flock structure into
64 bit flock structure and vice versa.
* fhandler.cc (fhandler_base::lock): Change 2nd parameter to
struct __flock64 *.
* fhandler_disk_file.cc (fhandler_disk_file::lock): Ditto. Rework
to be 64 bit aware.
* fhandler.h: Accomodate above method argument changes.
* include/cygwin/types.h: Add struct __flock32 and __flock64.
Define struct flock according to setting of __CYGWIN_USE_BIG_TYPES__.
* include/cygwin/version.h: Bump API minor number.
2003-12-01 Corinna Vinschen <corinna@vinschen.de>
+ * Makefile.in (OBSOLETE_FUNCTIONS): Add fcntl.
+ (NEW_FUNCTIONS): Add fcntl64.
+ * cygwin.din: Export fcntl64. Make fcntl being SIGFE.
+ * fcntl.cc (fcntl_worker): New function.
+ (fcntl64): New function.
+ (_fcntl): Call fcntl_worker. Convert 32 bit flock structure into
+ 64 bit flock structure and vice versa.
+ * fhandler.cc (fhandler_base::lock): Change 2nd parameter to
+ struct __flock64 *.
+ * fhandler_disk_file.cc (fhandler_disk_file::lock): Ditto. Rework
+ to be 64 bit aware.
+ * fhandler.h: Accomodate above method argument changes.
+ * include/cygwin/types.h: Add struct __flock32 and __flock64.
+ Define struct flock according to setting of __CYGWIN_USE_BIG_TYPES__.
+ * include/cygwin/version.h: Bump API minor number.
+
+2003-12-01 Corinna Vinschen <corinna@vinschen.de>
+
* cygheap.cc (cygheap_init): Set cygheap->shared_prefix.
* cygheap.h (struct init_cygheap): Add shared_prefix.
* shared.cc (shared_name): Use cygheap->shared_prefix.
OBSOLETE_FUNCTIONS:=regcomp regerror regexec regfree regsub \
open acl aclcheck aclfrommode aclfrompbits \
aclfromtext aclsort acltomode acltopbits \
- acltotext chown facl fchown fdopen fgetpos fopen \
+ acltotext chown facl fchown fcntl fdopen fgetpos fopen \
freopen fseeko fsetpos fstat ftello ftruncate \
getegid geteuid getgid getgrent getgrgid getgrnam \
getgroups getpwuid getpwuid_r getuid initgroups \
chown _chown32 \
facl _facl32 \
fchown _fchown32 \
+ fcntl _fcntl64 \
fdopen _fdopen64 \
fgetpos _fgetpos64 \
fopen _fopen64 \
_fclose = fclose SIGFE
fcloseall SIGFE
_fcloseall = fcloseall SIGFE
-fcntl NOSIGFE
-_fcntl = fcntl NOSIGFE
+fcntl SIGFE
+_fcntl = fcntl SIGFE
+_fcntl64 = fcntl64 SIGFE
fcvt SIGFE
_fcvt = fcvt SIGFE
fcvtbuf SIGFE
fiprintf SIGFE
_fiprintf = fiprintf SIGFE
flock SIGFE
+flock SIGFE
floor NOSIGFE
_floor = floor NOSIGFE
floorf NOSIGFE
#include "cygheap.h"
#include "thread.h"
-extern "C" int
-_fcntl (int fd, int cmd,...)
+static int
+fcntl_worker (int fd, int cmd, void *arg)
{
- void *arg = NULL;
- va_list args;
int res;
cygheap_fdget cfd (fd, true);
res = -1;
goto done;
}
-
- va_start (args, cmd);
- arg = va_arg (args, void *);
if (cmd != F_DUPFD)
res = cfd->fcntl(cmd, arg);
else
res = dup2 (fd, cygheap_fdnew (((int) arg) - 1));
- va_end (args);
-
done:
syscall_printf ("%d = fcntl (%d, %d, %p)", res, fd, cmd, arg);
return res;
}
+
+extern "C" int
+fcntl64 (int fd, int cmd,...)
+{
+ void *arg = NULL;
+ va_list args;
+
+ va_start (args, cmd);
+ arg = va_arg (args, void *);
+ va_end (args);
+ return fcntl_worker (fd, cmd, arg);
+}
+
+extern "C" int
+_fcntl (int fd, int cmd,...)
+{
+ void *arg = NULL;
+ va_list args;
+ struct __flock32 *src;
+ struct __flock64 dst;
+
+ va_start (args, cmd);
+ arg = va_arg (args, void *);
+ va_end (args);
+ if (cmd == F_GETLK || cmd == F_SETLK || cmd == F_SETLKW)
+ {
+ src = (struct __flock32 *)arg;
+ dst.l_type = src->l_type;
+ dst.l_whence = src->l_whence;
+ dst.l_start = src->l_start;
+ dst.l_len = src->l_len;
+ dst.l_pid = src->l_pid;
+ arg = &dst;
+ }
+ int res = fcntl_worker (fd, cmd, arg);
+ if (cmd == F_GETLK)
+ {
+ src->l_type = dst.l_type;
+ src->l_whence = dst.l_whence;
+ src->l_start = dst.l_start;
+ src->l_len = dst.l_len;
+ src->l_pid = (short)dst.l_pid;
+ }
+ return res;
+}
}
int
-fhandler_base::lock (int, struct flock *)
+fhandler_base::lock (int, struct __flock64 *)
{
set_errno (EINVAL);
return -1;
case F_GETLK:
case F_SETLK:
case F_SETLKW:
- res = lock (cmd, (struct flock *) arg);
+ res = lock (cmd, (struct __flock64 *) arg);
break;
default:
set_errno (EINVAL);
virtual ssize_t readv (const struct iovec *, int iovcnt, ssize_t tot = -1);
virtual ssize_t writev (const struct iovec *, int iovcnt, ssize_t tot = -1);
virtual _off64_t lseek (_off64_t offset, int whence);
- virtual int lock (int, struct flock *);
+ virtual int lock (int, struct __flock64 *);
virtual void dump ();
virtual int dup (fhandler_base *child);
int open (int flags, mode_t mode);
int close ();
- int lock (int, struct flock *);
+ int lock (int, struct __flock64 *);
bool isdevice () { return false; }
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
the best. */
int
-fhandler_disk_file::lock (int cmd, struct flock *fl)
+fhandler_disk_file::lock (int cmd, struct __flock64 *fl)
{
_off64_t win32_start;
- int win32_len;
- DWORD win32_upper;
+ _off64_t win32_len;
_off64_t startpos;
/*
win32_start = 0;
}
- /*
- * Special case if len == 0 for POSIX means lock
- * to the end of the entire file (and all future extensions).
- */
+ DWORD off_high, off_low, len_high, len_low;
+
+ off_high = (DWORD)(win32_start & 0xffffffff);
+ off_low = (DWORD)(win32_start >> 32);
if (win32_len == 0)
{
- win32_len = 0xffffffff;
- win32_upper = wincap.lock_file_highword ();
+ /* Special case if len == 0 for POSIX means lock to the end of
+ the entire file (and all future extensions). */
+ len_low = 0xffffffff;
+ len_high = wincap.lock_file_highword ();
}
else
- win32_upper = 0;
+ {
+ len_low = (DWORD)(win32_len & 0xffffffff);
+ len_high = (DWORD)(win32_len >> 32);
+ }
BOOL res;
ov.Internal = 0;
ov.InternalHigh = 0;
- ov.Offset = (DWORD)win32_start;
- ov.OffsetHigh = 0;
+ ov.Offset = off_low;
+ ov.OffsetHigh = off_high;
ov.hEvent = (HANDLE) 0;
if (fl->l_type == F_UNLCK)
{
- res = UnlockFileEx (get_handle (), 0, (DWORD)win32_len, win32_upper, &ov);
+ res = UnlockFileEx (get_handle (), 0, len_low, len_high, &ov);
}
else
{
- res = LockFileEx (get_handle (), lock_flags, 0, (DWORD)win32_len,
- win32_upper, &ov);
+ res = LockFileEx (get_handle (), lock_flags, 0,
+ len_low, len_high, &ov);
/* Deal with the fail immediately case. */
/*
* FIXME !! I think this is the right error to check for
{
/* Windows 95 -- use primitive lock call */
if (fl->l_type == F_UNLCK)
- res = UnlockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len,
- win32_upper);
+ res = UnlockFile (get_handle (), off_low, off_high, len_low, len_high);
else
- res = LockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len, win32_upper);
+ res = LockFile (get_handle (), off_low, off_high, len_low, len_high);
}
if (res == 0)
#endif
#endif /*__ino_t_defined*/
+#if defined (__INSIDE_CYGWIN__)
+struct __flock32 {
+ short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
+ short l_whence; /* flag to choose starting offset */
+ _off_t l_start; /* relative offset, in bytes */
+ _off_t l_len; /* length, in bytes; 0 means lock to EOF */
+ short l_pid; /* returned with F_GETLK */
+ short l_xxx; /* reserved for future use */
+};
+
+struct __flock64 {
+ short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
+ short l_whence; /* flag to choose starting offset */
+ _off_t l_start; /* relative offset, in bytes */
+ _off64_t l_len; /* length, in bytes; 0 means lock to EOF */
+ pid_t l_pid; /* returned with F_GETLK */
+};
+#endif
+
+struct flock {
+ short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
+ short l_whence; /* flag to choose starting offset */
+ off_t l_start; /* relative offset, in bytes */
+ off_t l_len; /* length, in bytes; 0 means lock to EOF */
+#ifdef __CYGWIN_USE_BIG_TYPES__
+ pid_t l_pid; /* returned with F_GETLK */
+#else
+ short l_pid; /* returned with F_GETLK */
+ short l_xxx; /* reserved for future use */
+#endif
+};
+
#ifndef __key_t_defined
#define __key_t_defined
typedef long long key_t;
104: Export msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop.
105: Export sigwait.
106: Export flock.
+ 107: Export fcntl64.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 106
+#define CYGWIN_VERSION_API_MINOR 107
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible