fcntl() problem - write() returns 13
Eric Z. Ayers
eric.ayers@mindspring.com
Sun Aug 6 07:41:00 GMT 2000
Hello All,
I'm a new user to Cygwin. Although I have a lot of experience in C
coding under UNIX, I've not developed on NT before. I've spent the
past hour or so researching this issue by reading the FAQ, API notes
and the archives, but haven't found an answer, so I'm posting.
We were scratching our heads to figure out why a write() call was
failing and setting errno to 13 (permission denied).
Apparently, some preceeding calls to 'fcntl' are
causing an NT error on trying to write to the file. The real error is
"LOCK_VIOLATION" which cygwin translates into 13 (permission denied)
because I guess that was the closest thing...
strace cgisam_add_del_test.exe -create -file=/tmp/ixfile_eza
...
442 282687 [main] cgisam_add_del_test 1097 statfs: statfs D:\
647 283334 [main] cgisam_add_del_test 1097 _fcntl: 0 = fcntl (3, 8, 0)
**This is a fcntl (F_SETLK for a 1 byte read-only lock at byte 1)
212 283546 [main] cgisam_add_del_test 1097 _fcntl: 0 = fcntl (3, 9, 0)
**This is a fcntl (F_SETLK for a 1 byte write lock at byte 9)
192 283927 [main] cgisam_add_del_test 1097 fhandler_base::lseek: lseek (/tmp/i\
xfile_eza.\ixd, 0, 0)
195 284\122 [main] cgisam_add_del_test 1097 _lseek: 0 = lseek (3, 0, 0)
186 28\4308 [main] cgisam_add_del_test 1097 _write: write (3, 0xA031860, 1024)
** This is writing a 1K block at the start of the file
216 \284524 [main] cgisam_add_del_test 1097 /src/winsup/fhandler.cc:272 seterr\
no: 3\3 (LOCK_VIOLATION) -> 13
190 284714 [main] cgisam_add_del_test
1097 _write: -1 = write (3, 0xA031860, 1024)
It appears that locks set with fcntl() have some different behavior
under Cygwin than under UNIX. Apparently, they are mandatory. It
seems that we have taken advantage of the fact that locks under UNIX
are advisory only. We're not using these locks to lock the parts of
the file we're interested in.
I noticed that there is nothing about file locking in the 'TODO'
list, but the API doc says that F_GETLK isn't implemented (darn, we
use that too.) I'm assuming that if this were something easy to do
you would have already done it... :-)
Thanks for reading all of the above. If this is not a bug, then, here
are my questions:
Are there any plans to make file locks advisory instead of mandatory?
Are there any plans to implement F_GETLK as an option to fcntl()?
Regards,
-Eric.
--
Eric Z. Ayers Phone: +1 404-705-2864
Computer Generation Incorporated FAX: +1 404-705-2805
Building G, 4th Floor, 5775 Peachtree-Dunwoody Rd., Atlanta, GA 30342 USA
eric@compgen.com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
More information about the Cygwin
mailing list