fixed fuse offset issue, but still haven't fixed the problem with written file length
This commit is contained in:
parent
c06287dd4d
commit
c2f3aa1310
@ -567,15 +567,13 @@ int FilesOperation::fischl_write(const char *path, const char *buf, size_t size,
|
||||
// return -ENOENT;
|
||||
// Caution! this based on content in file are multiple of IO_BLOCK_SIZE, not the exact write size.
|
||||
// based on current write_datablock API implement, when write_datablock pass with actual size not index this function should be fixed
|
||||
|
||||
INode_Data inode;
|
||||
// Assuming inode is correctly initialized here based on 'path'
|
||||
inode.inode_num = fi->fh;
|
||||
fs->inode_manager->load_inode(&inode);
|
||||
//size_t len = (inode.metadata.size/IO_BLOCK_SIZE) * IO_BLOCK_SIZE; // Assuming each block is 4096 bytes
|
||||
|
||||
char buffer[size];
|
||||
strcpy(buffer, buf);
|
||||
printf("received offset %d\n", offset);
|
||||
char *buffer = strdup(buf);
|
||||
size_t bytes_write = fs->write(&inode, buffer, size, offset);
|
||||
/*size_t block_index = offset / IO_BLOCK_SIZE; // Starting block index
|
||||
size_t block_offset = offset % IO_BLOCK_SIZE; // Offset within the first block
|
||||
@ -590,7 +588,6 @@ int FilesOperation::fischl_write(const char *path, const char *buf, size_t size,
|
||||
block_offset = 0; // Only the first block might have a non-zero offset
|
||||
}*/
|
||||
fs->inode_manager->save_inode(&inode);
|
||||
printf("received offset %llu\n", inode.metadata.size);
|
||||
return bytes_write; // Return the actual number of bytes read
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ static int fischl_read(const char* path, char *buf, size_t size, off_t offset, s
|
||||
}
|
||||
|
||||
static int fischl_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
|
||||
return options.fsop->fischl_write(path, buf, size, offset, fi);
|
||||
return options.fsop->fischl_write(path, buf, size, offset, fi);
|
||||
}
|
||||
|
||||
static int fischl_statfs(const char* path, struct statvfs* stbuf) {
|
||||
@ -213,7 +213,7 @@ int fischl(int argc, char *argv[])
|
||||
//const char* d = (argc < 2) ? "/dev/vdc" : argv[1];
|
||||
|
||||
//setupTestDirectory(&options.root);
|
||||
options.H = new FakeRawDisk(21504);
|
||||
options.H = new FakeRawDisk(23552);
|
||||
options.fs = new Fs(options.H);
|
||||
options.fs->format();
|
||||
options.fsop = new FilesOperation(*options.H, options.fs);
|
||||
|
@ -61,16 +61,13 @@ int Fs::sweep_datablocks(u_int64_t *block_num, int indirect_num,
|
||||
int err;
|
||||
int result = -1;
|
||||
|
||||
printf("SURVIVED 1\n");
|
||||
if (allocate && (*block_num) == 0)
|
||||
if ((err = datablock_manager->new_datablock(block_num)) < 0)
|
||||
return err;
|
||||
|
||||
printf("SURVIVED 2 %d\n", indirect_num);
|
||||
if (indirect_num == 0)
|
||||
return op->operation(*block_num);
|
||||
|
||||
printf("SURVIVED 3\n");
|
||||
if ((*block_num) == 0) {
|
||||
memset(buf, 0, sizeof(buf));
|
||||
} else {
|
||||
@ -104,11 +101,9 @@ int Fs::sweep_datablocks(u_int64_t *block_num, int indirect_num,
|
||||
if (result == 0)
|
||||
break;
|
||||
}
|
||||
printf("SURVIVED 4 %llu %d %llu\n", *block_num, result, this_layer_start_index);
|
||||
if (modified)
|
||||
if ((err = disk->write_block(*block_num, buf)) < 0)
|
||||
return err;
|
||||
printf("SURVIVED 5 %d\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user