Skip to content

Commit

Permalink
Correct {DSK} versioned file cache failures (#526)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nbriggs authored Jan 27, 2025
1 parent 3c4d9f5 commit e61d0f2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit e61d0f2

Please sign in to comment.