module FFI::VixDiskLib::ApiWrapper

Constants

ERROR_LOGGER
INFO_LOGGER
WARN_LOGGER

Attributes

error_logger[R]
info_logger[R]
warn_logger[R]

Public Class Methods

attach(parent_disk_handle, child_disk_handle) click to toggle source
Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 19
def self.attach(parent_disk_handle, child_disk_handle)
  vix_error = super(parent_disk_handle, child_disk_handle)
  check_error(vix_error, __method__)
  nil
end
check_error(err, method) click to toggle source
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 432
def self.check_error(err, method)
  # if API::vix_failed?(err)
  if API.vix_failed?(err)
    err_msg = get_error_text(err, nil)
    # err_code = API::vix_error_code(err)
    err_code = API.vix_error_code(err)
    err_name = API::VixErrorType[err_code]
    if err_msg.nil? || err_msg.null?
      err_msg = "Error retrieving text of error message for errcode."
      msg = "#{name}##{method} (errcode=#{err_code} - #{err_name}): #{err_msg}"
    else
      msg = "#{name}##{method} (errcode=#{err_code} - #{err_name}): #{err_msg.read_string}"
      free_error_text(err_msg)
    end
    raise VixDiskLibError, "#{msg}"
  end
end
check_repair(connection, file_name, repair) click to toggle source

The VixDiskLib_CheckRepair method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 28
def self.check_repair(connection, file_name, repair)
  file_ptr = FFI::MemoryPointer.from_string(file_name)
  vix_error = super(connection, file_ptr, repair)
  check_error(vix_error, __method__)
  nil
end
cleanup(connect_parms) click to toggle source

The VixDiskLib_Cleanup method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 38
def self.cleanup(connect_parms)
  safe_parms = SafeConnectParams.new(connect_parms)
  cleaned_up = FFI::MemoryPointer.new :pointer
  remaining = FFI::MemoryPointer.new :pointer
  vix_error = super(safe_parms.connect_params, cleaned_up, remaining)
  num_cleaned_up = cleaned_up.get_uint32(0) unless cleaned_up.nil?
  num_remaining = remaining.get_uint32(0) unless remaining.nil?
  check_error(vix_error, __method__)
  return num_cleaned_up, num_remaining
end
clone(dest_connection, dest_path, src_connection, src_path, create_parms, over_write) click to toggle source

The VixDiskLib_Clone method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 52
def self.clone(dest_connection, dest_path, src_connection, src_path, create_parms, over_write)
  dest_ptr = FFI::MemoryPointer.from_string(dest_path)
  src_ptr = FFI::MemoryPointer.from_string(src_path)
  safe_parms = SafeCreateParams.new(create_parms)
  vix_error = super(dest_connection, dest_ptr, src_connection, src_ptr,
                    safe_parms.create_params, nil, nil, over_write)
  check_error(vix_error, __method__)
  nil
end
close(disk_handle) click to toggle source

The VixDiskLib_Close method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 65
def self.close(disk_handle)
  vix_error = super(disk_handle)
  check_error(vix_error, __method__)
  nil
end
connect(connect_parms) click to toggle source

The VixDiskLib_Connect method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 74
def self.connect(connect_parms)
  connection = FFI::MemoryPointer.new :pointer
  safe_parms = SafeConnectParams.new(connect_parms)
  vix_error = super(safe_parms.connect_params, connection)
  connection = connection.get_pointer(0)
  check_error(vix_error, __method__)
  connection
end
connect_ex(connect_parms, read_only, snapshot_ref, transport_modes) click to toggle source

The VixDiskLib_ConnectEx method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 86
def self.connect_ex(connect_parms, read_only, snapshot_ref, transport_modes)
  connection = FFI::MemoryPointer.new :pointer
  safe_parms = SafeConnectParams.new(connect_parms)
  snapshot_ptr = snapshot_ref && FFI::MemoryPointer.from_string(snapshot_ref)
  modes_ptr = transport_modes && FFI::MemoryPointer.from_string(transport_modes)
  vix_error = super(safe_parms.connect_params, read_only, snapshot_ptr, modes_ptr, connection)
  connection = connection.get_pointer(0)
  check_error(vix_error, __method__)
  connection
end
create(connection, path, create_parms, prog_func = nil, prog_callback_data = nil) click to toggle source

The VixDiskLib_Create method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 100
def self.create(connection, path, create_parms, prog_func = nil, prog_callback_data = nil)
  safe_parms = SafeCreateParams.new(create_parms)
  path_ptr = FFI::MemoryPointer.from_string(path)
  vix_error = super(connection, path_ptr, safe_parms.create_params, prog_func, prog_callback_data)
  check_error(vix_error, __method)
  nil
end
create_child(disk_handle, child_path, disk_type, prog_func = nil, prog_callback_data = nil) click to toggle source

The VixDiskLib_CreateChild method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 111
def self.create_child(disk_handle, child_path, disk_type, prog_func = nil, prog_callback_data = nil)
  path_ptr = FFI::MemoryPointer.from_string(child_path)
  vix_error = super(disk_handle, path_ptr, disk_type, prog_func, prog_callback_data)
  check_error(vix_error, __method)
  nil
