From c8a124385e9c48cbe753d8e3e8187bfe0dd2c5c2 Mon Sep 17 00:00:00 2001 From: Dale Whinham Date: Fri, 11 Dec 2020 19:15:30 +0000 Subject: [PATCH] minimig: Add ACTION_SAME_LOCK to shared filesystem Adapt upstream fix from a314. This fixes some odd behaviour in Workbench such as: - Icons that were "Left Out" would reappear in their parent windows when refreshed. - Deleted files would not disappear from the window unless it was refreshed. Original message from a314 commit: This call is used in at least 2.1 to terminate directory traversal when deleting a directory using Workbench. This sometimes caused unhandled exceptions in a314d and much worse unintended files being deleted! --- support/minimig/miminig_fs_messages.h | 20 ++++++++++++++++++++ support/minimig/minimig_share.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/support/minimig/miminig_fs_messages.h b/support/minimig/miminig_fs_messages.h index d65f906..bdc1af2 100644 --- a/support/minimig/miminig_fs_messages.h +++ b/support/minimig/miminig_fs_messages.h @@ -28,6 +28,7 @@ #define ACTION_DISK_TYPE 32 #define ACTION_DISK_CHANGE 33 #define ACTION_SET_DATE 34 +#define ACTION_SAME_LOCK 40 #define ACTION_SCREEN_MODE 994 #define ACTION_READ_RETURN 1001 #define ACTION_WRITE_RETURN 1002 @@ -74,6 +75,10 @@ #define SHARED_LOCK -2 #define EXCLUSIVE_LOCK -1 +#define LOCK_DIFFERENT -1 +#define LOCK_SAME 0 +#define LOCK_SAME_VOLUME 1 + #define MODE_OLDFILE 1005 #define MODE_NEWFILE 1006 #define MODE_READWRITE 1004 @@ -356,6 +361,21 @@ struct SetCommentResponse long error_code; }; +struct SameLockRequest +{ + long sz; + long type; + long key1; + long key2; +}; + +struct SameLockResponse +{ + long sz; + long success; + long error_code; +}; + struct DiskInfoRequest { long sz; diff --git a/support/minimig/minimig_share.cpp b/support/minimig/minimig_share.cpp index 954ab77..f065360 100644 --- a/support/minimig/minimig_share.cpp +++ b/support/minimig/minimig_share.cpp @@ -781,6 +781,30 @@ static int process_request(void *reqres_buffer) ret = 0; } break; + + case ACTION_SAME_LOCK: + { + dbg_print("> ACTION_SAME_LOCK\n"); + SameLockRequest *req = (SameLockRequest*)reqres_buffer; + + uint32_t key1 = SWAP_INT(req->key1); + uint32_t key2 = SWAP_INT(req->key2); + + if ((locks.find(key1) == locks.end()) || (locks.find(key2) == locks.end())) + { + ret = LOCK_DIFFERENT; + break; + } + + if (locks[key1].path == locks[key2].path) + { + ret = LOCK_SAME; + break; + } + + ret = LOCK_SAME_VOLUME; + } + break; } int success = ret ? 0 : 1;