Sha256: 20a1171eaebebb1843e82b1cdf68892364bc2396760b37ab2dcc7959d27e6c6b

Contents?: true

Size: 1.76 KB

Versions: 3

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

require_relative 'accessors'

module FFI
  # Flocking operation
  class Flock < Struct
    # Enum definitions associated with Flock
    module Enums
      extend FFI::Library
      seek_whence = %i[seek_set seek_cur seek_end seek_data seek_hole]
      SeekWhenceShort = enum :short, seek_whence
      SeekWhence = enum :int, seek_whence

      LockType = enum :short, %i[rdlck wrlck unlck]
      LockCmd = enum :int, [:getlk, 5, :setlk, 6, :setlkw, 7]
    end

    include(Accessors)

    layout(l_type: Enums::LockType, l_whence: Enums::SeekWhenceShort, l_start: :off_t, l_len: :off_t, l_pid: :pid_t)

    l_members = members.grep(/^l_/).map { |m| m[2..].to_sym }

    ffi_attr_reader(*l_members, format: 'l_%s')

    # @!attribute [r] type
    #   @return [Symbol] lock type, :rdlck, :wrlck, :unlck

    # @!attribute [r] whence
    #   @return [Symbol] specifies what the offset is relative to, one of :seek_set, :seek_cur or :seek_end
    #    corresponding to the whence argument to fseek(2) or lseek(2),

    # @!attribute [r] start
    #  @return [Integer] the offset of the start of the region to which the lock applies, and is given in bytes
    #   relative to the point specified by #{whence} member.

    # @!attribute [r] len
    #  @return [Integer] the length of the region to be locked.
    #
    #    A value of 0 means the region extends to the end of the file.

    # @!attribute [r] pid
    #  @return [Integer] the process ID (see Process Creation Concepts) of the process holding the lock.
    #   It is filled in by calling fcntl with the F_GETLK command, but is ignored when making a lock. If the
    #   conflicting lock is an open file description lock (see Open File Description Locks), then this field will be
    #   set to -1.
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffi-libfuse-0.4.0 lib/ffi/flock.rb
ffi-libfuse-0.3.4 lib/ffi/flock.rb
ffi-libfuse-0.3.3 lib/ffi/flock.rb