Return version tags in directory listing
This commit is contained in:
@@ -85,6 +85,7 @@ int toasty_delete(ToastyFS *toasty, ToastyString path, ToastyVersionTag vtag);
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
char name[128]; // TODO: Implement a proper name length
|
char name[128]; // TODO: Implement a proper name length
|
||||||
bool is_dir;
|
bool is_dir;
|
||||||
|
ToastyVersionTag vtag;
|
||||||
} ToastyListingEntry;
|
} ToastyListingEntry;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
+2
-1
@@ -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:
|
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 {
|
struct ListItem {
|
||||||
|
uint64_t gen;
|
||||||
uint8_t is_dir;
|
uint8_t is_dir;
|
||||||
uint16_t name_len;
|
uint16_t name_len;
|
||||||
char name[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];
|
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.
|
If the truncated field is non-zero, the actual item count for this directory is greater than the one sent in the message.
|
||||||
|
|
||||||
|
|||||||
@@ -950,6 +950,14 @@ static void process_event_for_list(ToastyFS *toasty,
|
|||||||
|
|
||||||
// Parse each list item
|
// Parse each list item
|
||||||
for (uint32_t i = 0; i < item_count; i++) {
|
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;
|
uint8_t is_dir;
|
||||||
if (!binary_read(&reader, &is_dir, sizeof(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 };
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entities[i].vtag = gen;
|
||||||
entities[i].is_dir = is_dir;
|
entities[i].is_dir = is_dir;
|
||||||
|
|
||||||
if (name_len > sizeof(entities[i].name)-1) {
|
if (name_len > sizeof(entities[i].name)-1) {
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ int file_tree_list(FileTree *ft, string path,
|
|||||||
|
|
||||||
items[i].name_len = name_cpy;
|
items[i].name_len = name_cpy;
|
||||||
items[i].is_dir = c->is_dir;
|
items[i].is_dir = c->is_dir;
|
||||||
|
items[i].gen = c->gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(e->gen != NO_GENERATION);
|
assert(e->gen != NO_GENERATION);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ typedef struct {
|
|||||||
char name[1<<8];
|
char name[1<<8];
|
||||||
int name_len;
|
int name_len;
|
||||||
bool is_dir;
|
bool is_dir;
|
||||||
|
uint64_t gen;
|
||||||
} ListItem;
|
} ListItem;
|
||||||
|
|
||||||
#define MAX_COMPS 32
|
#define MAX_COMPS 32
|
||||||
|
|||||||
@@ -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++) {
|
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;
|
uint8_t is_dir = items[i].is_dir;
|
||||||
message_write(&writer, &is_dir, sizeof(is_dir));
|
message_write(&writer, &is_dir, sizeof(is_dir));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user