gd_desync(3)
β¨ NAME β¨
gd_desync β check for a change of metadata on disk π
okay bestie, real talk: this is a getdata manpage, third section, and it's literally all about noticing when someone else has been messing with your dirfile's metadata behind your back. no cap.
πΈ SYNOPSIS πΈ
#include <getdata.h>
int gd_desync(DIRFILE *dirfile, unsigned int flags);
π DESCRIPTION π
so the whole vibe of gd_desync() is: it figures out whether the metadata of the loaded dirfile has become desynchronised from the format specification fragments sitting on disk. and like, how would that even happen? π a third party modifying the Dirfile metadata on disk after GetData opened it. rude, honestly.
and if dirfile has become desynchronised, this function can optionally reload the dirfile for you. slay.
the flags argument is the main character here β it decides how the function does its thing. it should be zero or more of these flags, bitwise or'd together π«Ά:
GD_DESYNC_PATHCHECKβ ignore GetData's internal directory cache and use the format fragments' full path when checking for modifications. this one is highkey important when thedirfilenamepassed togd_cbopen(3), or directory paths used in included fragments, contain symbolic links: with this flag, those symbolic links get re-evaluated. without it, the target of the symbolic links in effect when the dirfile was first opened is what gets considered instead. iykyk β¨GD_DESYNC_REOPENβ if this flag is specified andgd_desync()detects desynchronisation, the Dirfile gets re-opened in place using the existingdirfilepointer. and in that case, upon a positive result from this function, the caller must discard all cached information about the dirfile β even the assumption thatdirfilehas been successfully opened. not me being dramatic, that's just the rules π
re-opening the dirfile is equivalent to calling gd_discard(3), and then gd_cbopen(3) with the same arguments used when originally creating dirfile, except that the dirfile pointer doesn't change its value. as a result, this function may invoke the registered parser callback function (see gd_cbopen(3) and gd_parser_callback(3)). π
π RETURN VALUE π
when it's all going well, this function returns zero if the loaded dirfile has not desynchronised, or one if it has.
on error though? it returns a negative-valued error code, regardless of desynchronisation. the possible error codes are:
GD_E_ALLOCβ the library was unable to allocate memory. πGD_E_BAD_DIRFILEβ the supplieddirfilewas invalid. π©GD_E_IOβ an error occurred while trying to obtain the modification time of a fragment.
also, if GD_DESYNC_REOPEN is used, this function may fail for any of the reasons listed in the gd_discard(3) and gd_cbopen(3) manual pages. so many ways to go wrong, lowkey iconic.
the error code is also stored in the DIRFILE object and may be retrieved after this function returns by calling gd_error(3). and a descriptive error string for the error? get that by calling gd_error_string(3). π
π¦ LIMITATIONS π¦
okay so here's the tea, and it's important tea β
the current implementation uses file modification times as reported by stat(2) to detect changes. and those times have a granularity of, at best, one second. so as a result, desynchronisation will not be detected in this exact case: a fragment is modified, then GetData reads it, then the fragment is modified again β all within one second. π¬ yeah. sneaky.
the caller may wish to perform its own monitoring using the pathnames returned by gd_fragmentname(3). just saying. π
on systems lacking a POSIX.1-2008 conformant fstatat(2) (q.v.), this function may always operate as if GD_DESYNC_PATHCHECK had been specified, regardless of the actual flags. so like, the flag might just be doing its own thing. π
π HISTORY π
- the function
gd_desync()appeared in GetData-0.8.0. β¨ - in GetData-0.10.0, the error return from this function changed from
-1to a negative-valued error code. glow-up fr fr.
π SEE ALSO π
fstatat(2), stat(2), gd_cbopen(3), gd_discard(3), gd_error(3), gd_error_string(3), gd_parser_callback(3)
and that's the whole page bestie, no notes π«Ά this was Version 0.10.0, dated 25 December 2016, straight out of the GETDATA manual β mwah, periodt π πΈ
π¦ where this page comes from
- debian bookworm: libgetdata-doc 0.11.0-6
- debian trixie: libgetdata-doc 0.11.0-15
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- nixos 26.05: getdata 0.11.0
- nixpkgs unstable: getdata 0.11.0
- ubuntu jammy: libgetdata-doc 0.11.0-3ubuntu1
- ubuntu noble: libgetdata-doc 0.11.0-13
- ubuntu questing: libgetdata-doc 0.11.0-15
- ubuntu resolute: libgetdata-doc 0.11.0-17build1
- ubuntu stonking: libgetdata-doc 0.11.0-17build2
- Copyright (C) 2016 D. V. Wiebe
- Copyright (C) 2012, 2014, 2016 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms