Main Page | Data Structures | File List | Data Fields | Globals

ioclient-posix.h File Reference

#include "glite/data/io/client/iotypes.h"
#include <unistd.h>
#include <fcntl.h>

Go to the source code of this file.

Functions

int glite_posix_open (const char *pathname, int flags, mode_t mode)
 Open a Remote File.

int glite_posix_creat (const char *pathname, mode_t mode)
 Create a Remote File.

ssize_t glite_posix_read (int fd, void *buf, size_t count)
 Read up to count bytes from file descriptor fd into the buffer starting at buf.

ssize_t glite_posix_write (int fd, const void *buf, size_t count)
 Writes up to count bytes to the file referenced by the file descriptor fd from the buffer starting at buf.

off_t glite_posix_lseek (int fd, off_t offset, int whence)
 Set a file read/write pointer.

off64_t glite_posix_lseek64 (int fd, off64_t offset, int whence)
 Set a file read/write pointer.

int glite_posix_fstat (int fd, struct stat *buf)
 Return information about the specified file.

int glite_posix_fstat64 (int fd, struct stat64 *buf)
 Return information about the specified file.

int glite_posix_close (int fd)
 Close the file.

int glite_posix_unlink (const char *pathname)
 Deletes a file on the remote Storage element.

glite_handle glite_filehandle (int fd)
 Returns the file handle associated with the descriptor.


Variables

int glite_posix_errno
 Number of last error.


Function Documentation

glite_handle glite_filehandle int  fd  ) 
 

Returns the file handle associated with the descriptor.

The returned handle could be used to call glite-io non-posix methods (like glite_fstat), but calling glite_close on a file opened with glite_posix_open may cause an impredictable behavior, so should be avoided in any case

Parameters:
fd [IN] the file descriptor returned by a previos glite_posix_open or glite_posix_creat call
Returns:
On success, the associated file handle if success. On error, GLITE_NULL_HANDLE is returned

int glite_posix_close int  fd  ) 
 

Close the file.

Parameters:
fd [IN] the file descriptor returned by a previos glite_posix_open or glite_posix_creat call
Returns:
On success, zero is returned. On error, -1 is returned, and glite_posix_errno is set appropriately

int glite_posix_creat const char *  pathname,
mode_t  mode
 

Create a Remote File.

This call is equivalent to glite_posix_open(pathname, O_CREAT, mode)

Parameters:
pathname [IN] the name of the remote file to open. It could be in the format lfn://<file_name> or guid:<file_guid>. glite_creat also accept the file name without the prefix: In that case if file_name starts with a '/' is interpreted as an LFN; otherwise if it's a valid GUID string representation, it's interpreted as a GUID
mode [IN] specifies what permissions the file has when it is created
Returns:
On success, the new file descriptor. On error, -1 is returned, and glite_posix_errno is set appropriately

int glite_posix_fstat int  fd,
struct stat *  buf
 

Return information about the specified file.

Parameters:
fd [IN] the file descriptor returned by a previos glite_posix_open or glite_posix_creat call
buf [OUT] pointer to a stat structure, as defined in <sys/stat.h>, into which information is placed concerning the file
Returns:
On success, zero is returned. On error, -1 is returned, and glite_posix_errno is set appropriately

int glite_posix_fstat64 int  fd,
struct stat64 *  buf
 

Return information about the specified file.

To be used for large files

Parameters:
fd [IN] the file descriptor returned by a previos glite_posix_open or glite_posix_creat call
buf [OUT] pointer to a stat structure, as defined in <sys/stat.h>, into which information is placed concerning the file
Returns:
On success, zero is returned. On error, -1 is returned, and glite_posix_errno is set appropriately

off_t glite_posix_lseek int  fd,
off_t  offset,
int  whence
 

Set a file read/write pointer.

Parameters:
fd [IN] the file descriptor returned by a previos glite_posix_open or glite_posix_creat call
offset [IN] new byte offset to seek to
whence [IN] relative file position. it can be one of the following values:
SEEK_SET - set to offset
SEEK_CUR - set to current position plus offset
SEEK_END - set to the size of the file plus offset
Returns:
the resulting offset location as measured in bytes from the beginning of the file. Otherwise, a value of (off_t)-1 is returned and glite_posix_errno is set to indicate the error

off64_t glite_posix_lseek64 int  fd,
off64_t  offset,
int  whence
 

Set a file read/write pointer.

Parameters:
fd [IN] the file descriptor returned by a previos glite_posix_open or glite_posix_creat call
offset [IN] new byte offset to seek to
whence [IN] relative file position. it can be one of the following values:
SEEK_SET - set to offset
SEEK_CUR - set to current position plus offset
SEEK_END - set to the size of the file plus offset
Returns:
the resulting offset location as measured in bytes from the beginning of the file. Otherwise, a value of (off64_t)-1 is returned and glite_posix_errno is set to indicate the error

int glite_posix_open const char *  pathname,
int  flags,
mode_t  mode
 

Open a Remote File.

Parameters:
pathname [IN] the name of the remote file to open. It could be in the format lfn://<file_name> or guid:<file_guid>. glite_open also accept the file name without the prefix: In that case if file_name starts with a '/' is interpreted as an LFN; otherwise if it's a valid GUID string representation, it's interpreted as a GUID
flags [IN] the requested access flag. The value should be a the bitwise inclusive-OR of values from the following lists:
O_RDONLY - open for reading only
O_WRONLY - open for writing only
O_CREAT - create a file
mode [IN] specifies what permissions the file has when it is created
Returns:
On success, the new file descriptor. On error, -1 is returned, and glite_posix_errno is set appropriately

ssize_t glite_posix_read int  fd,
void *  buf,
size_t  count
 

Read up to count bytes from file descriptor fd into the buffer starting at buf.

Parameters:
fd [IN] the file descriptor returned by a previos glite_posix_open call
buf [IN] the buffer where to store the data
count [IN] the number of byte to read. This parameter should be equal or less the size of the buffer
Returns:
On success, the number of bytes read is returned (zero indicates end of file), and the file position is advanced by this number. On error, -1 is returned, and glite_posix_errno is set appropriately

int glite_posix_unlink const char *  pathname  ) 
 

Deletes a file on the remote Storage element.

That replica information will be removed from the Logical File System and an attempt is made to remove the physical instance, but if that fails no error are returned. In case that replica is the last one, also the file logical name and GUID will be removed, so they can be reused later TODO Define GLite Error Codes (now the aiod ones are used)

Parameters:
pathname [IN] the name of the remote file to delete. It could be in the format lfn://<file_name> or guid:<file_guid>. glite_creat also accept the file name without the prefix: In that case if file_name starts with a '/' is interpreted as an LFN; otherwise if it's a valid GUID string representation, it's interpreted as a GUID
Returns:
On success, zero is returned. On error, -1 is returned, and glite_posix_errno is set appropriately

ssize_t glite_posix_write int  fd,
const void *  buf,
size_t  count
 

Writes up to count bytes to the file referenced by the file descriptor fd from the buffer starting at buf.

Parameters:
fd [IN] the file descriptor returned by a previos glite_posix_open or glite_posix_creat call
buf [IN] the buffer containing the data to be written
count [IN] the number of byte to write. This parameter should be equal or less the size of the buffer
Returns:
On success, the number of bytes written are returned (zero indicates nothing was written). On error, -1 is returned, and glite_posix_errno is set appropriately.


Variable Documentation

int glite_posix_errno
 

Number of last error.

Be aware that is not thread safe !

Definition at line 181 of file ioclient-posix.h.

The GLite Project. All rights reserved.