mirror of
https://github.com/clearlinux/graphene.git
synced 2026-10-03 23:48:19 +00:00
[LibOS] Replace hardcoded paths with manifest-supplied parameters
This commit is contained in:
@@ -134,11 +134,13 @@ size_t shim_do_write (int fd, const void * buf, size_t count)
|
||||
int shim_do_open (const char * file, int flags, mode_t mode)
|
||||
{
|
||||
if (strlen(file) >= 15 && strpartcmp_static(file, "/sys/class/fpga")) {
|
||||
char hardlink[128] = {'\0'};
|
||||
strcpy_static(hardlink, "/sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/fpga/", sizeof(hardlink));
|
||||
memcpy(hardlink + strlen(hardlink), file + 15, strlen(file) - 15);
|
||||
file = hardlink;
|
||||
debug("[FPGA DEMO] opening hardlink file: %s\n", file);
|
||||
//char hardlink[128] = {'\0'};
|
||||
//strcpy_static(hardlink, "/sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/fpga/", sizeof(hardlink));
|
||||
char devicepath[CONFIG_MAX] = {'\0'};
|
||||
get_config(root_config, "fpga.devicepath", devicepath, sizeof(devicepath));
|
||||
memcpy(devicepath + strlen(devicepath), file + 15, strlen(file) - 15);
|
||||
file = devicepath;
|
||||
debug("[FPGA DEMO] opening devicepath file: %s\n", file);
|
||||
}
|
||||
|
||||
if (!file || test_user_string(file))
|
||||
|
||||
@@ -33,11 +33,13 @@
|
||||
int shim_do_stat (const char * file, struct stat * stat)
|
||||
{
|
||||
if (strlen(file) >= 15 && strpartcmp_static(file, "/sys/class/fpga")) {
|
||||
char hardlink[128] = {'\0'};
|
||||
strcpy_static(hardlink, "/sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/fpga/", sizeof(hardlink));
|
||||
memcpy(hardlink + strlen(hardlink), file + 15, strlen(file) - 15);
|
||||
file = hardlink;
|
||||
debug("[FPGA DEMO] stating hardlink file: %s\n", file);
|
||||
//char hardlink[128] = {'\0'};
|
||||
//strcpy_static(hardlink, "/sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/fpga/", sizeof(hardlink));
|
||||
char devicepath[CONFIG_MAX] = {'\0'};
|
||||
get_config(root_config, "fpga.devicepath", devicepath, sizeof(devicepath));
|
||||
memcpy(devicepath + strlen(devicepath), file + 15, strlen(file) - 15);
|
||||
file = devicepath;
|
||||
debug("[FPGA DEMO] stating devicepath file: %s\n", file);
|
||||
}
|
||||
|
||||
if (!file || test_user_string(file))
|
||||
@@ -69,11 +71,13 @@ out:
|
||||
int shim_do_lstat (const char * file, struct stat * stat)
|
||||
{
|
||||
if (strlen(file) >= 15 && strpartcmp_static(file, "/sys/class/fpga")) {
|
||||
char hardlink[128] = {'\0'};
|
||||
strcpy_static(hardlink, "/sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/fpga/", sizeof(hardlink));
|
||||
memcpy(hardlink + strlen(hardlink), file + 15, strlen(file) - 15);
|
||||
file = hardlink;
|
||||
debug("[FPGA DEMO] stating hardlink file: %s\n", file);
|
||||
//char hardlink[128] = {'\0'};
|
||||
//strcpy_static(hardlink, "/sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/fpga/", sizeof(hardlink));
|
||||
char devicepath[CONFIG_MAX] = {'\0'};
|
||||
get_config(root_config, "fpga.devicepath", devicepath, sizeof(devicepath));
|
||||
memcpy(devicepath + strlen(devicepath), file + 15, strlen(file) - 15);
|
||||
file = devicepath;
|
||||
debug("[FPGA DEMO] stating devicepath file: %s\n", file);
|
||||
}
|
||||
|
||||
if (!file || test_user_string(file))
|
||||
@@ -135,11 +139,13 @@ int shim_do_readlink (const char * file, char * buf, size_t bufsize)
|
||||
return -EINVAL;
|
||||
|
||||
if (strlen(file) >= 15 && strpartcmp_static(file, "/sys/class/fpga")) {
|
||||
char hardlink[128] = {'\0'};
|
||||
strcpy_static(hardlink, "/sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/fpga/", sizeof(hardlink));
|
||||
memcpy(hardlink + strlen(hardlink), file + 15, strlen(file) - 15);
|
||||
memcpy(buf, hardlink, strlen(hardlink));
|
||||
return strlen(hardlink);
|
||||
//char hardlink[128] = {'\0'};
|
||||
//strcpy_static(hardlink, "/sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/fpga/", sizeof(hardlink));
|
||||
char devicepath[CONFIG_MAX] = {'\0'};
|
||||
get_config(root_config, "fpga.devicepath", devicepath, sizeof(devicepath));
|
||||
memcpy(devicepath + strlen(devicepath), file + 15, strlen(file) - 15);
|
||||
memcpy(buf, devicepath, strlen(devicepath));
|
||||
return strlen(devicepath);
|
||||
}
|
||||
|
||||
int ret;
|
||||
|
||||
+1
-1
Submodule LibOS/shim/test/apps updated: c8c086b2fe...72698c8cbd
Reference in New Issue
Block a user