From d48169169e98435c2dbb08fae1b51595ee19530b Mon Sep 17 00:00:00 2001 From: Dale Whinham Date: Sun, 13 Dec 2020 00:42:21 +0000 Subject: [PATCH] minimig: Fix path resolution for assigns Only nullify the key in find_path() if the name contains our device (SHARE:) or volume (MiSTer:) name. This fixes the ability to create assigns to locations on the shared filesystem. If find_path() is called with an assign-relative path, we want to preserve the key so that a relative path is constructed from the directory associated with that key. --- support/minimig/minimig_share.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/support/minimig/minimig_share.cpp b/support/minimig/minimig_share.cpp index fb57d8a..14898ea 100644 --- a/support/minimig/minimig_share.cpp +++ b/support/minimig/minimig_share.cpp @@ -27,6 +27,10 @@ static uint8_t *shmem = 0; #define REQUEST_BUFFER 4 // ~512B #define DATA_BUFFER 0x1000 // 4KB +// Must match device name in MountList and volume name from MiSTerFileSystem +#define DEVICE_NAME "SHARE" +#define VOLUME_NAME "MiSTer" + //#define DEBUG #ifdef DEBUG @@ -124,7 +128,12 @@ static char* find_path(uint32_t key, const char *name) const char* p = strchr(name, ':'); if (p) { - key = 0; + size_t root_len = p - name; + + // Don't use lock for relative path if the name contains our root + if (root_len == 0 || !strncasecmp(name, DEVICE_NAME, root_len) || !strncasecmp(name, VOLUME_NAME, root_len)) + key = 0; + name = p + 1; }