1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef __DADA_DISK_ARRAY_H
#define __DADA_DISK_ARRAY_H
/* ************************************************************************
************************************************************************ */
#include <pthread.h>
#include <sys/types.h>
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
dev_t device;
char* path;
unsigned long f_bsize; /* file system block size */
} disk_t;
typedef struct {
disk_t* disks; /* disks to which data will be written */
unsigned ndisk; /* number of disks */
uint64_t space; /* number of bytes total */
char overwrite; /* when set, allow data file to be over-written */
/* for multi-threaded use of the dbdisk struct */
pthread_mutex_t mutex;
} disk_array_t;
/*! Create a new disk array */
disk_array_t* disk_array_create ();
/*! Destroy a disk array */
int disk_array_destroy (disk_array_t*);
/*! Add a disk to the array */
int disk_array_add (disk_array_t*, char* path);
/*! Enable/disable file overwriting */
int disk_array_set_overwrite (disk_array_t* array, char value);
/*! Open a file on the disk array, return the open file descriptor */
int disk_array_open (disk_array_t*, char* name, uint64_t size, uint64_t* bs, int add_flags);
/*! Close a file, reopen it and seek to the end of the file */
int disk_array_reopen (disk_array_t* array, int curr_fd, char* filename);
/*! Get the total amount of disk space */
uint64_t disk_array_get_total (disk_array_t*);
/*! Get the available amount of disk space */
uint64_t disk_array_get_available (disk_array_t*);
#ifdef __cplusplus
}
#endif
#endif