NAME

GlusterFS::GFAPI::FFI::File - GFAPI File API

SYNOPSIS

DESCRIPTION

ATTRIBUTES

fd

originalpath

mode

CONSTRUCTOR

new

options

METHODS

fileno

Return the internal file descriptor (glfd) that is used by the underlying implementation to request I/O operations.

mode

The I/O mode for the file. If the file was created using the Volume-fopen()> function, this will be the value of the mode parameter. This is a read-only attribute.

name

If the file object was created using Volume-fopen()>, the name of the file.

closed

Bool indicating the current state of the file object. This is a read-only attribute; the close() method changes the value.

close

Close the file. A closed file cannot be read or written any more.

discard

This is similar to UNMAP command that is used to return the unused/freed blocks back to the storage system. In this implementation, fallocate with FALLOC_FL_PUNCH_HOLE is used to eventually release the blocks to the filesystem. If the brick has been mounted with '-o discard' option, then the discard request will eventually reach the SCSI storage if the storage device supports UNMAP.

dup

Return a duplicate of File object. This duplicate File class instance encapsulates a duplicate glfd obtained by invoking glfs_dup().

fallocate

This is a Linux-specific sys call, unlike posix_fallocate()

Allows the caller to directly manipulate the allocated disk space for the file for the byte range starting at offset and continuing for length bytes.

fchmod

Change this file's mode

fchown

Change this file's owner and group id

fdatasync

Flush buffer cache pages pertaining to data, but not the ones pertaining to metadata.

fgetsize

Return the size of a file, as reported by fstat()

fgetxattr

Retrieve the value of the extended attribute identified by key for the file.

parameters

key

Key of extended attribute

size

If size is specified as zero, we first determine the size of xattr and then allocate a buffer accordingly. If size is non-zero, it is assumed the caller knows the size of xattr.

returns

Value of extended attribute corresponding to key specified.

flistxattr

Retrieve list of extended attributes for the file.

parameters

size

If size is specified as zero, we first determine the size of list and then allocate a buffer accordingly. If size is non-zero, it is assumed the caller knows the size of the list.

returns

List of extended attributes.

fsetxattr

Set extended attribute of file.

parameters

key

The key of extended attribute.

key

The valiue of extended attribute.

key

Possible values are 0 (default), 1 and 2.

If 0 - xattr will be created if it does not exist, or the value will be replaced if the xattr exists. If 1 - it performs a pure create, which fails if the named attribute already exists. If 2 - it performs a pure replace operation, which fails if the named attribute does not already exist.

fremovexattr

Remove a extended attribute of the file.

parameters

key

The key of extended attribute.

fstat

Returns Stat object for this file.

returns

Returns the stat information of the file.

fsync

Flush buffer cache pages pertaining to data and metadata.

ftruncate

Truncated the file to a size of length bytes.

If the file previously was larger than this size, the extra data is lost.

If the file previously was shorter, it is extended, and the extended part reads as null bytes.

parameters

length

Length to truncate the file to in bytes.

lseek

Set the read/write offset position of this file.

The new position is defined by pos relative to how

parameters

pos

sets new offset position according to 'how'

how

SEEK_SET - sets offset position pos bytes relative to beginning of file. SEEK_CUR - the position is set relative to the current position. SEEK_END - sets the position relative to the end of the file.

returns

the new offset position

read

Read at most size bytes from the file.

parameters

size

length of read buffer. If less than 0, then whole file is read. Default is -1.

returns

buffer of size length

readinto

Read up to len(buf) bytes into buf which must be a bytearray. This method is useful when you have to read a large file over multiple read calls. While read() allocates a buffer every time it's invoked, readinto() copies data to an already allocated buffer passed to it.

parameters

buf

returns

the number of bytes read (0 for EOF).

write

Write data to the file.

parameters

data

The data to be written to file.

returns

The size in bytes actually written

zerofill

Fill length number of bytes with zeroes starting from offset.

parameters

offset

Start at offset location

length

Size/length in bytes

BUGS

SEE ALSO

AUTHOR

Ji-Hyeon Gim <potatogim@gluesys.com>

COPYRIGHT AND LICENSE

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.