/* ISC License Copyright (c) 2026, Antonio SJ Musumeci Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #pragma once #include "branches.hpp" #include "fuse.h" #include "fs_path.hpp" #include "ugid.hpp" #include #include #include namespace FUSE { // A replacement symlink which was actually created on one branch of // the caller's branch set. The identity is read from the freshly // created link through its pinned descriptor before it is published, // so a later match against it proves an object is the link this // request created; it is never taken from a later lookup. struct PreparedSymlink { fs::path branch; fs::path path; dev_t dev; ino_t ino; }; int symlink(const fuse_req_ctx_t *ctx, const char *target, const char *linkpath, struct stat *st = NULL, fuse_timeouts_t *timeouts = NULL); int symlink_owned(const ugid_t owner, const char *target, const fs::path &linkpath, struct stat *st = NULL, fuse_timeouts_t *timeouts = NULL); // Create the link `linkpath_` (pool relative) on every branch the // symlink create policy selects within `branches_`, owned by // `owner_`, using exactly the caller's branch set. All-or-fail: on // success `prepared_` records every creation, on failure it records // only the branches where creation succeeded so the caller can undo // them with symlink_unprepare(). `prepared_` is cleared first; its // records are only ever successful creations. int symlink_prepare(const Branches::Ptr &branches, const ugid_t owner, const char *target, const fs::path &linkpath, std::vector &prepared); // Remove prepared links this request created. A name which no longer // refers to the recorded identity is not ours and is left in place. // On return `prepared` is empty. void symlink_unprepare(std::vector &prepared); }