diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-03-12 18:30:29 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-03-12 18:30:29 +0000 |
commit | fc69f1aed5ddfc7af997b90131b8d453eec4fbfb (patch) | |
tree | bd472ed2e91ecab065b95cc0a00bf5767019a16f | |
parent | 2e0b52c9d8ead058f84b2e749d77ecdf6c0559cb (diff) | |
download | cygnal-fc69f1aed5ddfc7af997b90131b8d453eec4fbfb.tar.gz cygnal-fc69f1aed5ddfc7af997b90131b8d453eec4fbfb.tar.bz2 cygnal-fc69f1aed5ddfc7af997b90131b8d453eec4fbfb.zip |
* flock.cc (fhandler_disk_file::lock): Don't test file open mode in
case of flock-type locks. Explain why.
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/flock.cc | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index d702d3901..42d2388c8 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2009-03-12 Corinna Vinschen <corinna@vinschen.de> + + * flock.cc (fhandler_disk_file::lock): Don't test file open mode in + case of flock-type locks. Explain why. + 2009-03-12 Brian Ford <Brian.Ford@FlightSafety.com> * gethostby_helper: Fix typos in DEBUGGING case. diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc index 42941cb78..964156ca0 100644 --- a/winsup/cygwin/flock.cc +++ b/winsup/cygwin/flock.cc @@ -652,14 +652,19 @@ fhandler_disk_file::lock (int a_op, struct __flock64 *fl) a_op = F_UNLCK; break; case F_RDLCK: - if (!(get_access () & GENERIC_READ)) + /* flock semantics don't specify a requirement that the file has + been opened with a specific open mode, in contrast to POSIX locks + which require that a file is opened for reading to place a read + lock and opened for writing to place a write lock. */ + if ((a_flags & F_POSIX) && !(get_access () & GENERIC_READ)) { set_errno (EBADF); return -1; } break; case F_WRLCK: - if (!(get_access () & GENERIC_WRITE)) + /* See above comment. */ + if ((a_flags & F_POSIX) && !(get_access () & GENERIC_WRITE)) { set_errno (EBADF); return -1; |