#R668: Windows 2000 Lock File Creation Error
This was a tricky one. While the error was ultimately because he was specifying a non-existant directory in defaults.nh, the error message lead me to the wrong area until I traced through with a debugger. It turns out that an fqn buffer was being re-used before it was finished being used with the original information in sys/share/pcunix.c, so the error message listed the wrong file! This adds one more buffer and fixes the problem. Note that it could only affect plaforms with PREFIXES_IN_USE defined (NOCWD_ASSUMPTIONS or VAR_PLAYGROUND) It also alters the WIN32 error message to give them a hint as to what the problem might be. <email deleted> <email deleted> Sent: Saturday, March 23, 2002 9:27 AM Subject: #R668: Windows 2000 Lock File Creation Error > nhfrom: 3.4.0 Official binary release for Windows 95/98/NT/2000/Me/XP > I get an error after unzipping nethack to c:\nethack, and changing the > configuration (defaults.nh) to reflect this in the hackdir, levels and save > configuration items. > > The error I get is "cannot creat lock file (C:\nethack\NHPERM_lock.)" after > entering nethack at the command line and answering the Who are you? question.
This commit is contained in:
+3
-3
@@ -34,7 +34,7 @@ extern int errno;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PREFIXES_IN_USE
|
#ifdef PREFIXES_IN_USE
|
||||||
#define FQN_NUMBUF 2
|
#define FQN_NUMBUF 3
|
||||||
static char fqn_filename_buffer[FQN_NUMBUF][FQN_MAX_FILENAME];
|
static char fqn_filename_buffer[FQN_NUMBUF][FQN_MAX_FILENAME];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -909,7 +909,7 @@ int retryct;
|
|||||||
lockname = make_lockname(filename, locknambuf);
|
lockname = make_lockname(filename, locknambuf);
|
||||||
filename = fqname(filename, whichprefix, 0);
|
filename = fqname(filename, whichprefix, 0);
|
||||||
#ifndef NO_FILE_LINKS /* LOCKDIR should be subsumed by LOCKPREFIX */
|
#ifndef NO_FILE_LINKS /* LOCKDIR should be subsumed by LOCKPREFIX */
|
||||||
lockname = fqname(lockname, LOCKPREFIX, 1);
|
lockname = fqname(lockname, LOCKPREFIX, 2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(UNIX) || defined(VMS)
|
#if defined(UNIX) || defined(VMS)
|
||||||
@@ -1013,7 +1013,7 @@ const char *filename;
|
|||||||
if (nesting == 1) {
|
if (nesting == 1) {
|
||||||
lockname = make_lockname(filename, locknambuf);
|
lockname = make_lockname(filename, locknambuf);
|
||||||
#ifndef NO_FILE_LINKS /* LOCKDIR should be subsumed by LOCKPREFIX */
|
#ifndef NO_FILE_LINKS /* LOCKDIR should be subsumed by LOCKPREFIX */
|
||||||
lockname = fqname(lockname, LOCKPREFIX, 1);
|
lockname = fqname(lockname, LOCKPREFIX, 2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(UNIX) || defined(VMS)
|
#if defined(UNIX) || defined(VMS)
|
||||||
|
|||||||
+9
-2
@@ -96,7 +96,7 @@ eraseoldlocks()
|
|||||||
void
|
void
|
||||||
getlock()
|
getlock()
|
||||||
{
|
{
|
||||||
register int fd, c, ci, ct;
|
register int fd, c, ci, ct, ern;
|
||||||
char tbuf[BUFSZ];
|
char tbuf[BUFSZ];
|
||||||
const char *fq_lock;
|
const char *fq_lock;
|
||||||
# if defined(MSDOS) && defined(NO_TERMS)
|
# if defined(MSDOS) && defined(NO_TERMS)
|
||||||
@@ -180,10 +180,17 @@ getlock()
|
|||||||
|
|
||||||
gotlock:
|
gotlock:
|
||||||
fd = creat(fq_lock, FCMASK);
|
fd = creat(fq_lock, FCMASK);
|
||||||
|
if (fd == -1) ern = errno;
|
||||||
unlock_file(HLOCK);
|
unlock_file(HLOCK);
|
||||||
if(fd == -1) {
|
if(fd == -1) {
|
||||||
chdirx(orgdir, 0);
|
chdirx(orgdir, 0);
|
||||||
error("cannot creat lock file (%s.)", fq_lock);
|
#if defined(WIN32)
|
||||||
|
error("cannot creat file (%s.)\n%s\n%s\"%s\" exists?\n",
|
||||||
|
fq_lock, strerror(ern), "Are you sure that the directory",
|
||||||
|
fqn_prefix[LEVELPREFIX]);
|
||||||
|
#else
|
||||||
|
error("cannot creat file (%s.)", fq_lock);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if(write(fd, (char *) &hackpid, sizeof(hackpid))
|
if(write(fd, (char *) &hackpid, sizeof(hackpid))
|
||||||
!= sizeof(hackpid)){
|
!= sizeof(hackpid)){
|
||||||
|
|||||||
Reference in New Issue
Block a user