Fix: SE030 Problem: Inconsistent use of RECORD_AREA, causing attempts to write into FILE_AREA_UNSHARE, which may cause Slash'EM to fail on systems that place this in a non-writable location. I suspect this is the root cause of the problems Peter Makholm was having a couple of weeks ago when he first tested file area support. Compatible with: Slash'EM 0.0.5E7 Author: J. Ali Harlow, ali@avrc.city.ac.uk Date: 5 Dec 1999 *** src/files.c.orig Thu Dec 2 15:00:58 1999 --- src/files.c Sun Dec 5 16:24:32 1999 *************** *** 1502,1508 **** --- 1502,1512 ---- #endif { #if defined(UNIX) || defined(VMS) + # ifdef FILE_AREAS + int fd = open_area(RECORD_AREA, RECORD, O_RDWR, 0); + # else int fd = open(RECORD, O_RDWR, 0); + # endif if (fd >= 0) { # ifdef VMS /* must be stream-lf to use UPDATE_RECORD_IN_PLACE */ *************** *** 1514,1524 **** --- 1518,1536 ---- } # endif (void) close(fd); /* RECORD is accessible */ + # ifdef FILE_AREAS + } else if ((fd = open_area(RECORD_AREA, RECORD, O_CREAT|O_RDWR, FCMASK)) >= 0) { + # else } else if ((fd = open(RECORD, O_CREAT|O_RDWR, FCMASK)) >= 0) { + # endif (void) close(fd); /* RECORD newly created */ # if defined(VMS) && !defined(SECURE) /* Re-protect RECORD with world:read+write+execute+delete access. */ + # ifdef FILE_AREAS + (void) chmod_area(RECORD_AREA, RECORD, FCMASK | 007); + # else (void) chmod(RECORD, FCMASK | 007); /* allow everyone full access */ + # endif # endif /* VMS && !SECURE */ } else { raw_printf("Warning: cannot write scoreboard file %s/%s", *************** *** 1539,1547 **** Strcpy(tmp, RECORD); # endif if ((fd = open(tmp, O_RDWR)) < 0) { /* try to create empty record */ ! # if defined(AZTEC_C) || defined(_DCC) /* Aztec doesn't use the third argument */ /* DICE doesn't like it */ if ((fd = open(tmp, O_CREAT|O_RDWR)) < 0) { --- 1551,1566 ---- Strcpy(tmp, RECORD); # endif + # ifdef FILE_AREAS + if ((fd = open_area(RECORD_AREA, tmp, O_RDWR)) < 0) { + # else if ((fd = open(tmp, O_RDWR)) < 0) { + # endif /* try to create empty record */ ! # if defined(FILE_AREAS) ! if ((fd = open_area(RECORD_AREA, tmp, O_CREAT|O_RDWR, ! S_IREAD|S_IWRITE)) < 0) { ! # elif defined(AZTEC_C) || defined(_DCC) /* Aztec doesn't use the third argument */ /* DICE doesn't like it */ if ((fd = open(tmp, O_CREAT|O_RDWR)) < 0) { *** src/topten.c.orig Thu Dec 2 15:00:58 1999 --- src/topten.c Sun Dec 5 16:26:06 1999 *************** *** 388,396 **** goto destroywin; #ifdef UPDATE_RECORD_IN_PLACE ! rfile = fopen_datafile_area(FILE_AREA_VAR,RECORD, "r+"); #else ! rfile = fopen_datafile_area(FILE_AREA_VAR,RECORD, "r"); #endif if (!rfile) { --- 388,396 ---- goto destroywin; #ifdef UPDATE_RECORD_IN_PLACE ! rfile = fopen_datafile_area(RECORD_AREA, RECORD, "r+"); #else ! rfile = fopen_datafile_area(RECORD_AREA, RECORD, "r"); #endif if (!rfile) { *************** *** 471,477 **** t0->fpos : final_fpos), SEEK_SET); #else (void) fclose(rfile); ! if(!(rfile = fopen_datafile_area(FILE_AREA_VAR,RECORD,"w"))){ HUP raw_print("Cannot write record file"); unlock_file_area(RECORD_AREA, RECORD); free_ttlist(tt_head); --- 471,477 ---- t0->fpos : final_fpos), SEEK_SET); #else (void) fclose(rfile); ! if(!(rfile = fopen_datafile_area(RECORD_AREA, RECORD, "w"))){ HUP raw_print("Cannot write record file"); unlock_file_area(RECORD_AREA, RECORD); free_ttlist(tt_head); *************** *** 784,790 **** return; } ! rfile = fopen_datafile_area(FILE_AREA_VAR,RECORD, "r"); if (!rfile) { raw_print("Cannot open record file!"); return; --- 784,790 ---- return; } ! rfile = fopen_datafile_area(RECORD_AREA, RECORD, "r"); if (!rfile) { raw_print("Cannot open record file!"); return; *************** *** 982,988 **** if (!otmp) return((struct obj *) 0); ! rfile = fopen_datafile_area(FILE_AREA_VAR,RECORD, "r"); if (!rfile) { impossible("Cannot open record file!"); return (struct obj *)0; --- 982,988 ---- if (!otmp) return((struct obj *) 0); ! rfile = fopen_datafile_area(RECORD_AREA, RECORD, "r"); if (!rfile) { impossible("Cannot open record file!"); return (struct obj *)0;