From e80c0bde70ddeca7218204e915f57bba2da68214 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Thu, 14 Jul 2022 02:20:32 +0300 Subject: [PATCH] LibC: Support blocking flock() --- Userland/Libraries/LibC/sys/file.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibC/sys/file.cpp b/Userland/Libraries/LibC/sys/file.cpp index 03142f5f084..826ca21af8b 100644 --- a/Userland/Libraries/LibC/sys/file.cpp +++ b/Userland/Libraries/LibC/sys/file.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2021, Peter Elliott + * Copyright (c) 2022, Idan Horowitz * * SPDX-License-Identifier: BSD-2-Clause */ @@ -16,11 +17,6 @@ int flock(int fd, int operation) struct flock lock { short(operation & 0b11), SEEK_SET, 0, 0, 0 }; - if (operation & LOCK_NB) { - return fcntl(fd, F_SETLK, &lock); - } - - // FIXME: Implement F_SETLKW in fcntl. - VERIFY_NOT_REACHED(); + return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock); } }