end
defragment(disk_handle) click to toggle source

The VixDiskLib_Defragment method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 121
def self.defragment(disk_handle)
  vix_error = super(disk_handle, nil, nil)
  check_error(vix_error, __method__)
  nil
end
disconnect(connection) click to toggle source

The VixDiskLib_Disconnect method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 130
def self.disconnect(connection)
  vix_error = super(connection)
  check_error(vix_error, __method__)
  nil
end
end_access(connect_parms, identity) click to toggle source

The VixDiskLib_Access method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 139
def self.end_access(connect_parms, identity)
  safe_parms = SafeConnectParams.new(connect_parms)
  identity_ptr = FFI::MemoryPointer.from_string(identity)
  vix_error = super(safe_parms.connect_params, identity_ptr)
  check_error(vix_error, __method__)
  nil
end
exit() click to toggle source

The VixDiskLib_Exit method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 150
def self.exit
  super
  nil
end
free_connect_params(connect_params) click to toggle source

The VixDiskLib_FreeConnectParams method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 158
def self.free_connect_params(connect_params)
  super(connect_params)
end
get_connect_params(connection) click to toggle source

The VixDiskLib_GetConnectParams method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 165
def self.get_connect_params(connection)
  params_ptr = FFI::MemoryPointer.new :pointer
  vix_error = super(connection, params_ptr)
  check_error(vix_error, __method__)
  ffi_connect_params = params_ptr.get_pointer(0)
  safe_connect_params = SafeConnectParams.read(ffi_connect_params)
  safe_connect_params
end
get_info(disk_handle) click to toggle source

The VixDiskLib_GetInfo method

# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 177
def self.get_info(disk_handle)
  info = DiskInfo.new(disk_handle)
  info.info
end
get_metadata_keys(disk_handle) click to toggle source

The VixDiskLib_GetMetadataKeys method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 185
def self.get_metadata_keys(disk_handle)
  #
  # Get the size of the buffer required for the metadata keys for the disk.
  #
  len_ptr = FFI::MemoryPointer.new :pointer
  vix_error = super(disk_handle, nil, 0, len_ptr)
  if vix_error != API::VixErrorType[:VIX_OK] && vix_error != API::VixErrorType[:VIX_E_BUFFER_TOOSMALL]
    check_error(vix_error, __method__)
  end
  #
  # Read the metadata keys for the disk into the allocated buffer.
  #
  buf_size = len_ptr.get_uint64(0)
  read_buf = FFI::MemoryPointer.new(buf_size)
  vix_error = super(disk_handle, read_buf, buf_size, nil)
  check_error(vix_error, __method__)
  keys = read_buf.get_bytes(0, buf_size)
  keys.split("\x00")
end
get_transport_mode(disk_handle) click to toggle source

The VixDiskLib_GetTransportMode method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 208
def self.get_transport_mode(disk_handle)
  mode = super(disk_handle)
  mode.read_string
end
grow(connection, path, capacity, update_geometry) click to toggle source

The VixDiskLib_Grow method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 216
def self.grow(connection, path, capacity, update_geometry)
  path_ptr = FFI::MemoryPointer.from_string(path)
  vix_error = super(connection, path_ptr, capacity, update_geometry, nil, nil)
  check_error(vix_error, __method__)
  nil
end
init(info_logger = nil, warn_logger = nil, error_logger = nil, libDir = nil) click to toggle source

The VixDiskLib_Init method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 226
def self.init(info_logger = nil, warn_logger = nil, error_logger = nil, libDir = nil)
  @info_logger, @warn_logger, @error_logger = info_logger, warn_logger, error_logger

  vix_error = super(API::VERSION_MAJOR, API::VERSION_MINOR,
                    logger_for("info"), logger_for("warn"), logger_for("error"), libDir)
  check_error(vix_error, __method__)
  nil
end
init_ex(info_logger = nil, warn_logger = nil, error_logger = nil, libDir = nil, configFile = nil) click to toggle source

The VixDiskLib_InitEx method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 238
def self.init_ex(info_logger = nil, warn_logger = nil, error_logger = nil, libDir = nil, configFile = nil)
  @info_logger, @warn_logger, @error_logger = info_logger, warn_logger, error_logger

  vix_error = super(API::VERSION_MAJOR, API::VERSION_MINOR,
                    logger_for("info"), logger_for("warn"), logger_for("error"), libDir, configFile)
  check_error(vix_error, __method__)
  nil
end
is_attach_possible(parent_disk_handle, child_disk_handle) click to toggle source

The VixDiskLib_IsAttachPossible method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 250
def self.is_attach_possible(parent_disk_handle, child_disk_handle)
  vix_error = super(parent_disk_handle, child_disk_handle)
  VixDiskLib.vix_succeeded?(vix_error)
end
list_transport_modes() click to toggle source

The VixDiskLib_ListTransportModes method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 258
def self.list_transport_modes
  list = super
  list.read_string
