#include <aegis_storage.h>
Public Member Functions | |
virtual | ~p_file () |
Destructor. | |
virtual bool | p_open (int flags) |
Open file. | |
virtual ssize_t | p_read (foff_t at, RAWDATA_PTR data, size_t len) |
Read data from a file. | |
virtual ssize_t | p_write (foff_t at, const RAWDATA_PTR data, size_t len) |
Write data to a file. | |
virtual int | p_trunc (foff_t at) |
Truncate the file. | |
virtual void | p_close () |
Close the file. | |
bool | is_open () |
Is the file currently open. | |
virtual int | p_stat (struct stat *st) |
Get file status. | |
virtual const char * | digest () |
Get the digest of the file. | |
const char * | name () |
The name shown to outside. | |
storage * | owner () |
Return a pointer to the owning pstore. | |
virtual int | p_rename (const char *new_name) |
Rename the file. | |
virtual int | p_chmod (mode_t flags) |
Change mode flags. | |
virtual int | p_chown (uid_t uid, gid_t gid) |
Change ownership. | |
virtual int | p_utime (struct utimbuf *ntime) |
Change access times. | |
void | p_rollback (void) |
Forget pending changes. | |
Friends | |
class | storage |
class | pe_file |
class | storage_lock |
Implements the usual POSIX semantics of open, close, read and write.
virtual aegis::p_file::~p_file | ( | ) | [virtual] |
Destructor.
Notice that the constructor of this class is private, i.e. a p_file instance can only be created by function storage::member.
virtual bool aegis::p_file::p_open | ( | int | flags | ) | [virtual] |
Open file.
flags | (in) as in man(2) open, flags plus O_RECOVER |
virtual ssize_t aegis::p_file::p_read | ( | foff_t | at, | |
RAWDATA_PTR | data, | |||
size_t | len | |||
) | [virtual] |
Read data from a file.
at | (in) The offset from which to read | |
data | (in) The buffer to copy read data | |
len | (in) The number of bytes to read |
virtual ssize_t aegis::p_file::p_write | ( | foff_t | at, | |
const RAWDATA_PTR | data, | |||
size_t | len | |||
) | [virtual] |
Write data to a file.
at | (in) The offset to which to write | |
data | (in) A pointer to the buffer to write from | |
len | (in) Number of bytes to write |
virtual int aegis::p_file::p_trunc | ( | foff_t | at | ) | [virtual] |
Truncate the file.
at | (in) The new size of the file |
virtual void aegis::p_file::p_close | ( | ) | [virtual] |
Close the file.
The contents of the file are flushed to the disk and if it was opened with O_CREAT or O_TRUNC, its size is set to the last written byte offset. Also a O_RDWR file grows if data was written beoynd its original size.
bool aegis::p_file::is_open | ( | ) |
Is the file currently open.
virtual int aegis::p_file::p_stat | ( | struct stat * | st | ) | [virtual] |
Get file status.
st | (in,out) A pointer to the status buffer |
virtual const char* aegis::p_file::digest | ( | ) | [virtual] |
Get the digest of the file.
const char* aegis::p_file::name | ( | ) |
The name shown to outside.
storage* aegis::p_file::owner | ( | ) |
Return a pointer to the owning pstore.
virtual int aegis::p_file::p_rename | ( | const char * | new_name | ) | [virtual] |
Rename the file.
new_name | (in) The new name |
virtual int aegis::p_file::p_chmod | ( | mode_t | flags | ) | [virtual] |
Change mode flags.
flags | (in) new value of mode flags |
virtual int aegis::p_file::p_chown | ( | uid_t | uid, | |
gid_t | gid | |||
) | [virtual] |
Change ownership.
uid | (in) new file owner uid | |
gid | (in) new group owner gid |
virtual int aegis::p_file::p_utime | ( | struct utimbuf * | ntime | ) | [virtual] |
Change access times.
ntime | (in) new access and modification times |
void aegis::p_file::p_rollback | ( | void | ) |
Forget pending changes.
This function only has effect if the called instance is opened for writing. It changes the open mode as read only to prevent committing any changes in the protected store when the file is closed. Any changes already made will not be rolled back in the current implementation, however. The main use of this function is to discard pending changes when a file is removed from the storage while it was still open.