2021-07-18 23:55:13 -06:00
|
|
|
/*
|
2021-08-31 19:32:46 -07:00
|
|
|
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
|
2022-07-14 02:20:32 +03:00
|
|
|
* Copyright (c) 2022, Idan Horowitz <idan.horowitz@serenityos.org>
|
2021-07-18 23:55:13 -06:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <AK/Assertions.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <sys/file.h>
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
int flock(int fd, int operation)
|
|
|
|
|
{
|
|
|
|
|
struct flock lock {
|
|
|
|
|
short(operation & 0b11), SEEK_SET, 0, 0, 0
|
|
|
|
|
};
|
2022-07-14 02:20:32 +03:00
|
|
|
return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock);
|
2021-07-18 23:55:13 -06:00
|
|
|
}
|
|
|
|
|
}
|