summaryrefslogtreecommitdiffstats
path: root/src/fuse/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fuse/main.c')
-rwxr-xr-xsrc/fuse/main.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/fuse/main.c b/src/fuse/main.c
index 5c2db34..ee52695 100755
--- a/src/fuse/main.c
+++ b/src/fuse/main.c
@@ -162,13 +162,13 @@ static int image_write(const char *path, char *buf, size_t size, off_t offset, s
if ( path[1] == STATS_PATH[1] ) {
return -EIO;
}
- if((((size_t)offset)+size) > imageSize){
- imageSize = ((size_t)offset)+size;
- writeImageSizeToFile((uint64_t)size);
+ if( ( ( ( size_t ) offset ) + size ) > imageSize ){
+ imageSize = ( ( size_t ) offset ) + size;
+ writeImageSizeToFile( imageSize );
}
- return write_cow(buf,size, offset);
+ return writeCow(buf,size, offset);
}
-int image_read_internal(char *buf,size_t size, off_t offset){
+int imageReadInternal(char *buf,size_t size, off_t offset){
dnbd3_async_t request;
request.buffer = buf;
request.length = (uint32_t)size;
@@ -232,7 +232,7 @@ static int image_read(const char *path, char *buf, size_t size, off_t offset, st
if(useCow){
return cow_read(buf, size, offset);
} else {
- return image_read_internal(buf,size,offset);
+ return imageReadInternal(buf,size,offset);
}
}
@@ -279,15 +279,7 @@ static void image_destroy(void *private_data UNUSED)
}
-static int image_truncate(const char *path, off_t size, struct fuse_file_info *fi UNUSED){
- if ( strcmp( path, IMAGE_PATH ) == 0 ) {
- imageSize=size;
- writeImageSizeToFile((uint64_t)size);
- return 0;
- }
- return -1;
-}
-static int image_ftruncate(const char *path, off_t size, struct fuse_file_info *fi UNUSED){
+static int image_truncate(const char *path, off_t size, struct fuse_file_info *fi UNUSED) {
if ( strcmp( path, IMAGE_PATH ) == 0 ) {
imageSize=size;
writeImageSizeToFile((uint64_t)size);
@@ -295,13 +287,16 @@ static int image_ftruncate(const char *path, off_t size, struct fuse_file_info *
}
return -1;
}
-static int image_flush(const char *path, struct fuse_file_info *fi UNUSED){
+
+static int image_flush(const char *path UNUSED, struct fuse_file_info *fi UNUSED) {
return 0;
}
-static int image_release(const char *path, struct fuse_file_info *fi UNUSED){
+static int image_release(const char *path UNUSED, struct fuse_file_info *fi UNUSED) {
return 0;
}
-
+static int image_create(const char *path UNUSED, mode_t mode UNUSED, struct fuse_file_info *fi UNUSED){
+ return -EPERM;
+}
@@ -322,16 +317,14 @@ static struct fuse_operations image_oper_cow = {
.read = image_read,
.init = image_init,
.destroy = image_destroy,
- .ftruncate = image_ftruncate,
.flush = image_flush,
.release = image_release,
.write = image_write,
- .truncate =image_truncate,
+ .truncate = image_truncate,
+ .create = image_create,
};
-void setImagesize(uint64_t size){
- imageSize = size;
-}
+
static void printVersion()
{
@@ -496,12 +489,16 @@ int main(int argc, char *argv[])
printf("Using Cow");
if(loadCow){
printf("Loading Cow");
- if(!load_cow_file(cow_path, imageSize)){
+ uint64_t cowSize = cow_loadFile(cow_path, imageSize);
+
+ if(cowSize == 0){
logadd( LOG_ERROR, "Could not load COW FIle. Bye.\n" );
return EXIT_FAILURE;
+ } else{
+ imageSize = cowSize;
}
} else {
- if(!create_cow_file(cow_path, image_Name, imageSize)){
+ if(!cow_createFile(cow_path, image_Name, imageSize)){
logadd( LOG_ERROR, "Could not create COW FIle. Bye.\n" );
return EXIT_FAILURE;
}