Tactility/Tactility/Source/MountPoints.cpp
Ken Van Hoeylandt 3fe1dc0312
Create hal-device module, fix GPIO, fix tests, fix TactilityC (#471)
* **New Features**
  * Added a HAL device module providing device enumeration, type queries and a HAL↔kernel bridge.

* **Improvements**
  * Integrated HAL module into startup; standardized module names, includes and lifecycle logging; safer file append behavior; broader build support.

* **API Changes**
  * Driver lifecycle now uses explicit add/remove semantics; C and HAL device type/lookup APIs clarified.

* **Chores**
  * Added module README and Apache‑2.0 license; updated build configuration to include the new module.

* **Fixes**
  * Updated tests and object file handling to behave correctly.
2026-02-01 01:05:16 +01:00

60 lines
1.6 KiB
C++

#include "Tactility/MountPoints.h"
#include "Tactility/TactilityConfig.h"
#include <tactility/hal/Device.h>
#include "Tactility/hal/sdcard/SdCardDevice.h"
#include <Tactility/file/File.h>
#include <cstring>
#include <vector>
#include <dirent.h>
namespace tt::file {
std::vector<dirent> getMountPoints() {
std::vector<dirent> dir_entries;
dir_entries.clear();
// Data partition
auto data_dirent = dirent{
.d_ino = 1,
.d_type = TT_DT_DIR,
.d_name = { 0 }
};
strcpy(data_dirent.d_name, DATA_PARTITION_NAME);
dir_entries.push_back(data_dirent);
// SD card partitions
auto sdcards = tt::hal::findDevices<hal::sdcard::SdCardDevice>(hal::Device::Type::SdCard);
for (auto& sdcard : sdcards) {
auto state = sdcard->getState();
if (state == hal::sdcard::SdCardDevice::State::Mounted) {
auto mount_name = sdcard->getMountPath().substr(1);
auto dir_entry = dirent {
.d_ino = 2,
.d_type = TT_DT_DIR,
.d_name = { 0 }
};
assert(mount_name.length() < sizeof(dirent::d_name));
strcpy(dir_entry.d_name, mount_name.c_str());
dir_entries.push_back(dir_entry);
}
}
if (config::SHOW_SYSTEM_PARTITION) {
// System partition
auto system_dirent = dirent{
.d_ino = 0,
.d_type = TT_DT_DIR,
.d_name = { 0 }
};
strcpy(system_dirent.d_name, SYSTEM_PARTITION_NAME);
dir_entries.push_back(system_dirent);
}
return dir_entries;
}
}