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!
This commit is contained in:
Dale Whinham
2020-12-11 19:15:30 +00:00
parent 255c22e601
commit c8a124385e
2 changed files with 44 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;