aboutsummaryrefslogtreecommitdiff
#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);


}
ommit/gnu/packages/specifications.scm?id=2541171580395bc14010e5ad136c321d34077ce3'>gnu: Add specification-specreduce-data....* gnu/packages/specifications.scm (specification-specreduce-data): New variable. Change-Id: I269cc7eefa12dd8d207da9ac613b5793c3e24c7c Sharlatan Hellseher 2024-05-23gnu: Add specification-ipld....* gnu/packages/specifications.scm (specification-ipld): New variable. Change-Id: Ib36d0cdb4a6d20da789ba20830945c8a7d223b69 Sharlatan Hellseher 2024-04-12gnu: Add specification-multicodec....* gnu/packages/specifications.scm (specification-multicodec): New variable. Change-Id: I75de43613c5a1818b1db79aa275c58dc52411957 Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com> Artyom V. Poptsov 2024-04-12gnu: Add specification-multihash....* gnu/packages/specifications.scm (specification-multihash): New variable. Change-Id: I065898164cc126445a92b33dd628ab06e19d0615 Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com> Artyom V. Poptsov 2024-04-06gnu: Add specification-multibase....* gnu/packages/specifications.scm: New module. (specification-multibase): New variable. * gnu/local.mk (GNU_SYSTEM_MODULES): Add "gnu/packages/specifications.scm". Change-Id: I5994e8f8927d5365cc201da30bd49abf03d17574 Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com> Artyom V. Poptsov