summaryrefslogtreecommitdiffstats
path: root/src/fuse/cow.h
blob: 78cc3ef89aed329172a1209ae18823d8d9d8ab1c (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
51
/*
 * cow.h
 *
 *  Created on: 22.08.2018
 *      Author: Michael Scherle
 */

#ifndef COW_H_
#define COW_H_
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "../shared/fdsignal.h"

typedef struct cow_request{
	struct cow_request *next;
	off_t offset;
	off_t end;
	struct cow_request *dependencies[6];
	struct cow_request *myDependencies[6];
	dnbd3_signal_t* signal;
} cow_request;

typedef struct {
	uint32_t version;
	uint64_t imageSize;
	uint32_t nameLenght;
	uint32_t pageSize;
} cow_metadata;

uint64_t cow_init(char *cow_path, char *image_Name, uint64_t imageSize, bool overWrite);
uint64_t createFile(char *cow_path, char *image_Name,uint64_t imageSize);
bool createBigBlock(unsigned long id);
int cow_read(char *buf, size_t size, off_t offset);
int cow_write(const char *data, size_t size, off_t offset);
uint64_t loadFile( char *cow_path,char *image_Name, uint64_t imageSize );
void cow_writeImageSizeToFile(uint64_t size);
int readBigBlock(long bigBlockId ,char *buf,size_t size, off_t offset);
void onClose();
cow_request getAccess(off_t offset,size_t size);
void closeAcccess(cow_request *request);
int write_cow(const char *data, size_t size, off_t offset);
int writeToBigBlock(unsigned long bigBlockId,const char *data, off_t offset,size_t size);
int getSmallBlockId(off_t offset);

void test();

#endif /* COW_H_ */