Serenity Operating System
at master 22 lines 479 B view raw
1/* 2 * Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org> 3 * Copyright (c) 2022, Idan Horowitz <idan.horowitz@serenityos.org> 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#include <AK/Assertions.h> 9#include <fcntl.h> 10#include <stdio.h> 11#include <sys/file.h> 12 13extern "C" { 14 15int flock(int fd, int operation) 16{ 17 struct flock lock { 18 short(operation & 0b11), SEEK_SET, 0, 0, 0 19 }; 20 return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock); 21} 22}