Prepare mount for more features

This commit is contained in:
Baptiste Wicht 2016-08-14 22:12:37 +02:00
parent 4f3fb72f1a
commit 106f53d9d3

View File

@ -13,36 +13,59 @@
static constexpr const size_t BUFFER_SIZE = 4096; static constexpr const size_t BUFFER_SIZE = 4096;
int main(int, char*[]){ int main(int argc, char* argv[]){
//TODO Add support to mount new directories if(argc == 1){
auto buffer = new char[BUFFER_SIZE];
auto buffer = new char[BUFFER_SIZE]; auto mp_result = mounts(buffer, BUFFER_SIZE);
auto mp_result = mounts(buffer, BUFFER_SIZE); if(mp_result.valid()){
size_t position = 0;
if(mp_result.valid()){ while(true){
size_t position = 0; auto entry = reinterpret_cast<mount_point*>(buffer + position);
while(true){ auto mount_point = &entry->name;
auto entry = reinterpret_cast<mount_point*>(buffer + position); auto device = mount_point + entry->length_mp + 1;
auto type = device + entry->length_dev + 1;
auto mount_point = &entry->name; printf("%s %s %s\n", mount_point, device, type);
auto device = mount_point + entry->length_mp + 1;
auto type = device + entry->length_dev + 1;
printf("%s %s %s\n", mount_point, device, type); if(!entry->offset_next){
break;
}
if(!entry->offset_next){ position += entry->offset_next;
break;
} }
} else {
position += entry->offset_next; printf("mount: error: %s\n", std::error_message(mp_result.error()));
} }
} else {
printf("mount: error: %s\n", std::error_message(mp_result.error())); delete[] buffer;
exit(0);
} }
delete[] buffer; if(argc < 4){
printf("usage: mount fs device mountpoint\n");
exit(1);
}
auto fs_str = argv[1];
auto device_str = argv[2];
auto mount_point_str = argv[3];
std::string fs(fs_str);
if(fs == "fat32"){
printf("mkfs: Mounting %s fat32 filesystem on %s\n", mount_point_str, device_str);
//TODO Mount new directory
} else {
printf("mkfs: Unsupported filesystem %s\n", fs_str);
exit(1);
}
exit(0); exit(0);
} }