---
name: "gd_desync"
section: "3"
platform: "linux"
package: "libgetdata-doc"
version: "0.11.0-15"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/gd_desync"
---

# gd\_desync(3)

check for a change of metadata on disk

## NAME

gd\_desync — check for a change of metadata on disk

## SYNOPSIS

**#include \<getdata.h\>**

**int gd\_desync(DIRFILE \****dirfile***, unsigned int** *flags***);**

## DESCRIPTION

The **gd\_desync**() function determines whether the metadata of the loaded *dirfile* has become desynchronised from the format specification fragments on disk, due to a third party modifying the Dirfile metadata on disk after GetData opened it.  If *dirfile* has become desynchronised, this function can, optionally, reload the dirfile.

The *flags* argument influences how the function works.  It should be zero or more of the following flags, bitwise or'd together:\
  .TP 8 **GD\_DESYNC\_PATHCHECK** Ignore GetData's internal directory cache, and use the format fragments' full path when checking for modifications.  This flag is of particular importance when the *dirfilename* passed to [**gd\_cbopen**(3)](/gd_cbopen/3.md), or directory paths used in included fragments, contain symbolic links: with this flag, these symbolic links will be re-evaluated.  Without it, the target of the symbolic links in effect when the dirfile was first opened will be considered instead.\
  .TP 8 **GD\_DESYNC\_REOPEN** If this flag is specified, and **gd\_desync**() detects desynchronisation, the Dirfile will be re-opened in place using the exiting *dirfile* pointer.  In this case, upon a positive result from this function, the caller must discard all cached information about the dirfile, even the assumption that *dirfile* has been successfully opened.

Re-opening the dirfile is equivalent to calling [**gd\_discard**(3)](/gd_discard/3.md), and then [**gd\_cbopen**(3)](/gd_cbopen/3.md) 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)](/gd_cbopen/3.md) and [**gd\_parser\_callback**(3)](/gd_parser_callback/3.md)).

## RETURN VALUE

When successful, this function returns zero if the loaded dirfile has not desynchronised, or one if it has.  On error, a negative-valued error code is returned, regardless of desynchronisation.  Possible error codes are:\
  .TP 8 **GD\_E\_ALLOC** The library was unable to allocate memory.\
  .TP 8 **GD\_E\_BAD\_DIRFILE** The supplied dirfile was invalid.\
  .TP 8 **GD\_E\_IO** An error occurred while trying to obtain the modification time of a fragment.

Additionally, if **GD\_DESYNC\_REOPEN** is used, this function may fail for any of the reasons listed in the [**gd\_discard**(3)](/gd_discard/3.md) and [**gd\_cbopen**(3)](/gd_cbopen/3.md) manual pages.

The error code is also stored in the **DIRFILE** object and may be retrieved after this function returns by calling [**gd\_error**(3)](/gd_error/3.md). A descriptive error string for the error may be obtained by calling [**gd\_error\_string**(3)](/gd_error_string/3.md).

## LIMITATIONS

The current implementation uses file modification times as reported by [**stat**(2)](/stat/2.md) to detect changes.  These times have a granularity of, at best, one second.  As a result, desynchronisation will not be detected in the case when a fragment is modified, then GetData reads it, then the fragment is modified again, all within one second.  The caller may wish to perform its own monitoring using the pathnames returned by [**gd\_fragmentname**(3)](/gd_fragmentname/3.md).

On systems lacking a POSIX.1-2008 conformant [**fstatat**(2)](/fstatat/2.md) (q.v.), this function may always operate as if **GD\_DESYNC\_PATHCHECK** had been specified, regardless of the actual *flags*.

## HISTORY

The function **gd\_desync**() appeared in GetData-0.8.0.

In GetData-0.10.0, the error return from this function changed from -1 to a negative-valued error code.

## SEE ALSO

[**fstatat**(2)](/fstatat/2.md), [**stat**(2)](/stat/2.md), [**gd\_cbopen**(3)](/gd_cbopen/3.md), [**gd\_discard**(3)](/gd_discard/3.md), [**gd\_error**(3)](/gd_error/3.md), [**gd\_error\_string**(3)](/gd_error_string/3.md), [**gd\_parser\_callback**(3)](/gd_parser_callback/3.md)
