file.cpp 487 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/Assertions.h>
  7. #include <fcntl.h>
  8. #include <stdio.h>
  9. #include <sys/file.h>
  10. extern "C" {
  11. int flock(int fd, int operation)
  12. {
  13. struct flock lock {
  14. short(operation & 0b11), SEEK_SET, 0, 0, 0
  15. };
  16. if (operation & LOCK_NB) {
  17. return fcntl(fd, F_SETLK, &lock);
  18. }
  19. // FIXME: Implement F_SETLKW in fcntl.
  20. VERIFY_NOT_REACHED();
  21. }
  22. }