[dovecot-cvs] dovecot/src/lib-index/mbox mbox-append.c,1.34,1.35 mbox-index.c,1.55,1.56 mbox-lock.c,1.18,1.19 mbox-rebuild.c,1.20,1.21 mbox-rewrite.c,1.45,1.46 mbox-sync-full.c,1.7,1.8 mbox-sync.c,1.26,1.27

cras at procontrol.fi cras at procontrol.fi
Fri Dec 20 09:53:54 EET 2002


Update of /home/cvs/dovecot/src/lib-index/mbox
In directory danu:/tmp/cvs-serv29331/src/lib-index/mbox

Modified Files:
	mbox-append.c mbox-index.c mbox-lock.c mbox-rebuild.c 
	mbox-rewrite.c mbox-sync-full.c mbox-sync.c 
Log Message:
Added :INDEX=<dir> for both Maildir and mbox to specify different location
where to store index files. This would allow keeping mailboxes accessible
through NFS but still keep the indexes in fast local disk.

Did also some other related cleanups and minor fixes.



Index: mbox-append.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-append.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- mbox-append.c	16 Dec 2002 03:27:35 -0000	1.34
+++ mbox-append.c	20 Dec 2002 07:53:52 -0000	1.35
@@ -38,7 +38,7 @@
 		   b) not a From-line */
 		index_set_error(index, "Error indexing mbox file %s: "
 				"From-line not found where expected",
-				index->mbox_path);
+				index->mailbox_path);
 		index->set_flags |= MAIL_INDEX_FLAG_FSCK;
 		return FALSE;
 	}
@@ -130,7 +130,7 @@
 				index_set_error(index,
 						"Error indexing mbox file %s: "
 						"LF not found where expected",
-						index->mbox_path);
+						index->mailbox_path);
 
 				index->set_flags |= MAIL_INDEX_FLAG_FSCK;
 				return FALSE;

Index: mbox-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-index.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- mbox-index.c	18 Dec 2002 15:15:41 -0000	1.55
+++ mbox-index.c	20 Dec 2002 07:53:52 -0000	1.56
@@ -24,7 +24,7 @@
 	i_assert(function != NULL);
 
 	index_set_error(index, "%s failed with mbox file %s: %m",
-			function, index->mbox_path);
+			function, index->mailbox_path);
 	return FALSE;
 }
 
@@ -35,7 +35,7 @@
 
 	i_assert(index->mbox_fd == -1);
 
-	fd = open(index->mbox_path, O_RDWR);
+	fd = open(index->mailbox_path, O_RDWR);
 	if (fd == -1) {
 		mbox_set_syscall_error(index, "open()");
 		return FALSE;
@@ -727,7 +727,7 @@
 	index->mbox_fd = -1;
 	index->mbox_sync_counter = (unsigned int)-1;
 
-	index->mbox_path = i_strdup(mbox_path);
+	index->mailbox_path = i_strdup(mbox_path);
 	mail_index_init(index, dir);
 	return index;
 }
@@ -736,8 +736,8 @@
 {
         mbox_file_close_fd(index);
 	mail_index_close(index);
-	i_free(index->mbox_path);
 	i_free(index->dir);
+	i_free(index->mailbox_path);
 	i_free(index);
 }
 

Index: mbox-lock.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-lock.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mbox-lock.c	6 Dec 2002 01:09:23 -0000	1.18
+++ mbox-lock.c	20 Dec 2002 07:53:52 -0000	1.19
@@ -87,7 +87,7 @@
 			index->mailbox_lock_timeout = TRUE;
 			index_set_error(index, "Timeout while waiting for "
 					"release of flock() lock for mbox file "
-					"%s", index->mbox_path);
+					"%s", index->mailbox_path);
 			return FALSE;
 		}
 
@@ -127,7 +127,7 @@
 			index->mailbox_lock_timeout = TRUE;
 			index_set_error(index, "Timeout while waiting for "
 					"release of fcntl() lock for mbox file "
-					"%s", index->mbox_path);
+					"%s", index->mailbox_path);
 			return FALSE;
 		}
 
