LC_SYNC(3)
π¦ LC_SYNC(3) β bestie edition π¦
okay so this is page LC_SYNC(3) from the Librecast Programmer's Manual, and it's literally the page where you learn to sync memory or files over multicast. no cap, it's giving main character energy for distributed data. π
β¨ NAME β¨
lc_sync, lc_syncfile β synchronize memory or files over multicast
π LIBRARY π
Librecast library (liblibrecast, -llibrecast)
π SYNOPSIS π
#include <librecast/sync.h>
ssize_t lc_sync(lc_ctx_t *lctx, unsigned char *hash, void *data, const size_t len,
q_t *q, lc_stat_t *stats, lc_sync_options_t *opt, int flags);
ssize_t lc_syncfile(lc_ctx_t *lctx, unsigned char *hash, const char *pathname,
q_t *q, lc_stat_t *stats, lc_sync_options_t *opt, int flags);
ssize_t lc_syncfilehash(lc_ctx_t *lctx, unsigned char *hash, const char *dst,
q_t *q, lc_stat_t *stats, lc_sync_options_t *opt, int flags);
Compile and link with -llibrecast.
heads up bestie: when you build, you compile and link with -llibrecast. that's the whole vibe. π«Ά
π DESCRIPTION π
so what do these even do
The lc_sync() function synchronizes the memory area pointed to by data of length len with data fetched from the network. π
The lc_syncfile() function synchronizes the file at pathname with data fetched from the network. The file will be created if it does not exist. β¨
The lc_syncfile_hash() function synchronizes the file at pathname with data fetched from the network. The file will be created if it does not exist. If a trailing slash is present it is parsed and removed before calling lc_syncfile(3). Similar to rsync(3), the presence of a trailing slash on the source directory indicates that the directories synced are at the same level. The absence of a trailing slash on the source will cause the directory to be created as a subdirectory on the destination. (yes this is the exact same energy as rsync's slash drama, iykyk π)
the merkle tree of it all π³
hash is used to create the multicast address from which to fetch the merkle tree of the source data. This tree is compared to the merkle tree of the memory at data to find which chunks differ, and these chunks are fetched from the network using their hashes to create the multicast source addresses. obsessed with this actually. π₯
the arguments, one by one π§
lctxβ a Librecast context, created withlc_ctx_new(3).qβ if it's not NULL, it must point to a queueq_tstructure previously initialized withq_init(3). This queue will have jobs enqueued to build the tree. This is normally used in conjunction with a threadpool created withq_pool_create(3)with threads all callingq_job_seek(3). π§΅q(when it's NULL) β if q is NULL, the creation and destruction of a queue and threadpool will be handled automatically. auto-pilot slay.statsβ if it's not NULL, transfer statistics will be returned in this structure. πoptβ not used, at present, and must be NULL for compatibility with future versions. don't be cute with it. π«flagsβ not used, at present, and must be zero for compatibility with future versions. same deal, bestie. π«
β οΈ like, genuinely: opt must beNULLand flags must be0. it's a future-compatibility thing, not a suggestion. π
π«Ά RETURN VALUE π«Ά
These calls return the number of bytes received, or -1 if an error occurred. On error, NULL is returned, and errno is set to indicate the error. π
π ERRORS π
EINVALβ Invalid argument.ENOMEMβ Not enough space/cannot allocate memory (POSIX.1-2001).EACCESβ Permission to create a socket of the specified type and/or protocol is denied.
also, lc_syncfile() can also fail with any of the errors for lc_mmapfile(3). so go read that page too, bestie. π
π NOTES π
To restrict syncing to a particular network interface, call lc_ctx_ifx(3) to set the default interface for the Librecast context before calling the appropriate sync function. timing matters!! β
πΈ SEE ALSO πΈ
lc_ctx_new(3), lc_ctx_ifx(3), lc_mmapfile(3), lc_share(3), mdex_init(3), mdex_free(3), mdex_add(3), mdex_addfile(3), mdex_alias(3), mdex_get(3), mdex_put(3), mdex_del(3), lcrq(7)
and that's the whole page, bestie!! π this one's from the Librecast crew and it's dated 2025-06-09 β go forth and sync your little heart out. mwah. π β¨π¦
π¦ where this page comes from
- nixos 26.05: librecast 0.11.2
- nixpkgs unstable: librecast 0.11.2
- ubuntu resolute: liblibrecast-dev 0.11.2-2 Β· GPL-2.0-only OR GPL-3.0-only
- ubuntu stonking: liblibrecast-dev 0.11.2-2build1 Β· GPL-2.0-only OR GPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms