changeset 6161:c62f7ee79446 HEAD

Split o_stream_create_file() to _create_fd() and _create_fd_file().
author Timo Sirainen <tss@iki.fi>
date Thu, 02 Aug 2007 18:23:22 +0300
parents fe1e6e895d8f
children 896cc473c1f0
files src/auth/auth-client-connection.c src/auth/auth-master-connection.c src/auth/auth-worker-client.c src/auth/auth-worker-server.c src/deliver/auth-client.c src/deliver/duplicate.c src/dict/dict-server.c src/imap-login/client.c src/imap/client.c src/lib-auth/auth-server-connection.c src/lib-dict/dict-client.c src/lib-index/mail-cache-compress.c src/lib-index/mailbox-list-index-sync.c src/lib-storage/index/cydir/cydir-save.c src/lib-storage/index/dbox/dbox-sync-expunge.c src/lib-storage/index/dbox/dbox-uidlist.c src/lib-storage/index/maildir/maildir-save.c src/lib-storage/index/maildir/maildir-uidlist.c src/lib-storage/index/mbox/mbox-save.c src/lib-storage/index/mbox/mbox-sync-rewrite.c src/lib-storage/list/subscription-file.c src/lib/file-copy.c src/lib/ostream-file.c src/lib/ostream.h src/login-common/login-proxy.c src/master/auth-process.c src/master/login-process.c src/plugins/acl/acl-backend-vfile-acllist.c src/plugins/expire/auth-client.c src/plugins/fts-squat/squat-trie.c src/plugins/fts-squat/squat-uidlist.c src/pop3-login/client.c src/pop3/client.c src/util/rawlog.c
diffstat 34 files changed, 100 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-client-connection.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/auth/auth-client-connection.c	Thu Aug 02 18:23:22 2007 +0300
@@ -276,8 +276,7 @@
 	conn->fd = fd;
 	conn->input =
 		i_stream_create_file(fd, AUTH_CLIENT_MAX_LINE_LENGTH, FALSE);
-	conn->output =
-		o_stream_create_file(fd, (size_t)-1, FALSE);
+	conn->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
 	o_stream_set_flush_callback(conn->output, auth_client_output, conn);
 	conn->io = io_add(fd, IO_READ, auth_client_input, conn);
 
--- a/src/auth/auth-master-connection.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/auth/auth-master-connection.c	Thu Aug 02 18:23:22 2007 +0300
@@ -243,7 +243,7 @@
 	conn->refcount = 1;
 	conn->fd = fd;
 	conn->input = i_stream_create_file(fd, MAX_INBUF_SIZE, FALSE);
-	conn->output = o_stream_create_file(fd, (size_t)-1, FALSE);
+	conn->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
 	o_stream_set_flush_callback(conn->output, master_output, conn);
 	conn->io = io_add(fd, IO_READ, master_input, conn);
 
--- a/src/auth/auth-worker-client.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/auth/auth-worker-client.c	Thu Aug 02 18:23:22 2007 +0300
@@ -469,8 +469,7 @@
 	client->fd = fd;
 	client->input =
 		i_stream_create_file(fd, AUTH_WORKER_MAX_LINE_LENGTH, FALSE);
-	client->output =
-		o_stream_create_file(fd, (size_t)-1, FALSE);
+	client->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
 	o_stream_set_flush_callback(client->output, auth_worker_output, client);
 	client->io = io_add(fd, IO_READ, auth_worker_input, client);
 
--- a/src/auth/auth-worker-server.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/auth/auth-worker-server.c	Thu Aug 02 18:23:22 2007 +0300
@@ -81,7 +81,7 @@
 	conn->fd = fd;
 	conn->input = i_stream_create_file(fd, AUTH_WORKER_MAX_LINE_LENGTH,
 					   FALSE);
-	conn->output = o_stream_create_file(fd, (size_t)-1, FALSE);
+	conn->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
 	conn->io = io_add(fd, IO_READ, worker_input, conn);
 	conn->requests = buffer_create_dynamic(default_pool, 128);
 
--- a/src/deliver/auth-client.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/deliver/auth-client.c	Thu Aug 02 18:23:22 2007 +0300
@@ -180,7 +180,7 @@
 	conn = i_new(struct auth_connection, 1);
 	conn->fd = fd;
 	conn->input = i_stream_create_file(fd, MAX_INBUF_SIZE, FALSE);
-	conn->output = o_stream_create_file(fd, MAX_OUTBUF_SIZE, FALSE);
+	conn->output = o_stream_create_fd(fd, MAX_OUTBUF_SIZE, FALSE);
 	conn->io = io_add(fd, IO_READ, auth_input, conn);
 	return conn;
 }
--- a/src/deliver/duplicate.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/deliver/duplicate.c	Thu Aug 02 18:23:22 2007 +0300
@@ -218,7 +218,7 @@
 	if (duplicate_file == NULL || !file->changed || file->new_fd == -1)
 		return;
 
-	output = o_stream_create_file(file->new_fd, 4096, FALSE);
+	output = o_stream_create_fd_file(file->new_fd, 0, FALSE);
 	iter = hash_iterate_init(file->hash);
 	while (hash_iterate(iter, &key, &value)) {
 		struct duplicate *d = value;
--- a/src/dict/dict-server.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/dict/dict-server.c	Thu Aug 02 18:23:22 2007 +0300
@@ -448,7 +448,7 @@
 	conn->fd = fd;
 	conn->input = i_stream_create_file(fd, DICT_CLIENT_MAX_LINE_LENGTH,
 					   FALSE);
-	conn->output = o_stream_create_file(fd, 128*1024, FALSE);
+	conn->output = o_stream_create_fd(fd, 128*1024, FALSE);
 	conn->io = io_add(fd, IO_READ, dict_client_connection_input, conn);
 	return conn;
 }
--- a/src/imap-login/client.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/imap-login/client.c	Thu Aug 02 18:23:22 2007 +0300
@@ -69,7 +69,7 @@
 static void client_open_streams(struct imap_client *client, int fd)
 {
 	client->input = i_stream_create_file(fd, MAX_INBUF_SIZE, FALSE);
-	client->output = o_stream_create_file(fd, MAX_OUTBUF_SIZE, FALSE);
+	client->output = o_stream_create_fd(fd, MAX_OUTBUF_SIZE, FALSE);
 	client->parser = imap_parser_create(client->input, client->output,
 					    MAX_IMAP_LINE);
 }
--- a/src/imap/client.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/imap/client.c	Thu Aug 02 18:23:22 2007 +0300
@@ -32,7 +32,7 @@
 	client->fd_out = fd_out;
 	client->input =
 		i_stream_create_file(fd_in, imap_max_line_length, FALSE);
-	client->output = o_stream_create_file(fd_out, (size_t)-1, FALSE);
+	client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE);
 
 	o_stream_set_flush_callback(client->output, _client_output, client);
 
--- a/src/lib-auth/auth-server-connection.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-auth/auth-server-connection.c	Thu Aug 02 18:23:22 2007 +0300
@@ -228,7 +228,7 @@
 	conn->io = io_add(fd, IO_READ, auth_client_input, conn);
 	conn->input = i_stream_create_file(fd, AUTH_CLIENT_MAX_LINE_LENGTH,
 					   FALSE);
-	conn->output = o_stream_create_file(fd, (size_t)-1, FALSE);
+	conn->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
 	conn->requests = hash_create(default_pool, pool, 100, NULL, NULL);
 	conn->auth_mechs_buf = buffer_create_dynamic(default_pool, 256);
 
--- a/src/lib-dict/dict-client.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-dict/dict-client.c	Thu Aug 02 18:23:22 2007 +0300
@@ -245,7 +245,7 @@
 	net_set_nonblock(dict->fd, FALSE);
 
 	dict->input = i_stream_create_file(dict->fd, (size_t)-1, FALSE);
