Commit e6ff7fc3 authored by ROOL's avatar ROOL 🤖
Browse files

[419] LanManFS does not see all visible files

Detail:
  When the number of files read from the server didn't fit in the OS_GBPB buffer, continuation of the enumeration would fail.
  Resume key *and* filename used when resuming a directory enumeration to the same directory.
Admin:
  Submission from Colin Granville.

Version 2.56. Tagged as 'LanManFS-2_56'
parent b826b8ec
/* (2.55)
/* (2.56)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.55
#define Module_MajorVersion_CMHG 2.56
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 14 Apr 2016
#define Module_Date_CMHG 14 May 2016
#define Module_MajorVersion "2.55"
#define Module_Version 255
#define Module_MajorVersion "2.56"
#define Module_Version 256
#define Module_MinorVersion ""
#define Module_Date "14 Apr 2016"
#define Module_Date "14 May 2016"
#define Module_ApplicationDate "14-Apr-16"
#define Module_ApplicationDate "14-May-16"
#define Module_ComponentName "LanManFS"
#define Module_ComponentPath "castle/RiscOS/Sources/Networking/Omni/Protocols/LanManFS"
#define Module_FullVersion "2.55"
#define Module_HelpVersion "2.55 (14 Apr 2016)"
#define Module_LibraryVersionInfo "2:55"
#define Module_FullVersion "2.56"
#define Module_HelpVersion "2.56 (14 May 2016)"
#define Module_LibraryVersionInfo "2:56"
......@@ -2160,6 +2160,7 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
int n_read = 0;
int eos;
int i;
DWORD actual_resume_key;
const int first_flags = ffirst_RETURN_KEYS;
const int stuck_flags = ffirst_RETURN_KEYS | fnext_CONTINUE;
const int next_flags = ffirst_RETURN_KEYS;
......@@ -2210,6 +2211,7 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
con->dir_handle_valid = true;
con->resume_fake = 0;
con->resume_key_stuck = false;
con->resume_file_name[0] = 0;
debug1("SMB_ReadDirEntriesX2 -> new dir handle %x\n", con->dir_handle);
}
else {
......@@ -2219,15 +2221,9 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
Transact_addword(&con->tp, con->dir_handle); /* findnext_DirHandle */
Transact_addword(&con->tp, count); /* findnext_SearchCount */
Transact_addword(&con->tp, 1); /* Search level */
Transact_addlong(&con->tp, con->resume_key); /* Resume key from previous */
if (con->resume_key_stuck) {
Transact_addword(&con->tp, stuck_flags); /* Set continuation bit as NTFS maintains the position */
}
else {
Transact_addword(&con->tp, next_flags); /* Jump to place using the resume key */
con->resume_key_encountered = true;
}
Transact_addstring(&con->tp, ""); /* no name needed */
Transact_addlong(&con->tp, con->actual_resume_key); /* Resume key from previous */
Transact_addword(&con->tp, next_flags); /* Jump to place using the resume key */
Transact_addstring(&con->tp, con->resume_file_name);
debug1("SMB_ReadDirEntriesX2 -> continue with key %08x\n", con->resume_key);
res = SMB_Transact2(hS, &con->tp);
if (res != OK)
......@@ -2263,6 +2259,8 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
continue;
}
actual_resume_key = next_resume_key;
/* Workaround for NTFS always returning zero */
con->resume_key_stuck = (next_resume_key == 0) ? true : false;
if (con->resume_key_stuck) next_resume_key = con->resume_fake;
......@@ -2271,7 +2269,16 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
if ( con->resume_key_encountered ) {
debug1("SMB_ReadDirEntriesX2 -> call back with key %08x\n", next_resume_key);
res = dirfn(p, 1, &taken, private);
if (taken) con->resume_key = next_resume_key;
if (taken) {
con->resume_key = next_resume_key;
con->actual_resume_key = actual_resume_key;
memcpy(con->resume_file_name, p + 23, length + 1);
}
else {
con->resume_fake--;
}
if (res != OK) {
/* Entry expander must have run out of space! */
debug0("SMB_ReadDirEntriesX2 -> caller ran out of space (or could be name xlate code)\n");
......@@ -2280,6 +2287,8 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
}
else {
debug2("SMB_ReadDirEntriesX2 -> awaiting key %08x (got %08x)\n", con->resume_key, next_resume_key);
con->actual_resume_key = actual_resume_key;
memcpy(con->resume_file_name, p + 23, length + 1);
if ( next_resume_key == con->resume_key )
con->resume_key_encountered = true;
}
......
......@@ -34,7 +34,8 @@ typedef struct {
bool resume_key_encountered;
WORD dir_handle;
bool dir_handle_valid;
DWORD actual_resume_key;
char resume_file_name[DOS_NAME_LEN];
/* Cached state for short names */
BYTE resume_state[SEARCH_ST_SIZE];
} Transact_SearchContext;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment