summaryrefslogtreecommitdiffstats
path: root/src/fuse/connection.h
blob: b22e3ce68c7bec640aefa76da0aca6da571dcddd (plain) (blame)
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
#ifndef _CONNECTION_H_
#define _CONNECTION_H_

#include <dnbd3/shared/fdsignal.h>
#include <dnbd3/shared/timing.h>
#include <stdatomic.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/socket.h>
#define FUSE_USE_VERSION 30
#include <fuse_lowlevel.h>



extern atomic_bool keepRunning;
struct _dnbd3_async;

typedef struct _dnbd3_async {
	struct _dnbd3_async *next; // Next in this linked list (provate field, not set by caller)
	ticks time;        // When request was put on wire, 0 if not measuring
	uint64_t offset;
	uint32_t length;
	fuse_req_t fuse_req;
} dnbd3_async_t;

typedef struct _dnbd3_async_parent {
	dnbd3_async_t request;
	char buffer[]; // Must be last member!
} dnbd3_async_parent_t;

bool connection_init( const char *hosts, const char *image, const uint16_t rid, const bool learnNewServers );

bool connection_initThreads();

uint64_t connection_getImageSize();

char * connection_getImageName();

uint16_t connection_getImageRID();

bool connection_read( dnbd3_async_t *request );

void connection_close();

void connection_join();

size_t connection_printStats( char *buffer, const size_t len );

#endif /* CONNECTION_H_ */