summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSvante Signell <svante.signell@gmail.com>2019-10-29 23:59:23 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2019-10-30 00:04:35 +0100
commit14639382938714f07f76abd3d221c6d472710502 (patch)
tree53d96fbfdd7b80bac58f73244267c68a0058fbca
parentdd7447b87c6d6d1afaf25553b0f911853dcc6683 (diff)
libnetfs: Support for file record locking
2019-03-04 Svante Signell <svante.signell@gmail.com> * file-lock.c: Make flock work regardless of the mode in which the file was opened. 2019-02-12 Svante Signell <svante.signell@gmail.com> * file-lock.c: Comment out "Make flock work without R or W mode" 2019-02-01 Svante Signell <svante.signell@gmail.com> * Update copyright years. * file-record-lock.c(netfs_S_file_record_lock): Don't set rendezvous to MACH_PORT_NULL. 2017-01-05 Svante Signell <svante.signell@gmail.com> * Update copyright years and headers. * dir-lookup.c (netfs_S_dir_lookup): Call fshelp_rlock_tweak() with new last argument rendezvous = MACH_PORT_NULL. * file-lock.c (netfs_S_file_lock): Likewise. * file-record-lock.c (netfs_S_file_record_lock): Likewise. (netfs_S_file_record_lock): Add new argument mach_port_t rendezvous. 2016-05-23 Svante Signell <svante.signell@gmail.com> * netfs.h (struct peropen): Change the type of rlock_status from an int to a struct rlock_peropen. (struct node): Change the type of userbox from a struct lock_box to a struct rlock_box. * dir-lookup.c (netfs_S_dir_lookup): Use fshelp_rlock_tweak. * file-lock-stat.c (netfs_S_file_lock_stat): Total rewrite around the new record locking functions. * file-lock.c (netfs_S_file_lock): Likewise. * file-record-lock.c (netfs_S_file_record_lock): Likewise. * make-node.c (netfs_make_node): Initialize userbox with fshelp_rlock_init. * make-peropen.c (netfs_make_peropen): Initialize lock_status using fshelp_rlock_po_init. (netfs_make_peropen): Add a comment that po->refcnt starts at zero. * relese-peropen.c (netfs_release_peropen): Release lock_status using fshelp_rlock_drop_peropen. 2001-04-11 Neal H Walfield <neal@cs.uml.edu> * file-record-lock.c: New file. Implement netfs_S_file_record_lock. * Makefile (SRCS): Add file-record-lock.c
-rw-r--r--libtrivfs/Makefile10
-rw-r--r--libtrivfs/file-lock-stat.c30
-rw-r--r--libtrivfs/file-lock.c17
-rw-r--r--libtrivfs/file-record-lock.c33
-rw-r--r--libtrivfs/make-node.c33
-rw-r--r--libtrivfs/make-peropen.c29
-rw-r--r--libtrivfs/open.c7
-rw-r--r--libtrivfs/trivfs.h28
8 files changed, 163 insertions, 24 deletions
diff --git a/libtrivfs/Makefile b/libtrivfs/Makefile
index 4fd3150c..d645a0cd 100644
--- a/libtrivfs/Makefile
+++ b/libtrivfs/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1994, 1995, 1996, 1997, 1999, 2001, 2002, 2003, 2008, 2012
+# Copyright (C) 1994-1997, 1999, 2001-2003, 2008, 2012-2019
# Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
@@ -12,8 +12,7 @@
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>.
dir := libtrivfs
makemode := library
@@ -22,7 +21,8 @@ FSSRCS= dir-link.c dir-mkdir.c dir-mkfile.c dir-lookup.c dir-readdir.c \
dir-rename.c dir-rmdir.c dir-unlink.c file-chauthor.c \
file-chflags.c file-chmod.c file-chown.c file-get-trans.c \
file-get-transcntl.c file-getcontrol.c file-getfh.c \
- file-getlinknode.c file-lock.c file-set-trans.c file-statfs.c \
+ file-getlinknode.c file-lock.c file-lock-stat.c file-record-lock.c \
+ file-set-trans.c file-statfs.c \
file-sync.c file-syncfs.c file-set-size.c file-utimes.c file-exec.c \
file-access.c dir-chg.c file-chg.c file-get-storage-info.c \
file-get-fs-options.c file-reparent.c \
@@ -38,7 +38,7 @@ FSYSSRCS=fsys-getroot.c fsys-goaway.c fsys-stubs.c fsys-syncfs.c \
fsys-get-children.c fsys-get-source.c \
OTHERSRCS=demuxer.c protid-clean.c protid-dup.c cntl-create.c \
- cntl-clean.c times.c startup.c open.c \
+ cntl-clean.c times.c startup.c make-node.c make-peropen.c open.c \
runtime-argp.c set-options.c append-args.c dyn-classes.c \
get-source.c
diff --git a/libtrivfs/file-lock-stat.c b/libtrivfs/file-lock-stat.c
new file mode 100644
index 00000000..5ccd9d3d
--- /dev/null
+++ b/libtrivfs/file-lock-stat.c
@@ -0,0 +1,30 @@
+/*
+ Copyright (C) 1994, 2002, 2015-2019 Free Software Foundation, Inc.
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+#include "priv.h"
+#include "trivfs_fs_S.h"
+
+#include <fcntl.h>
+#include <sys/file.h>
+
+kern_return_t
+trivfs_S_file_lock_stat (struct trivfs_protid *cred,
+ mach_port_t reply, mach_msg_type_name_t reply_type,
+ int *mystatus, int *otherstatus)
+{
+ return EOPNOTSUPP;
+}
diff --git a/libtrivfs/file-lock.c b/libtrivfs/file-lock.c
index c89f2fac..b644024f 100644
--- a/libtrivfs/file-lock.c
+++ b/libtrivfs/file-lock.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994,2002 Free Software Foundation, Inc.
+ Copyright (C) 1994, 2002, 2015-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -12,12 +12,15 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>.
+*/
#include "priv.h"
#include "trivfs_fs_S.h"
+#include <fcntl.h>
+#include <sys/file.h>
+
kern_return_t
trivfs_S_file_lock (struct trivfs_protid *cred,
mach_port_t reply, mach_msg_type_name_t reply_type,
@@ -25,11 +28,3 @@ trivfs_S_file_lock (struct trivfs_protid *cred,
{
return EOPNOTSUPP;
}
-
-kern_return_t
-trivfs_S_file_lock_stat (struct trivfs_protid *cred,
- mach_port_t reply, mach_msg_type_name_t reply_type,
- int *mystatus, int *otherstat)
-{
- return EOPNOTSUPP;
-}
diff --git a/libtrivfs/file-record-lock.c b/libtrivfs/file-record-lock.c
new file mode 100644
index 00000000..5109d4ad
--- /dev/null
+++ b/libtrivfs/file-record-lock.c
@@ -0,0 +1,33 @@
+/*
+ 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.
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+#include "priv.h"
+/* #include "trivfs_fs_S.h" */
+#include <stdio.h>
+
+kern_return_t
+trivfs_S_file_record_lock (struct trivfs_protid *cred,
+ mach_port_t reply,
+ mach_msg_type_name_t reply_type,
+ int cmd, struct flock64 *lock,
+ mach_port_t rendezvous)
+{
+ return EOPNOTSUPP;
+}
diff --git a/libtrivfs/make-node.c b/libtrivfs/make-node.c
new file mode 100644
index 00000000..1ccb26b8
--- /dev/null
+++ b/libtrivfs/make-node.c
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) 2016-2019 Free Software Foundation, Inc.
+ Written by Svante Signell <svante.signell@gmail.com>
+
+ 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/>.
+*/
+
+#include "priv.h"
+
+static struct trivfs_node *
+init_node (struct trivfs_node *tp)
+{
+ return NULL;
+}
+
+struct trivfs_node *
+trivfs_make_node (struct trivfs_peropen *po)
+{
+ return NULL;
+}
diff --git a/libtrivfs/make-peropen.c b/libtrivfs/make-peropen.c
new file mode 100644
index 00000000..5525bc2d
--- /dev/null
+++ b/libtrivfs/make-peropen.c
@@ -0,0 +1,29 @@
+/*
+ Copyright (C) 2016-2019 Free Software Foundation, Inc.
+ Written by Svante Signell <svante.signell@gmail.com>
+
+ 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/>.
+*/
+
+#include "priv.h"
+#include <errno.h>
+#include <fcntl.h>
+
+struct trivfs_peropen *
+trivfs_make_peropen (struct trivfs_protid *cred)
+{
+ return NULL;
+}
diff --git a/libtrivfs/open.c b/libtrivfs/open.c
index 35a9452c..3e43a608 100644
--- a/libtrivfs/open.c
+++ b/libtrivfs/open.c
@@ -1,6 +1,6 @@
/* Make a new trivfs peropen/protid
- Copyright (C) 1993, 1994, 1995, 1996, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1993-1996, 1999, 2018-2019 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -9,14 +9,13 @@
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,
+ 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
#include <string.h> /* For bcopy() */
diff --git a/libtrivfs/trivfs.h b/libtrivfs/trivfs.h
index 1f0c5071..cdb1de8c 100644
--- a/libtrivfs/trivfs.h
+++ b/libtrivfs/trivfs.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994,95,96,97,99,2002,13 Free Software Foundation, Inc.
+ Copyright (C) 1994-1999, 2002, 2013-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -12,8 +12,8 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>.
+*/
#ifndef __TRIVFS_H__
#define __TRIVFS_H__
@@ -24,6 +24,7 @@
#include <mach/mach.h>
#include <hurd/ports.h>
#include <hurd/iohelp.h>
+#include <hurd/fshelp.h>
#include <refcount.h>
struct trivfs_protid
@@ -45,6 +46,21 @@ struct trivfs_peropen
int openmodes;
refcount_t refcnt;
struct trivfs_control *cntl;
+
+ struct rlock_peropen lock_status;
+ struct trivfs_node *tp;
+};
+
+/* A unique one of these exists for each node currently in use. */
+struct trivfs_node
+{
+ pthread_mutex_t lock;
+
+ /* The number of references to this node. */
+ int references;
+
+ struct transbox transbox;
+ struct rlock_box credlock;
};
struct trivfs_control
@@ -170,9 +186,13 @@ trivfs_create_control (mach_port_t underlying,
void trivfs_clean_protid (void *);
void trivfs_clean_cntl (void *);
-/* This demultiplees messages for trivfs ports. */
+/* This demultiplexes messages for trivfs ports. */
int trivfs_demuxer (mach_msg_header_t *, mach_msg_header_t *);
+/* FIXME: Add descriptions */
+struct trivfs_node *trivfs_make_node (struct trivfs_peropen *po);
+struct trivfs_peropen *trivfs_make_peropen (struct trivfs_protid *cred);
+
/* Return a new protid pointing to a new peropen in CRED, with REALNODE as
the underlying node reference, with the given identity, and open flags in
FLAGS. CNTL is the trivfs control object. */