Return version tags in directory listing

This commit is contained in:
2025-11-25 12:08:33 +01:00
parent afad13f44f
commit 0d099a1fa6
6 changed files with 16 additions and 1 deletions
+1
View File
@@ -85,6 +85,7 @@ int toasty_delete(ToastyFS *toasty, ToastyString path, ToastyVersionTag vtag);
typedef struct {
char name[128]; // TODO: Implement a proper name length
bool is_dir;
ToastyVersionTag vtag;
} ToastyListingEntry;
typedef struct {
+2 -1
View File
@@ -178,6 +178,7 @@ The following is the list of messages the Metadata Server may send to a Client:
When a client sends a LIST request to the metadata server and it succedes, the server replies with a LIST_SUCCESSS message with the following layout:
struct ListItem {
uint64_t gen;
uint8_t is_dir;
uint16_t name_len;
char name[name_len];
@@ -191,7 +192,7 @@ The following is the list of messages the Metadata Server may send to a Client:
ListItem items[item_count];
};
The gen field contains the generation counter for the directory.
The ListSuccessMessage gen field contains the generation counter for the directory, while the gen field in ListItem is the counter for that specific child.
If the truncated field is non-zero, the actual item count for this directory is greater than the one sent in the message.
+9
View File
@@ -950,6 +950,14 @@ static void process_event_for_list(ToastyFS *toasty,
// Parse each list item
for (uint32_t i = 0; i < item_count; i++) {
uint64_t gen;
if (!binary_read(&reader, &gen, sizeof(gen))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
sys_free(entities);
return;
}
uint8_t is_dir;
if (!binary_read(&reader, &is_dir, sizeof(is_dir))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
@@ -971,6 +979,7 @@ static void process_event_for_list(ToastyFS *toasty,
return;
}
entities[i].vtag = gen;
entities[i].is_dir = is_dir;
if (name_len > sizeof(entities[i].name)-1) {
+1
View File
@@ -257,6 +257,7 @@ int file_tree_list(FileTree *ft, string path,
items[i].name_len = name_cpy;
items[i].is_dir = c->is_dir;
items[i].gen = c->gen;
}
assert(e->gen != NO_GENERATION);
+1
View File
@@ -51,6 +51,7 @@ typedef struct {
char name[1<<8];
int name_len;
bool is_dir;
uint64_t gen;
} ListItem;
#define MAX_COMPS 32
+2
View File
@@ -362,6 +362,8 @@ process_client_list(MetadataServer *state, int conn_idx, ByteView msg)
for (int i = 0; i < ret && i < MAX_LIST_SIZE; i++) {
message_write(&writer, &items[i].gen, sizeof(items[i].gen));
uint8_t is_dir = items[i].is_dir;
message_write(&writer, &is_dir, sizeof(is_dir));