Created
November 29, 2013 06:14
-
-
Save maebashi/7702150 to your computer and use it in GitHub Desktop.
The simplest libgfapi example Ruby FFI version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
module GLFS | |
extend FFI::Library | |
ffi_lib 'gfapi' | |
attach_function :new, :glfs_new, [:string], :pointer | |
attach_function :set_volfile_server, :glfs_set_volfile_server, | |
[:pointer, :string, :string, :int], :int | |
attach_function :init, :glfs_init, [:pointer], :int | |
attach_function :creat, :glfs_creat, [:pointer, :string, :int, :int], :pointer | |
attach_function :write, :glfs_write, [:pointer, :string, :uint, :int], :uint | |
attach_function :close, :glfs_close, [:pointer], :int | |
end | |
fs = GLFS.new 'volume_name' | |
ret = GLFS.set_volfile_server fs, 'tcp', 'server_address', 24007 | |
ret = GLFS.init fs | |
fd = GLFS.creat fs, 'filename', 2, 0644 | |
s = "hello gluster\n" | |
ret = GLFS.write fd, s, s.size+1, 0 | |
GLFS.close fd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment