EXPORTED int mailbox_reload_index_record_dirty(struct mailbox *mailbox,
                                               struct index_record *record)
{
    unsigned recno = record->recno;
    unsigned offset = mailbox->i.start_offset + (recno-1) * mailbox->i.record_size;

    if (offset + mailbox->i.record_size > mailbox->index_size) {
        xsyslog(LOG_ERR, "IOERROR: index record past end of file",
                         "mailbox=<%s> record=<%u>",
                         mailbox_name(mailbox), recno);
        return IMAP_IOERROR;
    }

    const char *buf = mailbox->index_base + offset;
    mailbox_buf_to_index_record(buf, mailbox->i.minor_version, record, 1);
    record->recno = recno;

    return 0;
}
EXPORTED int mailbox_reload_index_record_dirty(struct mailbox *mailbox,
                                               struct index_record *record)
{
    unsigned recno = record->recno;
    unsigned offset = mailbox->i.start_offset + (recno-1) * mailbox->i.record_size;

    if (offset + mailbox->i.record_size > mailbox->index_size) {
        xsyslog(LOG_ERR, "IOERROR: index record past end of file",
                         "mailbox=<%s> record=<%u>",
                         mailbox_name(mailbox), recno);
        return IMAP_IOERROR;
    }

    const char *buf = mailbox->index_base + offset;
    mailbox_buf_to_index_record(buf, mailbox->i.minor_version, record, 1);
    record->recno = recno;

    return 0;
}