{
  "slug": "advisory-file-lock",
  "term": "Advisory file lock",
  "aliases": [
    "advisory locking"
  ],
  "definition": "An advisory file lock coordinates access among cooperating participants without itself preventing access that bypasses the locking protocol.",
  "note": "On local Linux filesystems, flock() locks follow open file descriptions; a replacement pathname can refer to a different file. Hesela's ordered subprocess observation acquires a second lock after target replacement while the old file remains locked. Retaining a separate coordination file preserves the tested conflict; deleting and recreating it loses that shared identity. [flock] [observation]",
  "status": "shipping",
  "advantages": [],
  "limitations": [
    {
      "text": "A lock does not substitute for file or directory synchronization.",
      "citationIds": [
        "hesela-locks"
      ]
    },
    {
      "text": "NFS and SMB/CIFS can change flock interaction and enforcement; this local experiment does not test them.",
      "citationIds": [
        "flock"
      ]
    },
    {
      "text": "All participants must coordinate on the same stable file using compatible locking operations.",
      "citationIds": [
        "hesela-locks"
      ]
    }
  ],
  "related": [
    "open-file-description-lock",
    "open-file-description",
    "atomic-rename",
    "unlink",
    "process-associated-record-lock"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-16",
  "citations": [
    {
      "id": "flock",
      "title": "Linux man-pages 6.19: flock(2), ownership and filesystem differences",
      "url": "https://man7.org/linux/man-pages/man2/flock.2.html",
      "accessed": "2026-10-16"
    },
    {
      "id": "observation",
      "title": "Hesela: local Linux lock-identity observation, source hash and limitations",
      "url": "https://hesela.dev/research/lock-identity/observation.json",
      "accessed": "2026-10-16"
    },
    {
      "id": "hesela-locks",
      "title": "Hesela: A lock follows the opened file, not the replacement name",
      "url": "https://hesela.com/analyses/atomic-rename-directory-durability/#lock-identity",
      "accessed": "2026-10-16"
    }
  ]
}
