(EFF_OPEN): New.

(ef_open): Restrict HOW to EFF_OPEN.
This commit is contained in:
Markus Armbruster 2005-10-23 06:17:14 +00:00
parent dbff0608e5
commit a3dd70f8c0
2 changed files with 9 additions and 3 deletions

View file

@ -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

View file

@ -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);