GlusterFS::GFAPI::FFI - FFI Perl binding for GlusterFS libgfapi
0.3
# make GlusterFS Volume instance my $fs = GlusterFS::GFAPI::FFI::glfs_new('libgfapi-perl'); # set server information for a volume if (GlusterFS::GFAPI::FFI::glfs_set_volfile_server($fs, 'tcp', 'node1', 24007)) { die "Failed to set volfile server: $!"; } # initialize connection for a GlusterFS Volume if (GlusterFS::GFAPI::FFI::glfs_init($fs)) { die "Failed to init connection: $!"; } # get a Volume-ID my $len = 16; my $id = "\0" x $len; if (GlusterFS::GFAPI::FFI::glfs_get_volumeid($fs, $id, $len) < 0) { die "Failed to get volume-id: $!"; } printf "Volume-ID: %s\n", join('-', unpack('H8 H4 H4 H4 H12', $id)); # get stat for a volume my $stat = GlusterFS::GFAPI::FFI::Statvfs->new(); if (GlusterFS::GFAPI::FFI::glfs_statvfs($fs, '/', $stat)) { die "Failed to get statvfs: $!"; } printf "- f_bsize : %d\n", $stat->f_bsize; printf "- f_frsize : %d\n", $stat->f_frsize; printf "- f_blocks : %d\n", $stat->f_blocks; printf "- f bfree : %d\n", $stat->f_bfree; printf "- f_bavail : %d\n", $stat->f_bavail; printf "- f_files : %d\n", $stat->f_files; printf "- f_ffree : %d\n", $stat->f_ffree; printf "- f_favail : %d\n", $stat->f_favail; printf "- f_fsid : %d\n", $stat->f_fsid; printf "- f_flag : 0x%o\n", $stat->f_flag; printf "- f_namemax : %d\n", $stat->f_namemax; # create a file and take file-descriptor my $fd = GlusterFS::GFAPI::FFI::glfs_creat($fs, "/potato", O_RDWR, 0644); # get stat for a file $stat = GlusterFS::GFAPI::FFI::Stat->new(); if (GlusterFS::GFAPI::FFI::glfs_stat($fs, "/potato", $stat)) { die "Failed to stat: $!"; } printf "- ino : %d\n", $stat->st_ino; printf "- mode : 0x%o\n", $stat->st_mode; printf "- size : %d\n", $stat->st_size; printf "- blksize : %d\n", $stat->st_blksize; printf "- uid : %d\n", $stat->st_uid; printf "- gid : %d\n", $stat->st_gid; printf "- atime : %d\n", $stat->st_atime; printf "- mtime : %d\n", $stat->st_mtime; printf "- ctime : %d\n", $stat->st_ctime; # write data to a file my $buffer = 'this is a lipsum'; if (GlusterFS::GFAPI::FFI::glfs_write($fd, $buffer, length($buffer), 0) == -1) { die "Failed to write: $!"; } # seek a file offset if (GlusterFS::GFAPI::FFI::glfs_lseek($fd, 0, 0)) { die "Failed to seek: $!"; } # read data from a file $buffer = "\0" x 256; if (GlusterFS::GFAPI::FFI::glfs_read($fd, $buffer, 256, 0) == -1) { die "Failed to read: $!"; } printf "read: %s\n", $buffer; # close a file if (GlusterFS::GFAPI::FFI::glfs_close($fd)) { die "Failed to close: $!"; } # destroy a connection if (GlusterFS::GFAPI::FFI::glfs_fini($fs)) { die "Failed to terminate: $!" }
$retval = glfs_init($fs)
$fs = glfs_new($volname)
$retval = glfs_set_volfile_server($fs, $proto, $node, $port)
$retval = glfs_set_logging($fs, $path, $level)
$retval = glfs_fini($fs)
$volid = glfs_get_volumeid($fs, $buf, $bufsz)
$retval = glfs_setfsuid($uid)
$retval = glfs_setfsgid($uid)
$retval = glfs_setfsgroups($uid, $gids)
$fd = glfs_open($fs, $path, $flags)
$fd = glfs_creat($fs, $path, $flags, $mode)
$retval = glfs_close($fd)
$fs = glfs_from_glfd($fd)
$retval = glfs_set_xlator_option($fs, $xlator, $key, $value)
$retval = glfs_read($fd, $buf, $count, $flags)
$retval = glfs_write($fd, $buf, $count, $flags)
($retval, @data) = glfs_readv($fd, [$buf1, ...], $flags)
$retval = glfs_writev($fd, [$buf1, ...], $flags)
$retval = glfs_pread($fd, $buf, $count, $offset, $flags)
$retval = glfs_pwrite($fd, $buf, $count, $offset, $flags)
($retval, @data) = glfs_preadv($fd, [$buf1, ...], $offset, $flags)
$retval = glfs_pwritev($fd, [$buf1, ...], $offset, $flags)
$retval = glfs_lseek($fd, $offset, $whence)
$retval = glfs_truncate($fs, $path, $length)
$retval = glfs_ftruncate($fd, $length)
$retval = glfs_lstat($fs, $path, $stat)
$retval = glfs_stat($fs, $path, $stat)
$retval = glfs_fstat($fd, $stat)
$retval = glfs_fsync($fd)
$retval = glfs_fdatasync($fd)
$retval = glfs_access($fs, $path, $mode)
$retval = glfs_symlink($fs, $oldpath, $newpath)
$retval = glfs_readlink($fs, $path, $buf, $bufsz)
$retval = glfs_mknod($fs, $path, $mode, $dev)
$retval = glfs_mkdir($fs, $path, $mode)
$retval = glfs_unlink($fs, $path)
$retval = glfs_rmdir($fs, $path)
$retval = glfs_rename($fs, $oldpath, $newpath)
$retval = glfs_link($fs, $oldpath, $newpath)
$retval = glfs_opendir($fs, $path)
$retval = glfs_readdir_r($fd, $dirent, \$result)
$retval = glfs_readdirplus_r($fd, $stat, $dirent, \$result)
$dirent = glfs_readdir($fd)
$dirent = glfs_readdirplus($fd, $stat)
$retval = glfs_telldir($fd)
$retval = glfs_seekdir($fd, $offset)
$retval = glfs_closedir($fd)
$retval = glfs_statvfs($fs, $path, $statvfs)
$retval = glfs_chmod($fs, $path, $mode)
$retval = glfs_fchmod($fd, $mode)
$retval = glfs_chown($fs, $path, $uid, $gid)
$retval = glfs_lchown($fs, $path, $uid, $gid)
$retval = glfs_fchown($fd, $uid, $gid)
$retval = glfs_utimens($fs, $path, $timespecs)
$retval = glfs_ltimens($fs, $path, $timespecs)
$retval = glfs_ftimens($fd, $timespecs)
$retval = glfs_getxattr($fs, $path, $key, $value, $valsz)
$retval = glfs_lgetxattr($fs, $path, $key, $value, $valsz)
$retval = glfs_lgetxattr($fd, $key, $value, $valsz)
$retval = glfs_listxattr($fs, $path, $value, $valsz)
$retval = glfs_llistxattr($fs, $path, $value, $valsz)
$retval = glfs_flistxattr($fd, $value, $valsz)
$retval = glfs_setxattr($fs, $path, $key, $value, $valsz, $flags)
$retval = glfs_lsetxattr($fs, $path, $key, $value, $valsz, $flags)
$retval = glfs_fsetxattr($fd, $key, $value, $valsz, $flags)
$retval = glfs_removexttr($fd, $path, $key)
$retval = glfs_lremovexttr($fd, $path, $key)
$retval = glfs_fremovexttr($fs, $key)
$retval = glfs_fallocate($fd, $keepsz, $offset, $len)
$retval = glfs_discard($fd, $offset, $len)
$retval = glfs_zerofill($fd, $offset, $len)
$retval = glfs_getcwd($fs, $buf, $bufsz)
$retval = glfs_chdir($fs, $path)
$retval = glfs_fchdir($fd)
$retval = glfs_realpath($fs, $path, $resolved)
$retval = glfs_posix_lock($fd, $cmd, $flock)
$fd = glfs_dup($fd)
$retval = glfs_read_async($fd, $buf, $bufsz, $flags, $cbk, $data)
This function is not supported yet!
$retval = glfs_write_async($fd, $buf, $bufsz, $flags, $cbk, $data)
$retval = glfs_readv_async($fd, [$buf1, ...], $flags, $cbk, $data)
$retval = glfs_writev_async($fd, [$buf1, ...], $flags, $cbk, $data)
$retval = glfs_pread_async($fd, $buf, $bufsz, $offset, flags, $cbk, $data)
$retval = glfs_pwrite_async($fd, $buf, $bufsz, $offset, flags, $cbk, $data)
$retval = glfs_preadv_async($fd, [$buf1, ...], $offset, $flags, $cbk, $data)
$retval = glfs_pwritev_async($fd, [$buf1, ...], $offset, $flags, $cbk, $data)
$retval = glfs_ftruncate_async($fd, $length, $cbk, $data)
$retval = glfs_fsync_async($fd, $cbk, $data)
$retval = glfs_fdatasync_async($fd, $cbk, $data)
$retval = glfs_discard_async($fd, $offset, $len, $cbk, $data)
$retval = glfs_zerofill_async($fd, $offset, $len, $cbk, $data)
Ji-Hyeon Gim <potatogim@gluesys.com>
This software is copyright 2017-2018 by Ji-Hyeon Gim.
This is free software; you can redistribute it and/or modify it under the same terms as the GPLv2/LGPLv3.
To install GlusterFS::GFAPI::FFI::Stat, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GlusterFS::GFAPI::FFI::Stat
CPAN shell
perl -MCPAN -e shell install GlusterFS::GFAPI::FFI::Stat
For more information on module installation, please visit the detailed CPAN module installation guide.