aboutsummaryrefslogtreecommitdiff
path: root/nix/libstore/pathlocks.hh
blob: 8a6b1450da2a302170806312f4d9c7b243736698 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include "types.hh"


namespace nix {


/* Open (possibly create) a lock file and return the file descriptor.
   -1 is returned if create is false and the lock could not be opened
   because it doesn't exist.  Any other error throws an exception. */
int openLockFile(const Path & path, bool create);

/* Delete an open lock file. */
void deleteLockFile(const Path & path, int fd);

enum LockType { ltRead, ltWrite, ltNone };

bool lockFile(int fd, LockType lockType, bool wait);


class PathLocks 
{
private:
    typedef std::pair<int, Path> FDPair;
    list<FDPair> fds;
    bool deletePaths;

public:
    PathLocks();
    PathLocks(const PathSet & paths,
        const string & waitMsg = "");
    bool lockPaths(const PathSet & _paths,
        const string & waitMsg = "",
        bool wait = true);
    ~PathLocks();
    void unlock();
    void setDeletion(bool deletePaths);
};


bool pathIsLockedByMe(const Path & path);


}
h?id=0d22fc8d36e4efba9748c94cab7cedbbe2bbb5bf'>services: shepherd: 'shepherd-service-type' requires documentation....Ludovic Courtès 2020-11-06tests: Test "guix system search ."....Ludovic Courtès 2020-10-02gexp: 'local-file' warns when passed a non-literal relative file name....Ludovic Courtès 2020-09-30scripts: system: Add support for image-type....Mathieu Othacehe 2020-06-08system: examples: Add bare-hurd.tmpl....Jan (janneke) Nieuwenhuizen 2020-01-17guix system: Add workaround in test for Guile 3.0.0....Ludovic Courtès 2020-01-16records: Improve reporting of "invalid field specifier" errors....Ludovic Courtès 2019-04-29tests: Adjust wildcard when testing OS examples....Ludovic Courtès 2019-01-21tests: Adjust for removal of 'device' field in <bootloader-configuration>....Ludovic Courtès 2019-01-11services: Deprecate a few more service procedures....Ludovic Courtès 2018-10-18services: dhcp-client: Deprecate 'dhcp-client-service' procedure....Ludovic Courtès 2018-09-07vm: Make UUID computation really deterministic....Ludovic Courtès 2018-05-28system: Remove uses of the 'title' field of <file-system>....Ludovic Courtès 2018-05-19tests: Adjust to new "unbound variable" messages....Ludovic Courtès 2018-04-30guix system: search: Display default Shepherd service names....Ludovic Courtès 2018-03-24tests: Add tests for "guix system disk-image" et al....Chris Marusich 2017-12-06gnu, doc, tests: Use ‘bootloader-configuration’ everywhere....Tobias Geerinckx-Rice 2017-12-04tests: Look for multi-digit column numbers in unbound variable test....Eric Bavier 2017-11-10tests: Adjust to unbound-variable exception printer....Ludovic Courtès 2017-11-08gnu: Improve error reporting of the use-.*modules macros....Ludovic Courtès 2017-10-10ui: Improve reporting of missing closing parentheses....Ludovic Courtès 2017-09-16guix system: Add 'search' command....Ludovic Courtès 2017-03-15tests: Expect less accurate location info in 2.2.0....Ludovic Courtès