]> git.pond.sub.org Git - empserver/commitdiff
(EFF_OPEN): New.
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 23 Oct 2005 06:17:14 +0000 (06:17 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 23 Oct 2005 06:17:14 +0000 (06:17 +0000)
(ef_open): Restrict HOW to EFF_OPEN.

include/file.h
src/lib/common/file.c

index 2fef929babad2563dc24a1eb618b4a4b59e2acef..4c8a2888418bb59843443e055ac4e623d94ebb08 100644 (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
index 243104544cd5d808e57dd43661ba276400593b32..8c228118f835a7810db658f14d3a32fb6fa87350 100644 (file)
 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);