[dovecot-cvs] dovecot/src/lib-index mail-custom-flags.c,1.20,1.21
cras at procontrol.fi
cras at procontrol.fi
Sun May 18 16:56:17 EEST 2003
- Previous message: [dovecot-cvs]
dovecot/src/lib-index/maildir maildir-expunge.c,NONE,1.1
maildir-update-flags.c,NONE,1.1 Makefile.am,1.6,1.7
maildir-build.c,1.22,1.23 maildir-index.c,1.29,1.30
maildir-index.h,1.20,1.21 maildir-open.c,1.15,1.16
maildir-sync.c,1.39,1.40 maildir-uidlist.c,1.4,1.5
- Next message: [dovecot-cvs]
dovecot/src/lib-index/maildir maildir-index.c,1.30,1.31
maildir-sync.c,1.40,1.41 maildir-uidlist.c,1.5,1.6
maildir-update-flags.c,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv295/lib-index
Modified Files:
mail-custom-flags.c
Log Message:
Some fixes to handling read-only maildirs.
Index: mail-custom-flags.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-custom-flags.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mail-custom-flags.c 17 May 2003 13:09:54 -0000 1.20
+++ mail-custom-flags.c 18 May 2003 12:56:14 -0000 1.21
@@ -62,7 +62,10 @@
index_cf_set_syscall_error(mcf, "munmap()");
}
- mcf->mmap_base = mmap_rw_file(mcf->fd, &mcf->mmap_length);
+
+ mcf->mmap_base = mcf->noupdate ?
+ mmap_ro_file(mcf->fd, &mcf->mmap_length) :
+ mmap_rw_file(mcf->fd, &mcf->mmap_length);
if (mcf->mmap_base == MAP_FAILED) {
mcf->mmap_base = NULL;
return index_cf_set_syscall_error(mcf, "mmap()");
@@ -166,7 +169,7 @@
static int custom_flags_check_sync(struct mail_custom_flags *mcf)
{
- if (mcf->noupdate)
+ if (mcf->fd == -1)
return TRUE;
if (mcf->mmap_length != 0 &&
@@ -177,7 +180,7 @@
if (!update_mmap(mcf))
return FALSE;
- if (mcf->mmap_length < HEADER_SIZE) {
+ if (mcf->mmap_length < HEADER_SIZE && !mcf->noupdate) {
/* it's broken, rewrite header */
if (mcf->lock_type == F_RDLCK)
(void)lock_file(mcf, F_UNLCK);
@@ -236,41 +239,49 @@
{
struct mail_custom_flags *mcf;
const char *path;
- int fd;
+ int fd, readonly;
path = t_strconcat(index->control_dir, "/",
CUSTOM_FLAGS_FILE_NAME, NULL);
- if (path == NULL)
- fd = -1;
- else {
- fd = open(path, O_RDWR | O_CREAT, 0660);
- if (fd == -1)
+ readonly = index->mailbox_readonly;
+ fd = !index->mailbox_readonly ?
+ open(path, O_RDWR | O_CREAT, 0660) : open(path, O_RDONLY);
+ if (fd == -1) {
+ if (errno == EACCES) {
+ fd = open(path, O_RDONLY);
+ readonly = TRUE;
+ }
+ if (errno != EACCES && errno != ENOENT && !ENOSPACE(errno)) {
index_file_set_syscall_error(index, path, "open()");
+ return FALSE;
+ }
}
mcf = i_new(struct mail_custom_flags, 1);
mcf->index = index;
mcf->filepath = i_strdup(path);
mcf->fd = fd;
+ mcf->noupdate = mcf->fd == -1 || readonly;
if (fd != -1) {
if (!update_mmap(mcf)) {
(void)close(mcf->fd);
mcf->fd = -1;
+ mcf->noupdate = TRUE;
}
- if (mcf->mmap_length < HEADER_SIZE) {
+ if (mcf->mmap_length < HEADER_SIZE && !mcf->noupdate) {
/* we just created it, write the header */
mcf->syncing = TRUE;
if (!custom_flags_init(mcf) || !update_mmap(mcf)) {
(void)close(mcf->fd);
mcf->fd = -1;
+ mcf->noupdate = TRUE;
}
mcf->syncing = FALSE;
}
}
- mcf->noupdate = mcf->fd == -1;
mcf->index->allow_new_custom_flags = mcf->fd != -1;
custom_flags_sync(mcf);
- Previous message: [dovecot-cvs]
dovecot/src/lib-index/maildir maildir-expunge.c,NONE,1.1
maildir-update-flags.c,NONE,1.1 Makefile.am,1.6,1.7
maildir-build.c,1.22,1.23 maildir-index.c,1.29,1.30
maildir-index.h,1.20,1.21 maildir-open.c,1.15,1.16
maildir-sync.c,1.39,1.40 maildir-uidlist.c,1.4,1.5
- Next message: [dovecot-cvs]
dovecot/src/lib-index/maildir maildir-index.c,1.30,1.31
maildir-sync.c,1.40,1.41 maildir-uidlist.c,1.5,1.6
maildir-update-flags.c,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list