summaryrefslogtreecommitdiffstats
path: root/src/fuse/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fuse/main.c')
-rwxr-xr-xsrc/fuse/main.c37
1 files changed, 13 insertions, 24 deletions
diff --git a/src/fuse/main.c b/src/fuse/main.c
index ee52695..89e1695 100755
--- a/src/fuse/main.c
+++ b/src/fuse/main.c
@@ -156,17 +156,16 @@ static int fillStatsFile(char *buf, size_t size, off_t offset) {
memcpy( buf, buffer + offset, len );
return len;
}
-
-static int image_write(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi UNUSED)
+static int image_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi UNUSED)
{
if ( path[1] == STATS_PATH[1] ) {
return -EIO;
}
if( ( ( ( size_t ) offset ) + size ) > imageSize ){
imageSize = ( ( size_t ) offset ) + size;
- writeImageSizeToFile( imageSize );
+ cow_writeImageSizeToFile( imageSize );
}
- return writeCow(buf,size, offset);
+ return cow_write(buf,size, offset);
}
int imageReadInternal(char *buf,size_t size, off_t offset){
dnbd3_async_t request;
@@ -279,10 +278,10 @@ static void image_destroy(void *private_data UNUSED)
}
-static int image_truncate(const char *path, off_t size, struct fuse_file_info *fi UNUSED) {
+static int image_truncate(const char *path, off_t size) {
if ( strcmp( path, IMAGE_PATH ) == 0 ) {
- imageSize=size;
- writeImageSizeToFile((uint64_t)size);
+ imageSize = size;
+ cow_writeImageSizeToFile((uint64_t)size);
return 0;
}
return -1;
@@ -345,7 +344,7 @@ static void printUsage(char *argv0, int exitCode)
printf( " -l --log Write log to given location\n" );
printf( " -o --option Mount options to pass to libfuse\n" );
printf( " -d --debug Don't fork and print debug output (fuse > stderr, dnbd3 > stdout)\n" );
- printf( " -c --cow Path where the cow file should be created");
+ printf( " -c --cow Path where the cow file should be created. Use -z to overwrite existing cow files.\n");
fuse_main( 2, arg, &dnbd3_fuse_no_operations, NULL );
exit( exitCode );
}
@@ -374,7 +373,7 @@ int main(int argc, char *argv[])
int newArgc;
int opt, lidx;
bool testOpt = false;
- bool loadCow = false;
+ bool overWrite = false;
if ( argc <= 1 || strcmp( argv[1], "--help" ) == 0 || strcmp( argv[1], "--usage" ) == 0 ) {
printUsage( argv[0], 0 );
@@ -443,7 +442,7 @@ int main(int argc, char *argv[])
useCow=true;
break;
case 'z':
- loadCow = true;
+ overWrite = true;
break;
default:
printUsage( argv[0], EXIT_FAILURE );
@@ -487,21 +486,11 @@ int main(int argc, char *argv[])
}
if(useCow){
printf("Using Cow");
- if(loadCow){
- printf("Loading Cow");
- 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;
- }
+ uint64_t cowSize = cow_init(cow_path, image_Name, imageSize,overWrite);
+ if(cowSize == 0){
+ return EXIT_FAILURE;
} else {
- if(!cow_createFile(cow_path, image_Name, imageSize)){
- logadd( LOG_ERROR, "Could not create COW FIle. Bye.\n" );
- return EXIT_FAILURE;
- }
+ imageSize = cowSize;
}
}
// Since dnbd3 is always read only and the remote image will not change