Hi,

In message "RCR - 'struct flock*' wrapper for rb_io_fcntl"
    on 03/12/09, "Ara.T.Howard" <ahoward / ngdc.noaa.gov> writes:

|SYNOPSIS:
|
|  ruby's fcntl call is incomplete in that one cannot pass a 'struct flock *'
|  arg as fcntl's third arg.  because of this, no posix compliant locking is
|  available from within ruby.

You can use pack/unpack for the purpose.

  require 'fcntl'        # import constants, perhaps this replaces IO#fcntl... 

  f = open('/tmp/foobar', 'w')
  flock = [Fcntl::F_RDLCK, 0, 0, 0, 0].pack("ssqqi")

  p Fcntl::F_RDLCK, Fcntl::F_GETLK
  f.fcntl Fcntl::F_GETLK, flock
  p flock.unpack("ssqqi")

But still I would not deny your proposal for the sake of readability
and portability.  Maybe there can be functions that work similar to
pack_sockaddr_*() / unpack_sockaddr_*() in the socket extension.
pack_flock() or something.

							matz.