This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Add flock syscall emulation


Hi All,

Here is a patch to add the flock() syscall to Cygwin.  I've noticed that some
of our mailer apps are using this syscall and have encountered a number of
other apps which do as well.  In most cases, they will provide an emulation of
flock using fcntl() in the case that  flock() is absent from the system's libc.
I've also noticed that some Linux distributions, Red Hat in particular, do not
trust the Linux kernel's implementation of flock and thus prefer to emulate it
in a similar manner.

Rather then duplicate the numerous varieties of emulated flock out there, I
decided to port this particular version of flock emulation from a patch
written by a Red Hat employee for use in Red Hat's IMAPd RPM.  I tried
contacting the individual listed in the spec's ChangeLog, but got no response.
IANAL, but since there was no notice of copyright at the top of the file and
since this code was created for Red Hat by a Red Hat employee, I'm assuming
that Red Hat owns the rights to this code?  This is based on the assumption
that Red Hat employees sign a similar copyright assignment to the one that we
do.  If this isn't so, please let me know and I'll go back to the drawing board.

So, I tweaked the code and formatting for use by Cygwin and have updated the
sys/file.h header to support the operations provided by this syscall.  I based
that off of the header from FreeBSD, which also resulted in the other changes.
IMHO, I found that the comments and the way in which the alternative whence
values were defined in the BSD header seemed to add more clarity.  So if there
are no objections, I thought I'd add those changes as well.

Also, I added an underscore symbol in the case that some program was looking
for the BSD syscall.  It was mostly done as an after-thought, so feel free to
dump that if you are inclined to do so.

Lastly, for testing purposes, you can build the flock source as an executable.
This is just a very small test to prove basic flock() functionality.  I've
tested successfully using some of the tests in the LTP.  Also, I've been
running programs using this implementation for months now, with no adverse
side-effects.

As a side note, I noticed that sys/file.h was from DJGPP.  Will DJ allow us to
use code from DJGPP in Newlib/Cygwin?  If so, I noticed some code in the DJGPP
libc which I could port and use in future contributions.

Cheers,
Nicholas

Attachment: ChangeLog.txt
Description: Text document

Attachment: cygwin-flock-emu.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]