Track actual bytes read in read operations
Add functionality to determine the actual number of bytes read during read operations, making it possible to detect when a read was truncated because it went past the end of the file. Changes: - Modified file_tree_read() to calculate and return actual_bytes via new output parameter - Updated metadata server to send actual_bytes in READ_SUCCESS messages - Added bytes_read field to ToastyResult structure - Modified client to parse, store, and report actual bytes read - Updated toasty_read() to return the actual number of bytes read instead of always returning 0 - Fixed web server to use bytes_read field instead of non-existent count field This allows clients to distinguish between: - Reading zeros because the file is sparse (has holes) - Reading past the end of the file (truncated read)
This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ int file_tree_list (FileTree *ft, string path, ListItem *items, int
|
||||
int file_tree_create_entity (FileTree *ft, string path, bool is_dir, uint64_t chunk_size);
|
||||
int file_tree_delete_entity (FileTree *ft, string path);
|
||||
int file_tree_write (FileTree *ft, string path, uint64_t off, uint64_t len, uint32_t num_chunks, uint32_t chunk_size, SHA256 *prev_hashes, SHA256 *hashes, SHA256 *removed_hashes, int *num_removed);
|
||||
int file_tree_read (FileTree *ft, string path, uint64_t off, uint64_t len, uint64_t *chunk_size, SHA256 *hashes, int max_hashes);
|
||||
int file_tree_read (FileTree *ft, string path, uint64_t off, uint64_t len, uint64_t *chunk_size, SHA256 *hashes, int max_hashes, uint64_t *actual_bytes);
|
||||
string file_tree_strerror (int code);
|
||||
int file_tree_serialize (FileTree *ft, int (*flush_fn)(char*,int,void*), void *flush_data);
|
||||
int file_tree_deserialize (FileTree *ft, int (*read_fn)(char*,int,void*), void *read_data);
|
||||
|
||||
Reference in New Issue
Block a user