first commit

This commit is contained in:
ngn
2024-05-01 21:02:15 +03:00
commit 5691727d64
32 changed files with 2114 additions and 0 deletions

17
src/lock.c Normal file
View File

@ -0,0 +1,17 @@
#include "lock.h"
#include "paths.h"
#include "util.h"
#include <fcntl.h>
#include <unistd.h>
lock_st lock() {
if (exists(mc_lock_path))
return ALREADY_LOCKED;
if (creat(mc_lock_path, 0600) == -1)
return LOCK_ERROR;
return LOCK_SUCCESS;
}
void unlock() {
unlink(mc_lock_path);
}