-	dict->output = o_stream_create_file(dict->fd, 4096, FALSE);
+	dict->output = o_stream_create_fd(dict->fd, 4096, FALSE);
 	dict->transaction_id_counter = 0;
 
 	t_push();
--- a/src/lib-index/mail-cache-compress.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-index/mail-cache-compress.c	Thu Aug 02 18:23:22 2007 +0300
@@ -138,7 +138,7 @@
 	}
 
 	cache_view = mail_cache_view_open(cache, view);
-	output = o_stream_create_file(fd, 0, FALSE);
+	output = o_stream_create_fd_file(fd, 0, FALSE);
 
 	memset(&hdr, 0, sizeof(hdr));
 	hdr.version = MAIL_CACHE_VERSION;
--- a/src/lib-index/mailbox-list-index-sync.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-index/mailbox-list-index-sync.c	Thu Aug 02 18:23:22 2007 +0300
@@ -850,7 +850,7 @@
 	int ret = 0;
 
 	if (ctx->index->mmap_base == NULL) {
-		ctx->output = o_stream_create_file(ctx->index->fd, 0, FALSE);
+		ctx->output = o_stream_create_fd_file(ctx->index->fd, 0, FALSE);
 		ctx->output_buf = buffer_create_dynamic(default_pool, 4096);
 		o_stream_seek(ctx->output, ctx->hdr.used_space);
 	}
--- a/src/lib-storage/index/cydir/cydir-save.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-storage/index/cydir/cydir-save.c	Thu Aug 02 18:23:22 2007 +0300
@@ -85,7 +85,7 @@
 	path = cydir_get_save_path(ctx, ctx->mail_count);
 	ctx->fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0660);
 	if (ctx->fd != -1) {
-		output = o_stream_create_file(ctx->fd, 0, FALSE);
+		output = o_stream_create_fd_file(ctx->fd, 0, FALSE);
 		ctx->output = o_stream_create_crlf(output);
 		o_stream_unref(&output);
 		o_stream_cork(ctx->output);
--- a/src/lib-storage/index/dbox/dbox-sync-expunge.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-storage/index/dbox/dbox-sync-expunge.c	Thu Aug 02 18:23:22 2007 +0300
@@ -145,7 +145,7 @@
 
 		/* try again with another file name */
 	}
-	output = o_stream_create_file(fd, 0, FALSE);
+	output = o_stream_create_fd_file(fd, 0, FALSE);
 	lock_path = file_dotlock_get_lock_path(dotlock);
 
 	memset(&dest_entry, 0, sizeof(dest_entry));
--- a/src/lib-storage/index/dbox/dbox-uidlist.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-storage/index/dbox/dbox-uidlist.c	Thu Aug 02 18:23:22 2007 +0300
@@ -559,7 +559,7 @@
 		return 0;
 	}
 
-	output = o_stream_create_file(uidlist->lock_fd, 0, FALSE);
+	output = o_stream_create_fd_file(uidlist->lock_fd, 0, FALSE);
 
 	t_push();
 	str = t_str_new(256);
@@ -739,7 +739,7 @@
 			"lseek(%s) failed: %m", ctx->uidlist->path);
 		return -1;
 	}
-	output = o_stream_create_file(ctx->uidlist->fd, 0, FALSE);
+	output = o_stream_create_fd_file(ctx->uidlist->fd, 0, FALSE);
 
 	uid_start = ctx->uidlist->last_uid + 1;
 
@@ -968,7 +968,7 @@
 	file->fd = fd;
 
 	file->input = i_stream_create_file(file->fd, 65536, FALSE);
