Lines Matching refs:box

570 void mailbox_set_critical(struct mailbox *box, const char *fmt, ...)
576 mail_storage_set_critical(box->storage, "Mailbox %s: %s",
577 box->vname, t_strdup_vprintf(fmt, va));
589 mailbox_set_critical(mail->box, "Saving mail: %s",
592 mailbox_set_critical(mail->box, "UID=%u: %s",
611 const char *mailbox_get_last_internal_error(struct mailbox *box,
614 return mail_storage_get_last_internal_error(mailbox_get_storage(box),
641 void mailbox_set_index_error(struct mailbox *box)
643 if (mail_index_is_deleted(box->index)) {
644 mailbox_set_deleted(box);
645 mail_index_reset_error(box->index);
647 mail_storage_set_index_error(box->storage, box->index);
716 const char *mailbox_get_last_error(struct mailbox *box,
719 return mail_storage_get_last_error(box->storage, error_r);
722 enum mail_error mailbox_get_last_mail_error(struct mailbox *box)
726 mail_storage_get_last_error(box->storage, &error);
812 struct mailbox *box;
848 box = storage->v.mailbox_alloc(storage, new_list, vname, flags);
849 box->set = mailbox_settings_find(new_list->ns, vname);
850 box->open_error = open_error;
853 hook_mailbox_allocated(box);
856 DLLIST_PREPEND(&box->storage->mailboxes, box);
857 mail_storage_obj_ref(box->storage);
858 return box;
865 struct mailbox *box = NULL;
873 box = mailbox_alloc(list, vname, flags);
874 if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID,
879 mailbox_free(&box);
884 return box;
889 mailbox_get_last_internal_error(box, NULL));
891 mailbox_free(&box);
902 box = mailbox_alloc(list, vname, flags);
903 box->open_error = open_error;
904 return box;
933 void mailbox_set_reason(struct mailbox *box, const char *reason)
937 box->reason = p_strdup(box->pool, reason);
940 bool mailbox_is_autocreated(struct mailbox *box)
942 if (box->inbox_user)
944 if ((box->flags & MAILBOX_FLAG_AUTO_CREATE) != 0)
946 return box->set != NULL &&
947 strcmp(box->set->autocreate, MAILBOX_SET_AUTO_NO) != 0;
950 bool mailbox_is_autosubscribed(struct mailbox *box)
952 if ((box->flags & MAILBOX_FLAG_AUTO_SUBSCRIBE) != 0)
954 return box->set != NULL &&
955 strcmp(box->set->autocreate, MAILBOX_SET_AUTO_SUBSCRIBE) == 0;
958 static int mailbox_autocreate(struct mailbox *box)
963 if (mailbox_create(box, NULL, FALSE) < 0) {
964 errstr = mailbox_get_last_internal_error(box, &error);
966 mailbox_set_critical(box,
971 } else if (mailbox_is_autosubscribed(box)) {
972 if (mailbox_set_subscribed(box, TRUE) < 0) {
973 mailbox_set_critical(box,
975 mailbox_get_last_internal_error(box, NULL));
982 static int mailbox_autocreate_and_reopen(struct mailbox *box)
986 if (mailbox_autocreate(box) < 0)
988 mailbox_close(box);
990 ret = box->v.open(box);
991 if (ret < 0 && box->inbox_user &&
992 !box->storage->user->inbox_open_error_logged) {
993 box->storage->user->inbox_open_error_logged = TRUE;
994 mailbox_set_critical(box,
996 mailbox_get_last_internal_error(box, NULL));
1036 mailbox_verify_name_prefix(struct mailbox *box, const char **error_r)
1038 const char *vname = box->vname;
1039 struct mail_namespace *ns = box->list->ns;
1044 /* vname is either "namespace/box" or "namespace" */
1070 int mailbox_verify_name(struct mailbox *box)
1072 struct mail_namespace *ns = box->list->ns;
1073 const char *error, *vname = box->vname;
1076 if (box->inbox_user) {
1081 if (!mailbox_verify_name_prefix(box, &error)) {
1082 mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS,
1088 list_sep = mailbox_list_get_hierarchy_sep(box->list);
1097 if (ns_sep != list_sep && box->list->set.escape_char == '\0' &&
1099 mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS, t_strdup_printf(
1108 !box->storage->set->mail_full_filesystem_access) {
1109 mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS,
1115 !mailbox_list_is_valid_name(box->list, box->name, &error)) {
1116 mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS,
1123 static int mailbox_verify_existing_name(struct mailbox *box)
1127 if (box->opened)
1130 if (mailbox_verify_name(box) < 0)
1133 /* Make sure box->_path is set, so mailbox_get_path() works from
1136 if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, &path) < 0) {
1137 if (box->storage->error != MAIL_ERROR_NOTFOUND ||
1138 !mailbox_is_autocreated(box))
1141 if (mailbox_autocreate(box) < 0)
1143 mailbox_close(box);
1144 if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX,
1162 void mailbox_skip_create_name_restrictions(struct mailbox *box, bool set)
1164 box->skip_create_name_restrictions = set;
1167 int mailbox_verify_create_name(struct mailbox *box)
1174 if (mailbox_verify_name(box) < 0)
1176 if (box->skip_create_name_restrictions)
1178 if (mailbox_name_has_control_chars(box->vname)) {
1179 mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS,
1183 if (strlen(box->vname) > MAILBOX_LIST_NAME_MAX_LENGTH) {
1184 mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS,
1189 const char *old_name = box->name;
1191 const char sep = mailbox_list_get_hierarchy_sep(box->list);
1194 mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS,
1202 mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS,
1231 int mailbox_exists(struct mailbox *box, bool auto_boxes,
1234 switch (box->open_error) {
1244 if (mailbox_verify_name(box) < 0) {
1252 if (auto_boxes && mailbox_is_autocreated(box)) {
1257 if (box->v.exists(box, auto_boxes, existence_r) < 0)
1260 if (!box->inbox_user && *existence_r == MAILBOX_EXISTENCE_NOSELECT &&
1261 have_listable_namespace_prefix(box->storage->user->namespaces,
1262 box->vname)) {
1271 box->list->ns->flags |= NAMESPACE_FLAG_USABLE;
1276 mailbox_open_full(struct mailbox *box, struct istream *input)
1280 if (box->opened)
1283 if (box->storage->set->mail_debug && box->reason != NULL) {
1285 box->vname, box->reason);
1288 switch (box->open_error) {
1292 mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
1293 T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
1296 mail_storage_set_internal_error(box->storage);
1297 box->storage->error = box->open_error;
1301 if (mailbox_verify_existing_name(box) < 0)
1305 if ((box->storage->class_flags &
1307 mailbox_set_critical(box,
1311 box->input = input;
1312 box->flags |= MAILBOX_FLAG_READONLY;
1313 i_stream_ref(box->input);
1317 ret = box->v.open(box);
1320 if (ret < 0 && box->storage->error == MAIL_ERROR_NOTFOUND &&
1321 !box->deleting && !box->creating &&
1322 box->input == NULL && mailbox_is_autocreated(box)) T_BEGIN {
1323 ret = mailbox_autocreate_and_reopen(box);
1327 if (box->input != NULL)
1328 i_stream_unref(&box->input);
1332 box->list->ns->flags |= NAMESPACE_FLAG_USABLE;
1336 static bool mailbox_try_undelete(struct mailbox *box)
1340 i_assert(!box->mailbox_undeleting);
1342 if ((box->flags & MAILBOX_FLAG_READONLY) != 0) {
1349 if (mail_index_get_modification_time(box->index, &mtime) < 0)
1354 box->mailbox_undeleting = TRUE;
1355 int ret = mailbox_mark_index_deleted(box, FALSE);
1356 box->mailbox_undeleting = FALSE;
1359 box->mailbox_deleted = FALSE;
1363 int mailbox_open(struct mailbox *box)
1366 if (((box->flags & MAILBOX_FLAG_USE_STUBS) != 0) &&
1367 ((box->storage->storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_STUBS) == 0)) {
1368 mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
1373 if (mailbox_open_full(box, NULL) < 0) {
1374 if (!box->mailbox_deleted || box->mailbox_undeleting)
1381 if(!mailbox_try_undelete(box))
1387 mailbox_close(box);
1388 if (mailbox_open_full(box, NULL) < 0)
1394 static int mailbox_alloc_index_pvt(struct mailbox *box)
1399 if (box->index_pvt != NULL)
1402 ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE,
1407 if (mailbox_create_missing_dir(box, MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE) < 0)
1410 box->index_pvt = mail_index_alloc_cache_get(box->storage->user->event,
1411 NULL, index_dir, t_strconcat(box->index_prefix, ".pvt", NULL));
1412 mail_index_set_fsync_mode(box->index_pvt,
1413 box->storage->set->parsed_fsync_mode, 0);
1414 mail_index_set_lock_method(box->index_pvt,
1415 box->storage->set->parsed_lock_method,
1416 mail_storage_get_lock_timeout(box->storage, UINT_MAX));
1420 int mailbox_open_index_pvt(struct mailbox *box)
1425 if (box->view_pvt != NULL)
1427 if (mailbox_get_private_flags_mask(box) == 0)
1430 if ((ret = mailbox_alloc_index_pvt(box)) <= 0)
1433 mail_storage_settings_to_index_flags(box->storage->set);
1434 if ((box->flags & MAILBOX_FLAG_SAVEONLY) != 0)
1436 if (mail_index_open(box->index_pvt, index_flags) < 0)
1438 box->view_pvt = mail_index_view_open(box->index_pvt);
1442 int mailbox_open_stream(struct mailbox *box, struct istream *input)
1444 return mailbox_open_full(box, input);
1447 int mailbox_enable(struct mailbox *box, enum mailbox_feature features)
1449 if (mailbox_verify_name(box) < 0)
1451 return box->v.enable(box, features);
1454 enum mailbox_feature mailbox_get_enabled_features(struct mailbox *box)
1456 return box->enabled_features;
1461 if (storage->binary_cache.box == NULL)
1469 void mailbox_close(struct mailbox *box)
1471 if (!box->opened)
1474 if (box->transaction_count != 0) {
1476 box->name);
1478 box->v.close(box);
1480 if (box->storage->binary_cache.box == box)
1481 mail_storage_free_binary_cache(box->storage);
1482 box->opened = FALSE;
1483 box->mailbox_deleted = FALSE;
1484 array_clear(&box->search_results);
1486 if (array_is_created(&box->recent_flags))
1487 array_free(&box->recent_flags);
1488 box->recent_flags_prev_uid = 0;
1489 box->recent_flags_count = 0;
1494 struct mailbox *box = *_box;
1498 mailbox_close(box);
1499 box->v.free(box);
1501 if (box->attribute_iter_count != 0) {
1503 box->name, box->attribute_iter_count);
1506 DLLIST_REMOVE(&box->storage->mailboxes, box);
1507 mail_storage_obj_unref(box->storage);
1508 pool_unref(&box->metadata_pool);
1509 pool_unref(&box->pool);
1529 bool mailbox_is_any_inbox(struct mailbox *box)
1531 return box->inbox_any;
1534 static void mailbox_copy_cache_decisions_from_inbox(struct mailbox *box)
1537 mail_namespace_find_inbox(box->storage->user->namespaces);
1548 mailbox_open(box) == 0) {
1550 mail_index_transaction_begin(box->view,
1553 mail_cache_decisions_copy(dit, inbox->cache, box->cache);
1562 int mailbox_create(struct mailbox *box, const struct mailbox_update *update,
1567 if (mailbox_verify_create_name(box) < 0)
1575 if (mailbox_list_lock(box->list) < 0) {
1576 mail_storage_copy_list_error(box->storage, box->list);
1579 box->creating = TRUE;
1580 ret = box->v.create_box(box, update, directory);
1581 box->creating = FALSE;
1582 mailbox_list_unlock(box->list);
1585 box->list->guid_cache_updated = TRUE;
1586 if (!box->inbox_any)
1587 mailbox_copy_cache_decisions_from_inbox(box);
1588 } else if (box->opened) {
1591 mail_storage_last_error_push(box->storage);
1592 mailbox_close(box);
1593 mail_storage_last_error_pop(box->storage);
1598 int mailbox_update(struct mailbox *box, const struct mailbox_update *update)
1606 if (mailbox_verify_existing_name(box) < 0)
1608 ret = box->v.update_box(box, update);
1610 box->list->guid_cache_invalidated = TRUE;
1614 int mailbox_mark_index_deleted(struct mailbox *box, bool del)
1621 if (box->marked_deleted && del) {
1627 old_flag = box->flags & MAILBOX_FLAG_OPEN_DELETED;
1628 box->flags |= MAILBOX_FLAG_OPEN_DELETED;
1629 ret = mailbox_open(box);
1630 box->flags = (box->flags & ~MAILBOX_FLAG_OPEN_DELETED) | old_flag;
1635 trans = mail_index_transaction_begin(box->view, trans_flags);
1641 mailbox_set_index_error(box);
1650 box->delete_sync_check = TRUE;
1651 ret = mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ);
1652 box->delete_sync_check = FALSE;
1657 box->marked_deleted = del;
1661 static void mailbox_close_reset_path(struct mailbox *box)
1663 i_zero(&box->_perm);
1664 box->_path = NULL;
1665 box->_index_path = NULL;
1668 int mailbox_delete(struct mailbox *box)
1673 if (*box->name == '\0') {
1674 mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS,
1679 box->deleting = TRUE;
1680 if (mailbox_open(box) < 0) {
1681 if (mailbox_get_last_mail_error(box) != MAIL_ERROR_NOTFOUND &&
1682 !box->mailbox_deleted)
1687 if (mailbox_list_lock(box->list) < 0) {
1688 mail_storage_copy_list_error(box->storage, box->list);
1693 ret = box->v.delete_box(box);
1695 if (ret < 0 && box->marked_deleted) {
1698 if (mailbox_mark_index_deleted(box, FALSE) < 0)
1702 mailbox_list_unlock(box->list);
1704 box->deleting = FALSE;
1705 mailbox_close(box);
1709 mailbox_close_reset_path(box);
1713 int mailbox_delete_empty(struct mailbox *box)
1719 box->deleting_must_be_empty = TRUE;
1720 ret = mailbox_delete(box);
1721 box->deleting_must_be_empty = FALSE;
1878 int mailbox_set_subscribed(struct mailbox *box, bool set)
1880 if (mailbox_verify_name(box) < 0)
1882 if (mailbox_list_iter_subscriptions_refresh(box->list) < 0) {
1883 mail_storage_copy_list_error(box->storage, box->list);
1886 if (mailbox_is_subscribed(box) == set)
1888 return box->v.set_subscribed(box, set);
1891 bool mailbox_is_subscribed(struct mailbox *box)
1895 i_assert(box->list->subscriptions != NULL);
1897 node = mailbox_tree_lookup(box->list->subscriptions, box->vname);
1901 struct mail_storage *mailbox_get_storage(const struct mailbox *box)
1903 return box->storage;
1907 mailbox_get_namespace(const struct mailbox *box)
1909 return box->list->ns;
1912 const struct mail_storage_settings *mailbox_get_settings(struct mailbox *box)
1914 return box->storage->set;
1917 const char *mailbox_get_name(const struct mailbox *box)
1919 return box->name;
1922 const char *mailbox_get_vname(const struct mailbox *box)
1924 return box->vname;
1927 bool mailbox_is_readonly(struct mailbox *box)
1929 i_assert(box->opened);
1931 return box->v.is_readonly(box);
1950 mailbox_get_status_set_defaults(struct mailbox *box,
1954 if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS) != 0)
1956 if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS) != 0)
1958 if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUID128) != 0)
1962 int mailbox_get_status(struct mailbox *box,
1966 mailbox_get_status_set_defaults(box, status_r);
1967 if (mailbox_verify_existing_name(box) < 0)
1970 if (box->v.get_status(box, items, status_r) < 0)
1976 void mailbox_get_open_status(struct mailbox *box,
1980 i_assert(box->opened);
1983 mailbox_get_status_set_defaults(box, status_r);
1984 if (box->v.get_status(box, items, status_r) < 0)
1988 int mailbox_get_metadata(struct mailbox *box, enum mailbox_metadata_items items,
1992 if (mailbox_verify_existing_name(box) < 0)
1995 if (box->metadata_pool != NULL)
1996 p_clear(box->metadata_pool);
1998 if (box->v.get_metadata(box, items, metadata_r) < 0)
2006 enum mail_flags mailbox_get_private_flags_mask(struct mailbox *box)
2008 if (box->v.get_private_flags_mask != NULL)
2009 return box->v.get_private_flags_mask(box);
2010 else if (box->list->set.index_pvt_dir != NULL)
2017 mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
2021 if (box->transaction_count != 0) {
2023 box->name);
2025 if (!box->opened) {
2026 if (mailbox_open(box) < 0) {
2028 ctx->box = box;
2035 ctx = box->v.sync_init(box, flags);
2045 return ctx->box->v.sync_next(ctx, sync_rec_r);
2052 struct mailbox *box = ctx->box;
2062 ret = box->v.sync_deinit(ctx, status_r);
2067 if (ret < 0 && box->inbox_user &&
2068 !box->storage->user->inbox_open_error_logged) {
2069 errormsg = mailbox_get_last_internal_error(box, &error);
2071 box->storage->user->inbox_open_error_logged = TRUE;
2076 box->synced = TRUE;
2080 int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags)
2085 if (array_count(&box->search_results) == 0) {
2091 ctx = mailbox_sync_init(box, flags);
2096 void mailbox_notify_changes(struct mailbox *box,
2099 i_assert(box->opened);
2101 box->notify_callback = callback;
2102 box->notify_context = context;
2104 box->v.notify_changes(box);
2107 void mailbox_notify_changes_stop(struct mailbox *box)
2109 i_assert(box->opened);
2111 box->notify_callback = NULL;
2112 box->notify_context = NULL;
2114 box->v.notify_changes(box);
2124 i_assert(wanted_headers == NULL || wanted_headers->box == t->box);
2129 return t->box->v.search_init(t, args, sort_program,
2141 ret = ctx->transaction->box->v.search_deinit(ctx);
2160 struct mailbox *box = ctx->transaction->box;
2165 if (!box->v.search_next_nonblock(ctx, mail_r, tryagain_r))
2198 mailbox_transaction_begin(struct mailbox *box,
2205 (box->flags & MAILBOX_FLAG_USE_STUBS) != 0);
2207 i_assert(box->opened);
2209 box->transaction_count++;
2210 trans = box->v.transaction_begin(box, flags, reason);
2232 struct mailbox *box = t->box;
2240 ret = box->v.transaction_commit(t, changes_r);
2252 box->transaction_count--;
2261 struct mailbox *box = t->box;
2264 box->v.transaction_rollback(t);
2265 box->transaction_count--;
2268 unsigned int mailbox_transaction_get_count(const struct mailbox *box)
2270 return box->transaction_count;
2283 return t->box;
2298 mailbox_get_settings(t->box);
2300 ctx = t->box->v.save_alloc(t);
2335 struct mailbox *box = ctx->transaction->box;
2340 ctx->data.flags = flags & ~mailbox_get_private_flags_mask(box);
2341 ctx->data.pvt_flags = flags & mailbox_get_private_flags_mask(box);
2354 mailbox_keywords_create_valid(ctx->transaction->box,
2429 struct mailbox *box = (*ctx)->transaction->box;
2432 if (mail_index_is_deleted(box->index)) {
2433 mailbox_set_deleted(box);
2452 if (box->v.save_begin == NULL) {
2453 mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
2457 ret = box->v.save_begin(*ctx, input);
2472 ret = ctx->transaction->box->v.save_continue(ctx);
2515 mailbox_get_settings(t->box);
2536 ret = t->box->v.save_finish(ctx);
2563 ctx->transaction->box->v.save_cancel(ctx);
2593 if (mail_index_is_deleted(t->box->index)) {
2594 mailbox_set_deleted(t->box);
2612 ret = t->box->v.copy(ctx, backend_mail);
2667 bool mailbox_is_inconsistent(struct mailbox *box)
2669 return box->mailbox_deleted || box->v.is_inconsistent(box);
2672 void mailbox_set_deleted(struct mailbox *box)
2674 mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
2676 box->mailbox_deleted = TRUE;
2679 static int get_path_to(struct mailbox *box, enum mailbox_list_path_type type,
2692 ret = mailbox_list_get_path(box->list, box->name, type, path_r);
2694 mail_storage_copy_list_error(box->storage, box->list);
2698 *internal_path = ret == 0 ? "" : p_strdup(box->pool, *path_r);
2702 int mailbox_get_path_to(struct mailbox *box, enum mailbox_list_path_type type,
2706 return get_path_to(box, type, &box->_path, path_r);
2708 return get_path_to(box, type, &box->_index_path, path_r);
2709 return get_path_to(box, type, NULL, path_r);
2712 const char *mailbox_get_path(struct mailbox *box)
2714 i_assert(box->_path != NULL);
2715 i_assert(box->_path[0] != '\0');
2716 return box->_path;
2719 const char *mailbox_get_index_path(struct mailbox *box)
2721 i_assert(box->_index_path != NULL);
2722 i_assert(box->_index_path[0] != '\0');
2723 return box->_index_path;
2726 static void mailbox_get_permissions_if_not_set(struct mailbox *box)
2728 if (box->_perm.file_create_mode != 0)
2731 if (box->input != NULL) {
2732 box->_perm.file_uid = geteuid();
2733 box->_perm.file_create_mode = 0600;
2734 box->_perm.dir_create_mode = 0700;
2735 box->_perm.file_create_gid = (gid_t)-1;
2736 box->_perm.file_create_gid_origin = "defaults";
2741 mailbox_list_get_permissions(box->list, box->name, &perm);
2742 mailbox_permissions_copy(&box->_perm, &perm, box->pool);
2745 const struct mailbox_permissions *mailbox_get_permissions(struct mailbox *box)
2747 mailbox_get_permissions_if_not_set(box);
2749 if (!box->_perm.mail_index_permissions_set && box->index != NULL) {
2750 box->_perm.mail_index_permissions_set = TRUE;
2751 mail_index_set_permissions(box->index,
2752 box->_perm.file_create_mode,
2753 box->_perm.file_create_gid,
2754 box->_perm.file_create_gid_origin);
2756 return &box->_perm;
2759 void mailbox_refresh_permissions(struct mailbox *box)
2761 i_zero(&box->_perm);
2762 (void)mailbox_get_permissions(box);
2765 int mailbox_create_fd(struct mailbox *box, const char *path, int flags,
2768 const struct mailbox_permissions *perm = mailbox_get_permissions(box);
2786 mailbox_set_deleted(box);
2789 mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
2792 } else if (mail_storage_set_error_from_errno(box->storage)) {
2795 mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", path);
2803 mailbox_set_critical(box, "%s",
2808 mailbox_set_critical(box,
2816 int mailbox_mkdir(struct mailbox *box, const char *path,
2819 const struct mailbox_permissions *perm = mailbox_get_permissions(box);
2824 root_dir = mailbox_list_get_root_forced(box->list, type);
2825 if (mailbox_list_mkdir_root(box->list, root_dir, type) < 0) {
2826 mail_storage_copy_list_error(box->storage, box->list);
2838 mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
2841 } else if (mail_storage_set_error_from_errno(box->storage)) {
2844 mailbox_set_critical(box, "mkdir_parents(%s) failed: %m", path);
2849 int mailbox_create_missing_dir(struct mailbox *box,
2856 if ((ret = mailbox_get_path_to(box, type, &dir)) <= 0)
2858 if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX,
2863 } else if ((box->list->props & MAILBOX_LIST_PROP_AUTOCREATE_DIRS) != 0) {
2878 if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) == 0 &&
2884 mailbox_set_deleted(box);
2888 return mailbox_mkdir(box, dir, type);
2969 mailbox_set_index_error(mail->box);
3021 int mailbox_lock_file_create(struct mailbox *box, const char *lock_fname,
3029 perm = mailbox_get_permissions(box);
3032 mail_storage_get_lock_timeout(box->storage, lock_secs);
3033 set.lock_method = box->storage->set->parsed_lock_method;
3038 if (box->list->set.volatile_dir == NULL)
3039 lock_path = t_strdup_printf("%s/%s", box->index->dir, lock_fname);
3050 str_printfa(str, "%s/%s.", box->list->set.volatile_dir,
3052 sha1_get_digest(box->name, strlen(box->name), box_name_sha1);
3059 box->storage->set, lock_r, error_r);