コード例 #1
0
static int
maildir_fill_readdir(struct maildir_list_iterate_context *ctx,
		     struct imap_match_glob *glob, bool update_only)
{
	struct mailbox_list *list = ctx->ctx.list;
	struct mail_namespace *ns = list->ns;
	DIR *dirp;
	struct dirent *d;
	const char *vname;
	int ret = 0;

	dirp = opendir(ctx->dir);
	if (dirp == NULL) {
		if (errno == EACCES) {
			mailbox_list_set_critical(list, "%s",
				mail_error_eacces_msg("opendir", ctx->dir));
		} else if (errno != ENOENT) {
			mailbox_list_set_critical(list,
				"opendir(%s) failed: %m", ctx->dir);
			return -1;
		}
		return 0;
	}

	while ((d = readdir(dirp)) != NULL) {
		T_BEGIN {
			ret = maildir_fill_readdir_entry(ctx, glob, d,
							 update_only);
		} T_END;
		if (ret < 0)
			break;
	}

	if (closedir(dirp) < 0) {
		mailbox_list_set_critical(list, "readdir(%s) failed: %m",
					  ctx->dir);
		return -1;
	}
	if (ret < 0)
		return -1;

	if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
		/* make sure INBOX is listed */
		return maildir_fill_inbox(ctx, glob, "INBOX", update_only);
	} else if ((ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
		/* show shared INBOX. */
		vname = mailbox_list_get_vname(ns->list, "INBOX");
		return maildir_fill_inbox(ctx, glob, vname, update_only);
	} else {
		return 0;
	}
}
コード例 #2
0
ファイル: maildir-mail.c プロジェクト: IvanKharpalev/core
static int
do_stat(struct maildir_mailbox *mbox, const char *path, struct stat *st)
{
	if (stat(path, st) == 0)
		return 1;
	if (errno == ENOENT)
		return 0;

	if (errno == EACCES) {
		mail_storage_set_critical(&mbox->storage->storage, "%s",
			mail_error_eacces_msg("stat", path));
	} else {
		mail_storage_set_critical(&mbox->storage->storage,
					  "stat(%s) failed: %m", path);
	}
	return -1;
}
コード例 #3
0
ファイル: maildir-mail.c プロジェクト: IvanKharpalev/core
static int
do_open(struct maildir_mailbox *mbox, const char *path,
	struct maildir_open_context *ctx)
{
	ctx->fd = nfs_safe_open(path, O_RDONLY);
	if (ctx->fd != -1) {
		ctx->path = i_strdup(path);
		return 1;
	}
	if (errno == ENOENT)
		return 0;

	if (errno == EACCES) {
		mail_storage_set_critical(&mbox->storage->storage, "%s",
			mail_error_eacces_msg("open", path));
	} else {
		mail_storage_set_critical(&mbox->storage->storage,
					  "open(%s) failed: %m", path);
	}
	return -1;
}