• src/sbbs3/chksmb.c fixsmb

    From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Tue Sep 22 20:05:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/531bd654b515fc1f6b790d89
    Modified Files:
    src/sbbs3/chksmb.c fixsmb.c smbutil.c src/smblib/smballoc.c smblib.c Log Message:
    smblib: read/write data allocation records a run at a time

    smb_incdat() and smb_freemsgdat() updated the .sda allocation table one
    2-byte record per 256-byte data block: seek, read, seek back, write. Each
    seek discards the stdio buffer, so every block cost its own read() and
    write() syscall. On a message base served over SMB/CIFS (e.g. with Samba
    "sync always"), each of those writes is a synchronous round trip to the
    file server: rebuilding an 820MB mail base with fixsmb took ~13 minutes
    at ~3,700 writes/sec, holding the base locked the whole time.

    Now the whole run of records for a data field is read with one fread(), adjusted in memory, and written back with one fwrite(). smb_freemsgdat()
    still truncates completely-freed records from the end of the .sda file.

    Measured on a copy of the same mail base, with byte-identical results
    versus the old code:
    fixsmb: 3,079,001 -> 58,663 write() calls
    smbutil m: 1,673,481 -> 39,340 write() calls

    This benefits every message delete/maint/pack as well as fixsmb.

    Bump SMBLIB, FIXSMB, CHKSMB and SMBUTIL to v3.22 (unchanged since the
    v3.21e release). The SMB format version is unchanged.

    Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Tue Sep 29 19:00:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/343738828ef6d998fea6a281
    Modified Files:
    src/sbbs3/chksmb.c fixsmb.c smbutil.c src/smblib/smblib.c smblib.h
    Log Message:
    fixsmb/chksmb/smbutil: don't skip headers after a corrupt one

    fixsmb, chksmb and the analysis pass of smbutil pack step from one header
    to the next by the header's calculated length (the sum of its fields).
    When a header is damaged so that its fields add up to more than its stored length (a field length overwritten, or its tail zeroed), that step jumps
    over the headers that follow: fixsmb leaves them out of the index it
    rebuilds, and chksmb neither counts them nor reports them as orphaned.

    New smb_msghdrblocks() returns the blocks a header occupies for this
    purpose: the lesser of its stored and calculated lengths, and at least one block. The two differ only for a damaged header; a header is rewritten in
    place only when its new length fits in the blocks it already has.

    fixsmb also treated a live header as a duplicate, and left it out of the
    index, when a deleted header with the same message number came before it.
    That is the normal state of a header that grew and was relocated (the old
    copy is marked deleted), so such messages were dropped from the rebuilt
    index. Deleted headers no longer count toward duplicate numbers, unless -undelete is given.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net