-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
27 lines (21 loc) · 725 Bytes
/
Copy pathmain.cpp
File metadata and controls
27 lines (21 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <cstring>
#include "ext4/context.h"
#include "shell/shell.h"
int main(int argc, char* argv[]) {
if (argc < 2) {
std::cerr << "Uso: " << argv[0] << " <nome da imagem>" << std::endl;
return 1;
}
ext4_context ctx;
if (ext4_context_init(&ctx, argv[1]) != 0) {
std::cerr << "Falha ao carregar a imagem do sistema de arquivos. (precisa ser um arquivo EXT4 válido)" << std::endl;
return 1;
}
// Extrai só o nome do arquivo para o prompt
const char* image_name = strrchr(argv[1], '/');
image_name = (image_name != nullptr) ? image_name + 1 : argv[1];
shell_run(&ctx, image_name);
ext4_context_destroy(&ctx);
return 0;
}