From a3dd70f8c08debb0a4aeda446069656c285050a9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 23 Oct 2005 06:17:14 +0000 Subject: [PATCH] (EFF_OPEN): New. (ef_open): Restrict HOW to EFF_OPEN. --- include/file.h | 3 +++ src/lib/common/file.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/file.h b/include/file.h index 2fef929ba..4c8a28884 100644 --- a/include/file.h +++ b/include/file.h @@ -67,6 +67,9 @@ struct empfile { #define EFF_OWNER bit(2) /* has concept of owner */ #define EFF_GROUP bit(3) /* has concept of group */ +/* Flags that may be passed to ef_open() */ +#define EFF_OPEN EFF_MEM + /* * Empire `file types' * These are really table IDs. Some tables are backed by files, some diff --git a/src/lib/common/file.c b/src/lib/common/file.c index 243104544..8c228118f 100644 --- a/src/lib/common/file.c +++ b/src/lib/common/file.c @@ -49,9 +49,10 @@ static void fillcache(struct empfile *ep, int start); /* - * Open the file containing objects of the type 'type' with mode 'mode'. - * 'how' sets whether the file should be cached (EFF_MEM), or type specific - * flags (EFF_XY,EFF_OWNER,EFF,EFF_GROUP). + * Open a the file for table TYPE (EF_SECTOR, ...). + * MODE is passed to open(). + * HOW are EFF_OPEN flags to control operation. + * Return non-zero on success, zero on failure. */ int ef_open(int type, int mode, int how) @@ -64,6 +65,8 @@ ef_open(int type, int mode, int how) #endif if (ef_check(type) < 0) return 0; + if (CANT_HAPPEN(how & ~EFF_OPEN)) + how &= EFF_OPEN; ep = &empfile[type]; if ((ep->fd = open(ep->file, mode, 0660)) < 0) { logerror("%s: open failed", ep->file); -- 2.43.0