Redesign VFS around handles
This commit is contained in:
21
ce/ce.c
21
ce/ce.c
@@ -72,16 +72,15 @@ static void cmd_cat (struct list_node_link* tokens) {
|
||||
struct list_node_link *token_link, *token_tmp_link;
|
||||
list_foreach (tokens, token_link, token_tmp_link) {
|
||||
struct token* token = list_entry (token_link, struct token, tokens_link);
|
||||
int ret;
|
||||
|
||||
ret = open (token->buffer);
|
||||
int handle = open (token->buffer);
|
||||
|
||||
if (ret < 0) {
|
||||
printf ("ERROR opening %s: %s\n", token->buffer, str_status[-ret]);
|
||||
if (handle < 0) {
|
||||
printf ("ERROR opening %s: %s\n", token->buffer, str_status[-handle]);
|
||||
continue;
|
||||
}
|
||||
|
||||
describe (token->buffer, &desc);
|
||||
describe (handle, &desc);
|
||||
|
||||
if (desc.type != FS_FILE)
|
||||
goto close1;
|
||||
@@ -92,21 +91,13 @@ static void cmd_cat (struct list_node_link* tokens) {
|
||||
goto close1;
|
||||
|
||||
memset (buffer, 0, desc.size + 1);
|
||||
|
||||
ret = read (token->buffer, 0, (uint8_t*)buffer, desc.size);
|
||||
|
||||
if (ret < 0) {
|
||||
printf ("ERROR reading%s: %s\n", token->buffer, str_status[-ret]);
|
||||
goto close1;
|
||||
}
|
||||
|
||||
read (handle, 0, (uint8_t*)buffer, desc.size);
|
||||
printf ("%s\n", buffer);
|
||||
|
||||
close1:
|
||||
if (buffer != NULL)
|
||||
free (buffer);
|
||||
|
||||
close (token->buffer);
|
||||
close (handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user