Proxy implementation added to the original patches.
 
Note: This proxy version does not work, e.g. set_fcntl /dev/null gives error
code EACCES. The problem has been traced down to fsServer.c:

3386: if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits) == 
MACH_MSG_TYPE_PROTECTED_PAYLOAD)
3387:   file = 
diskfs_begin_using_protid_payload(In0P>Head.msgh_protected_payload);
3388: else
3389:   file = diskfs_begin_using_protid_port(In0P->Head.msgh_request_port);
3390:
3391: OutP->RetCode = diskfs_S_file_record_lock(file, In0P->cmd, 
&In0P->flock64);
3392: diskfs_end_using_protid_port(file);

Test case: set-fcntl /dev/null
After the call on line 3387
file->po->openstat=0
while for set-fnctl foo it is
file->po->openstat=3

Setting it to 3 in gdb makes the program finish successfully.

Comments:
- The proxy implementation obviously does not work. How to activate the else
part for testing purposes?
- I have a working solution, which adds two new structs to struct trivfs_peropen
  struct rlock_peropen lock_status;
  struct trivfs_node *tp;

This solution was not accepted, and maybe finding the bug in
diskfs_begin_using_protid_payload generated by MIG? would be much better.
libtrivfs/ChangeLog
2015-12-17  Svante Signell <svante.sign...@gmail.com>
	* Makefile (FSSRCS): Add file-lock-stat.c
	* trivfs.h (trivfs_peropen): Fix a typo.
	* Split out file-lock-stat.c (trivfs_S_file_lock_stat) from
	file-lock.c to a separate file.
	* file-lock.c (trivfs_S_file_lock): Implement locking using the
	new record locking functions. proxy solution.
	* file-lock-stat.c (trivfs_S_file_lock_stat): Likewise
	* file-record-lock.c (trivfs_S_file_record_lock): Likewise

2001-04-11  Neal H Walfield  <n...@cs.uml.edu>

	* file-record-lock.c: New file.  Implement
	trivfs_S_file_record_lock.
	* Makefile (FSSRCS): Add file-record-lock.c

Index: hurd-0.7.git20160114/libtrivfs/Makefile
===================================================================
--- hurd-0.7.git20160114.orig/libtrivfs/Makefile
+++ hurd-0.7.git20160114/libtrivfs/Makefile
@@ -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-mkfil
 	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 get-source.c
Index: hurd-0.7.git20160114/libtrivfs/trivfs.h
===================================================================
--- hurd-0.7.git20160114.orig/libtrivfs/trivfs.h
+++ hurd-0.7.git20160114/libtrivfs/trivfs.h
@@ -169,7 +169,7 @@ trivfs_create_control (mach_port_t under
 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 *);
 
 /* Return a new protid pointing to a new peropen in CRED, with REALNODE as
Index: hurd-0.7.git20160114/libtrivfs/file-lock.c
===================================================================
--- hurd-0.7.git20160114.orig/libtrivfs/file-lock.c
+++ hurd-0.7.git20160114/libtrivfs/file-lock.c
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 1994,2002 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2002, 2015, 2016 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,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/>.  */
 
 #include "priv.h"
 #include "trivfs_fs_S.h"
@@ -23,13 +22,5 @@ trivfs_S_file_lock (struct trivfs_protid
 		    mach_port_t reply, mach_msg_type_name_t reply_type,
 		    int flags)
 {
-  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;
+  return cred ? file_lock (cred->realnode, flags) : EOPNOTSUPP;
 }
Index: hurd-0.7.git20160114/libtrivfs/file-lock-stat.c
===================================================================
--- /dev/null
+++ hurd-0.7.git20160114/libtrivfs/file-lock-stat.c
@@ -0,0 +1,26 @@
+/*
+   Copyright (C) 1994, 2002, 2015, 2016 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"
+
+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 cred ? file_lock_stat (cred->realnode, mystatus, otherstatus) : EOPNOTSUPP;
+}
Index: hurd-0.7.git20160114/libtrivfs/file-record-lock.c
===================================================================
--- /dev/null
+++ hurd-0.7.git20160114/libtrivfs/file-record-lock.c
@@ -0,0 +1,30 @@
+/*Copyright (C) 2001, 2014-2016 Free Software Foundation
+
+   Written by Neal H Walfield <n...@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"
+
+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)
+{
+  return cred ? file_record_lock (cred->realnode, cmd, lock) : EOPNOTSUPP;
+}

Reply via email to