diff options
author | Neal H Walfield <neal@cs.uml.edu> | 2019-10-29 23:48:50 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2019-10-29 23:48:50 +0100 |
commit | 56079039e9e304a1f2ef4e61949b6ebea230bee1 (patch) | |
tree | 5f238fe97ecdfbadef791dbd96782e3bbeb136a2 /libfshelp/rlock.h | |
parent | 85220c93ea4f0fa5897893f78896c6326039615b (diff) | |
download | hurd-56079039e9e304a1f2ef4e61949b6ebea230bee1.tar.gz hurd-56079039e9e304a1f2ef4e61949b6ebea230bee1.tar.bz2 hurd-56079039e9e304a1f2ef4e61949b6ebea230bee1.zip |
libfshelp: Support for file record locking
2019-03-03 Svante Signell <svante.signell@gmail.com>
* rlock-tweak.c: Require write access for F_SETLK64 and
F_SETLKW64 according to POSIX-1003.1.
2019-02-12 Svante Signell <svante.signell@gmail.com>
* rlock-tweak.c: Comment out check of lock->l_type and open_mode
2019-02-01 Svante Signell <svante.signell@gmail.com>
* 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 <svante.signell@gmail.com>
* Update copyright years.
* rlock-tweak.c (fshelp_rlock_tweak): Add new argument:
mach_port_t rendezvous.
2017-01-05 Svante Signell <svante.signell@gmail.com>
* 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 <svante.signell@gmail.com>
* 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 <neal@cs.uml.edu>
* 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.
Diffstat (limited to 'libfshelp/rlock.h')
-rw-r--r-- | libfshelp/rlock.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/libfshelp/rlock.h b/libfshelp/rlock.h new file mode 100644 index 00000000..5c620279 --- /dev/null +++ b/libfshelp/rlock.h @@ -0,0 +1,87 @@ +/* + Copyright (C) 2001, 2014-2019 Free Software Foundation + + Written by Neal H Walfield <neal@cs.uml.edu> + + This file is part of the GNU Hurd. + + The GNU Hurd 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. + + The GNU Hurd 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 <http://www.gnu.org/licenses/>. */ + +#ifndef FSHELP_RLOCK_H +#define FSHELP_RLOCK_H + +#include <pthread.h> +#include <string.h> + +struct rlock_linked_list +{ + struct rlock_list *next; + struct rlock_list **prevp; +}; + +struct rlock_list +{ + loff_t start; + loff_t len; + int type; + + struct rlock_linked_list node; + struct rlock_linked_list po; + + pthread_cond_t wait; + int waiting; + + void *po_id; +}; + +extern inline error_t +rlock_list_init (struct rlock_peropen *po, struct rlock_list *l) +{ + memset (l, 0, sizeof (struct rlock_list)); + pthread_cond_init (&l->wait, NULL); + l->po_id = po->locks; + return 0; +} + +/* void list_list (X ={po,node}, struct rlock_list **head, + struct rlock_list *node) + + Insert a node in the given list, X, in sorted order. */ +#define list_link(X, head, node) \ + do \ + { \ + struct rlock_list **e; \ + for (e = head; \ + *e && ((*e)->start < node->start); \ + e = &(*e)->X.next) \ + ; \ + node->X.next = *e; \ + if (node->X.next) \ + node->X.next->X.prevp = &node->X.next; \ + node->X.prevp = e; \ + *e = node; \ + } \ + while (0) + +/* void list_unlock (X = {po,node}, struct rlock_list *node) */ +#define list_unlink(X, node) \ + do \ + { \ + *node->X.prevp = node->X.next; \ + if (node->X.next) \ + node->X.next->X.prevp = node->X.prevp; \ + } \ + while (0) + +#endif /* FSHELP_RLOCK_H */ |