-	file->output = o_stream_create_file(file->fd, 0, FALSE);
+	file->output = o_stream_create_fd_file(file->fd, 0, FALSE);
 	if ((uoff_t)st->st_size < sizeof(struct dbox_file_header)) {
 		if (dbox_file_write_header(mbox, file) < 0) {
 			dbox_file_close(file);
--- a/src/lib-storage/index/maildir/maildir-save.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-save.c	Thu Aug 02 18:23:22 2007 +0300
@@ -377,7 +377,7 @@
 	ctx->received_date = received_date;
 	ctx->input = input;
 
-	output = o_stream_create_file(ctx->fd, 0, FALSE);
+	output = o_stream_create_fd_file(ctx->fd, 0, FALSE);
 	ctx->output = (ctx->mbox->storage->storage.flags &
 		       MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ?
 		o_stream_create_crlf(output) : o_stream_create_lf(output);
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Thu Aug 02 18:23:22 2007 +0300
@@ -804,7 +804,7 @@
 
 	i_assert(fd != -1);
 
-	output = o_stream_create_file(fd, 0, FALSE);
+	output = o_stream_create_fd_file(fd, (uoff_t)-1, FALSE);
 	str = t_str_new(512);
 
 	if (output->offset == 0) {
--- a/src/lib-storage/index/mbox/mbox-save.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Thu Aug 02 18:23:22 2007 +0300
@@ -321,7 +321,9 @@
 		if (mbox_seek_to_end(ctx, &ctx->append_offset) < 0)
 			return -1;
 
-		ctx->output = o_stream_create_file(mbox->mbox_fd, 0, FALSE);
+		ctx->output = o_stream_create_fd_file(mbox->mbox_fd,
+						      ctx->append_offset,
+						      FALSE);
 	}
 	return 0;
 }
--- a/src/lib-storage/index/mbox/mbox-sync-rewrite.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync-rewrite.c	Thu Aug 02 18:23:22 2007 +0300
@@ -26,7 +26,7 @@
 
 	i_stream_sync(sync_ctx->input);
 
-	output = o_stream_create_file(sync_ctx->write_fd, 4096, FALSE);
+	output = o_stream_create_fd_file(sync_ctx->write_fd, (uoff_t)-1, FALSE);
 	i_stream_seek(sync_ctx->file_input, source);
 	if (o_stream_seek(output, dest) < 0) {
 		mbox_set_syscall_error(sync_ctx->mbox,
--- a/src/lib-storage/list/subscription-file.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib-storage/list/subscription-file.c	Thu Aug 02 18:23:22 2007 +0300
@@ -115,8 +115,7 @@
 	input = fd_in == -1 ? NULL :
 		i_stream_create_file(fd_in, list->mailbox_name_max_length+1,
 				     TRUE);
-	output = o_stream_create_file(fd_out, list->mailbox_name_max_length+1,
-				      FALSE);
+	output = o_stream_create_fd_file(fd_out, 0, FALSE);
 	found = FALSE;
 	while ((line = next_line(list, path, input,
 				 &failed, FALSE)) != NULL) {
--- a/src/lib/file-copy.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib/file-copy.c	Thu Aug 02 18:23:22 2007 +0300
@@ -69,7 +69,7 @@
 	(void)fchown(fd_out, (uid_t)-1, st.st_gid);
 
 	input = i_stream_create_file(fd_in, 0, FALSE);
-	output = o_stream_create_file(fd_out, 0, FALSE);
+	output = o_stream_create_fd_file(fd_out, 0, FALSE);
 
 	while ((ret = o_stream_send_istream(output, input)) > 0) ;
 
--- a/src/lib/ostream-file.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib/ostream-file.c	Thu Aug 02 18:23:22 2007 +0300
@@ -733,17 +733,13 @@
 		return io_stream_copy_backwards(outstream, instream, in_size);
 }
 
-struct ostream *
-o_stream_create_file(int fd, size_t max_buffer_size, bool autoclose_fd)
+static struct file_ostream *
+o_stream_create_fd_common(int fd, bool autoclose_fd)
 {
 	struct file_ostream *fstream;
-	struct ostream *ostream;
-	struct stat st;
-	off_t offset;
 
 	fstream = i_new(struct file_ostream, 1);
 	fstream->fd = fd;
-	fstream->max_buffer_size = max_buffer_size;
 	fstream->autoclose_fd = autoclose_fd;
 	fstream->optimal_block_size = DEFAULT_OPTIMAL_BLOCK_SIZE;
 
@@ -759,28 +755,44 @@
 	fstream->ostream.sendv = _sendv;
 	fstream->ostream.send_istream = _send_istream;
 
+	return fstream;
+}
+
+static void fstream_init_file(struct file_ostream *fstream)
+{
+	struct stat st;
+
+	fstream->no_sendfile = TRUE;
+	if (fstat(fstream->fd, &st) < 0)
+		return;
+
+	if ((uoff_t)st.st_blksize > fstream->optimal_block_size) {
+		/* use the optimal block size, but with a reasonable limit */
+		fstream->optimal_block_size =
+			I_MIN(st.st_blksize, MAX_OPTIMAL_BLOCK_SIZE);
+	}
+
+	if (S_ISREG(st.st_mode)) {
+		fstream->no_socket_cork = TRUE;
+		fstream->file = TRUE;
+	}
+}
+
+struct ostream *
+o_stream_create_fd(int fd, size_t max_buffer_size, bool autoclose_fd)
+{
+	struct file_ostream *fstream;
+	struct ostream *ostream;
+	off_t offset;
+
+	fstream = o_stream_create_fd_common(fd, autoclose_fd);
+	fstream->max_buffer_size = max_buffer_size;
 	ostream = _o_stream_create(&fstream->ostream);
 
 	offset = lseek(fd, 0, SEEK_CUR);
 	if (offset >= 0) {
 		ostream->offset = offset;
-
-		if (fstat(fd, &st) == 0) {
-			if ((uoff_t)st.st_blksize >
-			    fstream->optimal_block_size) {
-				/* use the optimal block size, but with a
-				   reasonable limit */
-				fstream->optimal_block_size =
-					I_MIN(st.st_blksize,
-					      MAX_OPTIMAL_BLOCK_SIZE);
-			}
-
-			if (S_ISREG(st.st_mode)) {
-				fstream->no_socket_cork = TRUE;
-				fstream->file = TRUE;
-			}
-		}
-		fstream->no_sendfile = TRUE;
+		fstream_init_file(fstream);
 	} else {
 		if (net_getsockname(fd, NULL, NULL) < 0) {
 			fstream->no_sendfile = TRUE;
@@ -793,3 +805,21 @@
 
 	return ostream;
 }
+
+struct ostream *
+o_stream_create_fd_file(int fd, uoff_t offset, bool autoclose_fd)
+{
+	struct file_ostream *fstream;
+	struct ostream *ostream;
+
+	if (offset == (uoff_t)-1)
+		offset = lseek(fd, 0, SEEK_CUR);
+
+	fstream = o_stream_create_fd_common(fd, autoclose_fd);
+	fstream_init_file(fstream);
+	fstream->max_buffer_size = fstream->optimal_block_size;
+
+	ostream = _o_stream_create(&fstream->ostream);
+	ostream->offset = offset;
+	return ostream;
+}
--- a/src/lib/ostream.h	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/lib/ostream.h	Thu Aug 02 18:23:22 2007 +0300
@@ -24,7 +24,11 @@
 /* Create new output stream from given file descriptor.
    If max_buffer_size is 0, an "optimal" buffer size is used (max 128kB). */
 struct ostream *
-o_stream_create_file(int fd, size_t max_buffer_size, bool autoclose_fd);
+o_stream_create_fd(int fd, size_t max_buffer_size, bool autoclose_fd);
+/* Create an output stream from a regular file which begins at given offset.
+   If offset==(uoff_t)-1, the current offset isn't known. */
+struct ostream *
+o_stream_create_fd_file(int fd, uoff_t offset, bool autoclose_fd);
 
 /* o_stream_close() + o_stream_unref() */
 void o_stream_destroy(struct ostream **stream);
--- a/src/login-common/login-proxy.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/login-common/login-proxy.c	Thu Aug 02 18:23:22 2007 +0300
@@ -124,7 +124,7 @@
 		i_stream_create_file(proxy->server_fd, MAX_PROXY_INPUT_SIZE,
 				     FALSE);
 	proxy->server_output =
-		o_stream_create_file(proxy->server_fd, (size_t)-1, FALSE);
+		o_stream_create_fd(proxy->server_fd, (size_t)-1, FALSE);
 
 	io_remove(&proxy->server_io);
 	proxy->server_io =
--- a/src/master/auth-process.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/master/auth-process.c	Thu Aug 02 18:23:22 2007 +0300
@@ -298,7 +298,7 @@
 	p->fd = fd;
 	p->io = io_add(fd, IO_READ, auth_process_input, p);
 	p->input = i_stream_create_file(fd, MAX_INBUF_SIZE, FALSE);
-	p->output = o_stream_create_file(fd, MAX_OUTBUF_SIZE, FALSE);
+	p->output = o_stream_create_fd(fd, MAX_OUTBUF_SIZE, FALSE);
 	p->requests = hash_create(default_pool, default_pool, 0, NULL, NULL);
 
 	group->process_count++;
--- a/src/master/login-process.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/master/login-process.c	Thu Aug 02 18:23:22 2007 +0300
@@ -449,9 +449,8 @@
 	p->pid = pid;
 	p->fd = fd;
 	p->io = io_add(fd, IO_READ, login_process_input, p);
-	p->output = o_stream_create_file(fd,
-					 sizeof(struct master_login_reply)*10,
-					 FALSE);
+	p->output = o_stream_create_fd(fd, sizeof(struct master_login_reply)*10,
+				       FALSE);
 	child_process_add(pid, &p->process);
 
 	p->state = LOGIN_STATE_LISTENING;
--- a/src/plugins/acl/acl-backend-vfile-acllist.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/plugins/acl/acl-backend-vfile-acllist.c	Thu Aug 02 18:23:22 2007 +0300
@@ -208,7 +208,7 @@
 	fd = safe_mkstemp(path, mode, uid, gid);
 	if (fd == -1)
 		return -1;
-	output = o_stream_create_file(fd, 0, FALSE);
+	output = o_stream_create_fd_file(fd, 0, FALSE);
 
 	ret = 0;
 	acllist_clear(backend, 0);
--- a/src/plugins/expire/auth-client.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/plugins/expire/auth-client.c	Thu Aug 02 18:23:22 2007 +0300
@@ -47,7 +47,7 @@
 
 	conn->fd = fd;
 	conn->input = i_stream_create_file(fd, MAX_INBUF_SIZE, FALSE);
-	conn->output = o_stream_create_file(fd, MAX_OUTBUF_SIZE, FALSE);
+	conn->output = o_stream_create_fd(fd, MAX_OUTBUF_SIZE, FALSE);
 	conn->io = io_add(fd, IO_READ, auth_input, conn);
 
 	o_stream_send_str(conn->output, "VERSION\t1\t0\n");
--- a/src/plugins/fts-squat/squat-trie.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/plugins/fts-squat/squat-trie.c	Thu Aug 02 18:23:22 2007 +0300
@@ -1469,12 +1469,8 @@
 	struct squat_trie_header hdr;
 
 	hdr = *trie->hdr;
-	if (lseek(trie->fd, hdr.used_file_size, SEEK_SET) < 0) {
-		squat_trie_set_syscall_error(trie, "lseek()");
-		return -1;
-	}
-
-	ctx->output = o_stream_create_file(trie->fd, 0, FALSE);
+	ctx->output = o_stream_create_fd_file(trie->fd, (uoff_t)-1, FALSE);
+	o_stream_seek(ctx->output, hdr.used_file_size);
 	o_stream_cork(ctx->output);
 	if (hdr.used_file_size == 0) {
 		o_stream_send(ctx->output, &hdr, sizeof(hdr));
@@ -1799,7 +1795,7 @@
 	}
 
 	ctx->trie = trie;
-	ctx->output = o_stream_create_file(ctx->fd, 0, FALSE);
+	ctx->output = o_stream_create_fd_file(ctx->fd, 0, FALSE);
 	ctx->node_count = trie->hdr->node_count;
 
 	/* write a dummy header first */
--- a/src/plugins/fts-squat/squat-uidlist.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/plugins/fts-squat/squat-uidlist.c	Thu Aug 02 18:23:22 2007 +0300
@@ -580,7 +580,8 @@
 			return -1;
 	}
 
-	uidlist->output = o_stream_create_file(uidlist->fd, 0, FALSE);
+	uidlist->output =
+		o_stream_create_fd_file(uidlist->fd, (uoff_t)-1, FALSE);
 	o_stream_cork(uidlist->output);
 	if (uidlist->hdr.used_file_size < sizeof(uidlist->hdr)) {
 		/* creating a new file, write a dummy header */
@@ -760,7 +761,7 @@
 		ctx->failed = TRUE;
 		i_error("open(%s) failed: %m", ctx->tmp_path);
 	} else {
-		ctx->output = o_stream_create_file(fd, 0, TRUE);
+		ctx->output = o_stream_create_fd_file(fd, 0, TRUE);
 		o_stream_send(ctx->output, &ctx->hdr, sizeof(ctx->hdr));
 	}
 
--- a/src/pop3-login/client.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/pop3-login/client.c	Thu Aug 02 18:23:22 2007 +0300
@@ -66,7 +66,7 @@
 static void client_open_streams(struct pop3_client *client, int fd)
 {
 	client->input = i_stream_create_file(fd, MAX_INBUF_SIZE, FALSE);
-	client->output = o_stream_create_file(fd, MAX_OUTBUF_SIZE, FALSE);
+	client->output = o_stream_create_fd(fd, MAX_OUTBUF_SIZE, FALSE);
 }
 
 static void client_start_tls(struct pop3_client *client)
--- a/src/pop3/client.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/pop3/client.c	Thu Aug 02 18:23:22 2007 +0300
@@ -141,7 +141,7 @@
 	client->fd_in = fd_in;
 	client->fd_out = fd_out;
 	client->input = i_stream_create_file(fd_in, MAX_INBUF_SIZE, FALSE);
-	client->output = o_stream_create_file(fd_out, (size_t)-1, FALSE);
+	client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE);
 	o_stream_set_flush_callback(client->output, client_output, client);
 
 	client->io = io_add(fd_in, IO_READ, client_input, client);
--- a/src/util/rawlog.c	Thu Aug 02 17:35:04 2007 +0300
+++ b/src/util/rawlog.c	Thu Aug 02 18:23:22 2007 +0300
@@ -241,15 +241,14 @@
 	proxy->server_fd = server_fd;
 	proxy->server_input =
 		i_stream_create_file(server_fd, MAX_PROXY_INPUT_SIZE, FALSE);
-	proxy->server_output =
-		o_stream_create_file(server_fd, (size_t)-1, FALSE);
+	proxy->server_output = o_stream_create_fd(server_fd, (size_t)-1, FALSE);
 	proxy->server_io = io_add(server_fd, IO_READ, server_input, proxy);
 	o_stream_set_flush_callback(proxy->server_output, server_output, proxy);
 
 	proxy->client_in_fd = client_in_fd;
 	proxy->client_out_fd = client_out_fd;
 	proxy->client_output =
-		o_stream_create_file(client_out_fd, (size_t)-1, FALSE);
+		o_stream_create_fd(client_out_fd, (size_t)-1, FALSE);
 	proxy->client_io = io_add(proxy->client_in_fd, IO_READ,
 				  client_input, proxy);
 	o_stream_set_flush_callback(proxy->client_output, client_output, proxy);