From e61d0f2e6c748ed3a4044cde122858e752ef6981 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Sun, 26 Jan 2025 18:38:25 -0800 Subject: [PATCH] Correct {DSK} versioned file cache failures (#526) A missing check for the applicability of a versioned file cache caused loadups to fail in the case where the modification timestamp of a directory and its parent were identical, and the file being looked up had the same name (when lowercased) as the directory it was contained within. E.g., looking up TEDIT in library/tedit/ where the modification times of library and library/tedit were identical. The inode number of the directory containing the file must be the same as the inode number of the directory the cache was built from. --- src/dsk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dsk.c b/src/dsk.c index 75d9f4c8..a96a0f43 100644 --- a/src/dsk.c +++ b/src/dsk.c @@ -66,6 +66,7 @@ typedef struct filename_entry { */ static struct { char name[MAXPATHLEN]; /* lowercase unversioned file name */ + ino_t dir_ino; /* inode of the directory */ struct timespec lastMTime; /* modification time of the directory */ int allocated; /* number of entries in the files array */ int lastUsed; /* index of the last entry in use in files array */ @@ -3055,11 +3056,13 @@ static int get_version_array(char *dir, char *file) *Lisp_errno = errno; return(0); } - if (0 == strcmp(lcased_file, VA.name) && + if (sbuf.st_ino == VA.dir_ino && + 0 == strcmp(lcased_file, VA.name) && sbuf.st_mtim.tv_sec == VA.lastMTime.tv_sec && sbuf.st_mtim.tv_nsec == VA.lastMTime.tv_nsec) { return (1); } else { + VA.dir_ino = sbuf.st_ino; VA.lastMTime = sbuf.st_mtim; strcpy(VA.name, lcased_file); }