1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

remove hardcoded pcie device id in pci.cpp

Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
Niklas Eiling 2022-12-20 14:29:36 +01:00 committed by Steffen Vogel
parent 8008346804
commit 1157ce2996

View file

@ -393,7 +393,14 @@ bool Device::attachDriver(const std::string &driver) const
bool Device::readHostBar(uint32_t &bar) const
{
unsigned long long start, end, size, flags;
FILE *file = fopen("/sys/bus/pci/devices/0000:88:00.0/resource", "r");
char *path = NULL;
if (asprintf(&path, "%s/bus/pci/devices/%04x:%02x:%02x.%x/resource", SYSFS_PATH,
slot.domain, slot.bus, slot.device, slot.function) == -1)
{
log->error("could not allocate memory for path");
return false;
}
FILE *file = fopen(path, "r");
if (!file)
{
log->error("error opening resource file");