From 56079039e9e304a1f2ef4e61949b6ebea230bee1 Mon Sep 17 00:00:00 2001 From: Neal H Walfield Date: Tue, 29 Oct 2019 23:48:50 +0100 Subject: libfshelp: Support for file record locking 2019-03-03 Svante Signell * rlock-tweak.c: Require write access for F_SETLK64 and F_SETLKW64 according to POSIX-1003.1. 2019-02-12 Svante Signell * rlock-tweak.c: Comment out check of lock->l_type and open_mode 2019-02-01 Svante Signell * Update copyright years. * 2018-12-07: - Fix typo in fshelp_rlock_tweak. - Move description of rendezvous to fshelp.h. - Removed 64bit versions 2018-12-07 Svante Signell * Update copyright years. * rlock-tweak.c (fshelp_rlock_tweak): Add new argument: mach_port_t rendezvous. 2017-01-05 Svante Signell * Update copyright years and headers. * rlock_tweak.c: l_pid is set to 0 when a conflicting lock is taken by another process. Will be fixed by new proc RPCs. 2016-05-23 Svante Signell * rlock-drop-peropen.c: Port from cthreads to libpthread. * rlock-tweak.c: Likewise * fshelp.h: Likewise * rlock.h: Likewise 2001-04-12 Neal H Walfield * fshelp.h (struct rlock_box): New structure. (struct rlock_peropen): Likewise. (fshelp_rlock_init): New function. (fshelp_rlock_po_init): Likewise. (fshelp_rlock_drop_peropen): Likewise. (fshelp_rlock_tweak): Likewise. (fshelp_rlock_peropen_status): Likewise. (fshelp_rlock_node_status): Likewise. * rlock-drop-peropen.c: New file. Implement fshelp_rlock_drop_peropen. * rlock-status.c: New file. Implement fshelp_rlock_peropen_status and fshelp_rlock_node_status. * rlock-tweak.c: New file. Implement fshelp_rlock_tweak. * rlock.h: New file. * extern-inline.c: New file. * Makefile (installhdrs): Add rlock.h. (SRCS): Add extern-inline.c, rlock-drop-peropen.c, rlock-tweak.c and rlock-status.c. --- libfshelp/rlock-status.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 libfshelp/rlock-status.c (limited to 'libfshelp/rlock-status.c') diff --git a/libfshelp/rlock-status.c b/libfshelp/rlock-status.c new file mode 100644 index 00000000..718e540a --- /dev/null +++ b/libfshelp/rlock-status.c @@ -0,0 +1,53 @@ +/* Copyright (C) 2001, 2014-2019 Free Software Foundation, Inc. + + Written by Neal H Walfield + + This file is part of the GNU Hurd. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd. If not, see . */ + +#include "fshelp.h" +#include "rlock.h" +#include +#include + +int fshelp_rlock_peropen_status (struct rlock_peropen *po) +{ + struct rlock_list *l; + + if (! *po->locks) + return LOCK_UN; + + for (l = *po->locks; l; l = l->po.next) + if (l->type == F_WRLCK) + return LOCK_EX; + + return LOCK_SH; +} + +/* Like fshelp_rlock_peropen_status except for all users of NODE. */ +int fshelp_rlock_node_status (struct rlock_box *box) +{ + struct rlock_list *l; + + if (! box->locks) + return LOCK_UN; + + for (l = box->locks; l; l = l->node.next) + if (l->type == F_WRLCK) + return LOCK_EX; + + return LOCK_SH; +} + -- cgit v1.2.3