32 #ifndef Common_Filesystem_h
33 #define Common_Filesystem_h
49 #define HT_DIRECT_IO_ALIGNMENT 512
51 #define HT_IO_ALIGNED(size) \
52 (((size) % HT_DIRECT_IO_ALIGNMENT) == 0)
54 #define HT_IO_ALIGNMENT_PADDING(size) \
55 (HT_DIRECT_IO_ALIGNMENT - ((size) % HT_DIRECT_IO_ALIGNMENT))
86 OPEN_FLAG_DIRECTIO = 0x00000001,
87 OPEN_FLAG_OVERWRITE = 0x00000002,
88 OPEN_FLAG_VERIFY_CHECKSUM = 0x00000004
100 time_t last_modification_time {};
106 uint8_t encoding_version()
const override;
108 size_t encoded_length_internal()
const override;
110 void encode_internal(uint8_t **bufp)
const override;
112 void decode_internal(uint8_t version,
const uint8_t **bufp,
113 size_t *remainp)
override;
128 virtual void open(
const String &name, uint32_t flags,
137 virtual int open(
const String &name, uint32_t flags) = 0;
151 virtual int open_buffered(
const String &name, uint32_t flags,
152 uint32_t buf_size, uint32_t outstanding, uint64_t start_offset = 0,
153 uint64_t end_offset = 0) = 0;
158 virtual void decode_response_open(
EventPtr &event, int32_t *fd) = 0;
173 virtual void create(
const String &name, uint32_t flags, int32_t bufsz,
185 virtual int create(
const String &name, uint32_t flags, int32_t bufsz,
186 int32_t replication, int64_t blksz) = 0;
191 virtual void decode_response_create(
EventPtr &event, int32_t *fd) = 0;
210 virtual void close(
int fd) = 0;
236 virtual size_t read(
int fd,
void *dst,
size_t len) = 0;
243 virtual void decode_response_read(
EventPtr &event,
const void **buffer,
244 uint64_t *offset, uint32_t *length) = 0;
277 virtual void decode_response_append(
EventPtr &event, uint64_t *offset,
278 uint32_t *length) = 0;
289 virtual void seek(
int fd, uint64_t offset,
DispatchHandler *handler) = 0;
299 virtual void seek(
int fd, uint64_t offset) = 0;
316 virtual void remove(
const String &name,
bool force =
true) = 0;
327 virtual void length(
const String &name,
bool accurate,
337 virtual int64_t length(
const String &name,
bool accurate =
true) = 0;
342 virtual int64_t decode_response_length(
EventPtr &event) = 0;
356 virtual void pread(
int fd,
size_t amount, uint64_t offset,
372 virtual size_t pread(
int fd,
void *dst,
size_t len, uint64_t offset,
373 bool verify_checksum =
true) = 0;
380 virtual void decode_response_pread(
EventPtr &event,
const void **buffer,
381 uint64_t *offset, uint32_t *length) = 0;
398 virtual void mkdirs(
const String &name) = 0;
415 virtual void rmdir(
const String &name,
bool force =
true) = 0;
432 virtual void readdir(
const String &name, std::vector<Dirent> &listing) = 0;
437 virtual void decode_response_readdir(
EventPtr &event,
438 std::vector<Dirent> &listing) = 0;
463 virtual void flush(
int fd) = 0;
472 virtual void sync(
int fd) = 0;
488 virtual bool exists(
const String &name) = 0;
493 virtual bool decode_response_exists(
EventPtr &event) = 0;
500 virtual void rename(
const String &src,
const String &dst,
508 virtual void rename(
const String &src,
const String &dst) = 0;
526 static int decode_response(
EventPtr &event);
533 virtual void debug(int32_t command,
542 virtual void debug(int32_t command,
StaticBuffer &serialized_parameters,
556 static String dirname(
String name,
char separator =
'/');
568 static String basename(
String name,
char separator =
'/');
576 return lhs.
name.compare(rhs.
name) < 0;
590 #endif // Common_Filesystem_h
A memory buffer of static size.
static PyObject * convert(const SerializedCellsWriter &scw)
Holds Nagios-style program status information.
std::string String
A String is simply a typedef to std::string.
Abstract base class for application dispatch handlers registered with AsyncComm.
Flags
Enumeration type for append flags.
Po::typed_value< String > * str(String *v=0)
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
bool operator<(const Filesystem::Dirent &lhs, const Filesystem::Dirent &rhs)
Declarations for DispatchHandler.
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
A timer class to keep timeout states across AsyncComm related calls.
A memory buffer of static size.
Declarations for Serializable.
Flags
Enumeration for poll interest constants.
Mixin class that provides a standard serialization interface.
std::shared_ptr< Filesystem > FilesystemPtr
Smart pointer to Filesystem.
String name
File or directory name.
A timer class to keep timeout states across AsyncComm related calls.
A String class based on std::string.
Abstract base class for a filesystem.