Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::RestoreSink Struct Reference

#include <fs-sink.hh>

Inheritance diagram for nix::RestoreSink:
nix::FileSystemObjectSink

Public Member Functions

 RestoreSink (bool startFsync, RestoreSinkHooks *hooks=nullptr)
void createDirectory (const CanonPath &path) override
void createDirectory (const CanonPath &path, DirectoryCreatedCallback callback) override
void createRegularFile (const CanonPath &path, fun< void(CreateRegularFileSink &)>) override
void createSymlink (const CanonPath &path, const std::string &target) override

Public Attributes

std::filesystem::path dstPath
AutoCloseFD dirFd
bool startFsync = false

Additional Inherited Members

Public Types inherited from nix::FileSystemObjectSink
using DirectoryCreatedCallback = fun<void(FileSystemObjectSink & dirSink, const CanonPath & dirRelPath)>

Detailed Description

Write files at the given path

Member Function Documentation

◆ createDirectory() [1/2]

void nix::RestoreSink::createDirectory ( const CanonPath & path)
overridevirtual
Todo
Remove. Only keep the callback driven function (at least for recursive traversal).

Implements nix::FileSystemObjectSink.

◆ createDirectory() [2/2]

void nix::RestoreSink::createDirectory ( const CanonPath & path,
DirectoryCreatedCallback callback )
overridevirtual

Create a directory and invoke a callback with a pair of sink + CanonPath of the created subdirectory relative to dirSink.

Note
This allows for UNIX RestoreSink implementations to implement *at-style accessors that always keep an open file descriptor for the freshly created directory. Use this when it's important to disallow any intermediate path components from being symlinks.

Reimplemented from nix::FileSystemObjectSink.

◆ createRegularFile()

void nix::RestoreSink::createRegularFile ( const CanonPath & path,
fun< void(CreateRegularFileSink &)>  )
overridevirtual

This function in general is no re-entrant. Only one file can be written at a time.

Implements nix::FileSystemObjectSink.

◆ createSymlink()

void nix::RestoreSink::createSymlink ( const CanonPath & path,
const std::string & target )
overridevirtual

Member Data Documentation

◆ dirFd

AutoCloseFD nix::RestoreSink::dirFd

File descriptor for the directory located at dstPath. Used for at operations relative to this file descriptor. This sink must *never follow intermediate symlinks (starting from dstPath) in case a file collision is encountered for various reasons like case-insensitivity or other types on normalization. using appropriate *at system calls and traversing only one path component at a time ensures that writing is race-free and is is not susceptible to symlink replacement.


The documentation for this struct was generated from the following files:
  • libutil/include/nix/util/fs-sink.hh
  • libutil/fs-sink.cc