diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2003-12-01 20:26:28 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2003-12-01 20:26:28 +0300 |
commit | dc3998682acd295299bffc3c544af74503e1dc02 (patch) | |
tree | 9d483f863e7902630121a627e6db18f632e3ad60 | |
parent | 6c2b7846124572ffed3ce4fea074cc89e732651c (diff) |
* 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.
-rw-r--r-- | winsup/cygwin/ChangeLog | 18 | ||||
-rw-r--r-- | winsup/cygwin/Makefile.in | 3 | ||||
-rw-r--r-- | winsup/cygwin/cygwin.din | 6 | ||||
-rw-r--r-- | winsup/cygwin/fcntl.cc | 56 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 39 | ||||
-rw-r--r-- | winsup/cygwin/include/cygwin/types.h | 32 | ||||
-rw-r--r-- | winsup/cygwin/include/cygwin/version.h | 3 |
9 files changed, 130 insertions, 35 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index d23b19b1f..1030e4b57 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,23 @@ 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. diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index b7bcbe532..3a6f06233 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -143,7 +143,7 @@ GMON_OFILES:=gmon.o mcount.o profil.o 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 \ @@ -168,6 +168,7 @@ NEW_FUNCTIONS:=regcomp posix_regcomp \ chown _chown32 \ facl _facl32 \ fchown _fchown32 \ + fcntl _fcntl64 \ fdopen _fdopen64 \ fgetpos _fgetpos64 \ fopen _fopen64 \ diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index b5d71578a..0611076fe 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -464,8 +464,9 @@ fclose SIGFE _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 @@ -501,6 +502,7 @@ _finitef = finitef NOSIGFE fiprintf SIGFE _fiprintf = fiprintf SIGFE flock SIGFE +flock SIGFE floor NOSIGFE _floor = floor NOSIGFE floorf NOSIGFE diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc index b1afb57d3..89287b647 100644 --- a/winsup/cygwin/fcntl.cc +++ b/winsup/cygwin/fcntl.cc @@ -19,11 +19,9 @@ details. */ #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); @@ -32,16 +30,56 @@ _fcntl (int fd, int cmd,...) 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; +} diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index afd5ffd3d..7a3b6773e 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -931,7 +931,7 @@ fhandler_base::ioctl (unsigned int cmd, void *buf) } int -fhandler_base::lock (int, struct flock *) +fhandler_base::lock (int, struct __flock64 *) { set_errno (EINVAL); return -1; @@ -1088,7 +1088,7 @@ int fhandler_base::fcntl (int cmd, void *arg) 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); diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index b0fb90405..22b2eb062 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -294,7 +294,7 @@ class fhandler_base 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); @@ -603,7 +603,7 @@ class fhandler_disk_file: public fhandler_base 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))); diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index faebc4511..c51eace2a 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -460,11 +460,10 @@ fhandler_base::close_fs () 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; /* @@ -535,17 +534,22 @@ fhandler_disk_file::lock (int cmd, struct flock *fl) 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; @@ -558,18 +562,18 @@ fhandler_disk_file::lock (int cmd, struct flock *fl) 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 @@ -587,10 +591,9 @@ fhandler_disk_file::lock (int cmd, struct flock *fl) { /* 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) diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h index 103337457..fc803aca1 100644 --- a/winsup/cygwin/include/cygwin/types.h +++ b/winsup/cygwin/include/cygwin/types.h @@ -99,6 +99,38 @@ typedef __ino32_t ino_t; #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; diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 76130833b..246e7a45c 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -231,12 +231,13 @@ details. */ 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 |