end
logger_for(level) click to toggle source
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 421
def self.logger_for(level)
  instance_variable_get("@#{level.downcase}_logger") && const_get("#{level.upcase}_LOGGER")
end
open(connection, path, flags) click to toggle source

The VixDiskLib_Open method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 266
def self.open(connection, path, flags)
  path_ptr = FFI::MemoryPointer.from_string(path)
  disk_handle = FFI::MemoryPointer.new :pointer
  vix_error = super(connection, path_ptr, flags, disk_handle)
  check_error(vix_error, __method__)
  disk_handle.get_pointer(0)
end
prepare_for_access(connect_parms, identity) click to toggle source

The VixDiskLib_PrepareForAccess method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 277
def self.prepare_for_access(connect_parms, identity)
  safe_parms = SafeConnectParams.new(connect_parms)
  identity_ptr = FFI::MemoryPointer.from_string(identity)
  vix_error = super(safe_parms.connect_params, identity_ptr)
  check_error(vix_error, __method__)
  nil
end
process_log_args(fmt, args) click to toggle source
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 425
def self.process_log_args(fmt, args)
  buf = FFI::MemoryPointer.new(:char, 1024, true)
  # LIBC::vsnprintf(buf, 1024, fmt, args)
  LIBC.vsnprintf(buf, 1024, fmt, args)
  buf.read_string.chomp
end
read(disk_handle, start_sector, num_sectors) click to toggle source

The VixDiskLib_Read method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 288
def self.read(disk_handle, start_sector, num_sectors)
  buf_size = num_sectors * API::VIXDISKLIB_SECTOR_SIZE
  read_buf = FFI::MemoryPointer.new(buf_size)
  read_buf.clear
  vix_error = super(disk_handle, start_sector, num_sectors, read_buf)
  check_error(vix_error, __method__)
  read_buf.get_bytes(0, buf_size)
end
read_metadata(disk_handle, key) click to toggle source

The VixDiskLib_ReadMetadata method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 300
def self.read_metadata(disk_handle, key)
  key_ptr = FFI::MemoryPointer.from_string(key)
  #
  # Get the size of the buffer required for the metadata key for this disk.
  #
  len_ptr = FFI::MemoryPointer.new :pointer
  vix_error = super(disk_handle, key_ptr, nil, 0, len_ptr)
  if vix_error != API::VixErrorType[:VIX_OK] && vix_error != API::VixErrorType[:VIX_E_BUFFER_TOOSMALL]
    check_error(vix_error, __method__)
  end
  #
  # Read the metadata key for the disk into the allocated buffer.
  #
  buf_size = len_ptr.get_uint64(0)
  read_buf = FFI::MemoryPointer.new(buf_size)
  vix_error = super(disk_handle, key_ptr, read_buf, buf_size, nil)
  check_error(vix_error, __method__)
  read_buf.get_bytes(0, buf_size)
end
rename(src_path, dest_path) click to toggle source

The VixDiskLib_Rename method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 323
def self.rename(src_path, dest_path)
  src_ptr = FFI::MemoryPointer.from_string(src_path)
  dest_ptr = FFI::MemoryPointer.from_string(dest_path)
  vix_error = super(src_ptr, dest_ptr)
  check_error(vix_error, __method__)
  nil
end
shrink(disk_handle, prog_func = nil, prog_callback_data = nil) click to toggle source

The VixDiskLib_Shrink method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 334
def self.shrink(disk_handle, prog_func = nil, prog_callback_data = nil)
  vix_error = super(disk_handle, prog_func, prog_callback_data)
  check_error(vix_error, __method__)
  nil
end
space_needed_for_clone(disk_handle, disk_type) click to toggle source

The VixDiskLib_SpaceNeededForClone method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 343
def self.space_needed_for_clone(disk_handle, disk_type)
  needed_ptr = FFI::MemoryPointer.new :pointer
  vix_error = super(disk_handle, disk_type, needed_ptr)
  check_error(vix_error, __method__)
  needed_ptr.get_uint64(0)
end
write(disk_handle, start_sector, num_sectors, buf) click to toggle source

The VixDiskLib_Write method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 363
def self.write(disk_handle, start_sector, num_sectors, buf)
  buf_size = num_sectors * :VIXDISKLIB_SECTOR_SIZE
  buf_ptr = FFI::MemoryPointer.new(buf_size)
  buf_ptr.write_bytes(buf, 0, buf_size)
  vix_error = super(disk_handle, start_sector, num_sectors, buf_ptr)
  check_error(vix_error, __method__)
  nil
end
write_metadata(disk_handle, key, value) click to toggle source

The VixDiskLib_WriteMetadata method

Calls superclass method
# File lib/ffi-vix_disk_lib/api_wrapper.rb, line 375
def self.write_metadata(disk_handle, key, value)
  key_ptr = FFI::MemoryPointer.from_string(key)
  val_ptr = FFI::MemoryPointer.from_string(value)
  vix_error = super(disk_handle, key_ptr, val_ptr)
  check_error(vix_error, __method__)
  nil
end