diff src/lib-index/mail-index.c @ 6686:610f3d9813b5 HEAD

Added MAIL_INDEX_OPEN_FLAG_READONLY.
author Timo Sirainen <tss@iki.fi>
date Sun, 04 Nov 2007 14:47:01 +0200
parents 90196328bcce
children 3e189cbb7e7a
line wrap: on
line diff
--- a/src/lib-index/mail-index.c	Sat Nov 03 23:02:55 2007 +0200
+++ b/src/lib-index/mail-index.c	Sun Nov 04 14:47:01 2007 +0200
@@ -243,8 +243,12 @@
 	i_assert(!MAIL_INDEX_IS_IN_MEMORY(index));
 
         /* Note that our caller must close index->fd by itself. */
-	index->fd = nfs_safe_open(index->filepath, O_RDWR);
-	index->readonly = FALSE;
+	if (index->readonly)
+		errno = EACCES;
+	else {
+		index->fd = nfs_safe_open(index->filepath, O_RDWR);
+		index->readonly = FALSE;
+	}
 
 	if (index->fd == -1 && errno == EACCES) {
 		index->fd = open(index->filepath, O_RDONLY);
@@ -396,6 +400,7 @@
 	index->fsync_disable =
 		(flags & MAIL_INDEX_OPEN_FLAG_FSYNC_DISABLE) != 0;
 	index->nfs_flush = (flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0;
+	index->readonly = (flags & MAIL_INDEX_OPEN_FLAG_READONLY) != 0;
 	index->lock_method = lock_method;
 
 	if (index->nfs_flush && index->fsync_disable)