@@ -163,7 +163,7 @@
 
 		if (stat(path, &st) == 0) {
 			/* see if there's been any changes in mbox */
-			if (stat(index->mbox_path, &st) < 0) {
+			if (stat(index->mailbox_path, &st) < 0) {
 				mbox_set_syscall_error(index, "stat()");
 				break;
 			}
@@ -332,14 +332,15 @@
 
 	/* make .lock file first to protect overwriting the file */
 	if (use_dotlock && index->mbox_dotlock_ino == 0) {
-		if (!mbox_lock_dotlock(index, index->mbox_path, max_wait_time,
+		if (!mbox_lock_dotlock(index, index->mailbox_path,
+				       max_wait_time,
 				       lock_type == MAIL_LOCK_SHARED &&
 				       !use_read_dotlock))
 			return FALSE;
 	}
 
 	/* now we need to have the file itself locked. open it if needed. */
-	if (stat(index->mbox_path, &st) < 0)
+	if (stat(index->mailbox_path, &st) < 0)
 		return mbox_set_syscall_error(index, "stat()");
 
 	if (st.st_dev != index->mbox_dev || st.st_ino != index->mbox_ino)
@@ -382,7 +383,7 @@
 	}
 
 	if (index->mbox_dotlock_ino != 0) {
-		if (!mbox_unlock_dotlock(index, index->mbox_path))
+		if (!mbox_unlock_dotlock(index, index->mailbox_path))
 			failed = TRUE;
 	}
 

Index: mbox-rebuild.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-rebuild.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mbox-rebuild.c	6 Dec 2002 01:09:23 -0000	1.20
+++ mbox-rebuild.c	20 Dec 2002 07:53:52 -0000	1.21
@@ -56,7 +56,7 @@
 		return FALSE;
 
 	/* update sync stamp */
-	if (stat(index->mbox_path, &st) < 0)
+	if (stat(index->mailbox_path, &st) < 0)
 		return mbox_set_syscall_error(index, "fstat()");
 
 	index->file_sync_stamp = st.st_mtime;

Index: mbox-rewrite.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-rewrite.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- mbox-rewrite.c	19 Dec 2002 01:02:35 -0000	1.45
+++ mbox-rewrite.c	20 Dec 2002 07:53:52 -0000	1.46
@@ -61,13 +61,13 @@
 	i_stream_set_read_limit(input, end_offset);
 	if (o_stream_send_istream(output, input) < 0) {
 		index_set_error(index, "Error rewriting mbox file %s: %s",
-				index->mbox_path,
+				index->mailbox_path,
 				strerror(output->stream_errno));
 		failed = TRUE;
 	} else if (input->v_offset < end_offset) {
 		/* fsck should have noticed it.. */
 		index_set_error(index, "Error rewriting mbox file %s: "
-				"Unexpected end of file", index->mbox_path);
+				"Unexpected end of file", index->mailbox_path);
 		failed = TRUE;
 	} else {
 		failed = FALSE;
@@ -315,7 +315,7 @@
 	if (input->v_offset >= end_offset) {
 		/* fsck should have noticed it.. */
 		index_set_error(index, "Error rewriting mbox file %s: "
-				"Unexpected end of file", index->mbox_path);
+				"Unexpected end of file", index->mailbox_path);
 		return FALSE;
 	}
 
@@ -539,7 +539,7 @@
 
 	if (!dirty_found) {
 		index_set_error(index, "Expected dirty messages not found "
-				"from mbox file %s", index->mbox_path);
+				"from mbox file %s", index->mailbox_path);
 		failed = TRUE;
 	}
 

Index: mbox-sync-full.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-sync-full.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mbox-sync-full.c	18 Dec 2002 05:42:12 -0000	1.7
+++ mbox-sync-full.c	20 Dec 2002 07:53:52 -0000	1.8
@@ -205,7 +205,7 @@
 	if (i_stream_read_data(input, &data, &size, 5) > 0 &&
 	    strncmp((const char *) data, "From ", 5) != 0) {
 		index_set_error(index, "File isn't in mbox format: %s",
-				index->mbox_path);
+				index->mailbox_path);
 		return FALSE;
 	}
 
@@ -232,7 +232,7 @@
 				index_set_error(index,
 						"Error syncing mbox file %s: "
 						"LF not found where expected",
-						index->mbox_path);
+						index->mailbox_path);
 				return FALSE;
 			}
 		}

Index: mbox-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-sync.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mbox-sync.c	6 Dec 2002 01:09:23 -0000	1.26
+++ mbox-sync.c	20 Dec 2002 07:53:52 -0000	1.27
@@ -93,14 +93,14 @@
 	}
 
 	count = 0;
-	while (stat(index->mbox_path, &st) < 0) {
+	while (stat(index->mailbox_path, &st) < 0) {
 		if (errno != ENOENT || ++count == 3)
 			return mbox_set_syscall_error(index, "stat()");
 
 		/* mbox was deleted by someone - happens with some MUAs
 		   when all mail is expunged. easiest way to deal with this
 		   is to recreate the file. */
-		fd = open(index->mbox_path, O_RDWR | O_CREAT | O_EXCL, 0660);
+		fd = open(index->mailbox_path, O_RDWR | O_CREAT | O_EXCL, 0660);
 		if (fd != -1)
 			(void)close(fd);
 		else if (errno != EEXIST)




More information about the dovecot-cvs mailing list