Module Name:    src
Committed By:   ozaki-r
Date:           Fri Aug 16 04:23:31 UTC 2024

Modified Files:
        src/lib/librumphijack: hijack.c

Log Message:
librumphijack: support flock

The original author is k-goda@IIJ.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.139 src/lib/librumphijack/hijack.c:1.140
--- src/lib/librumphijack/hijack.c:1.139	Tue Aug  1 07:04:15 2023
+++ src/lib/librumphijack/hijack.c	Fri Aug 16 04:23:31 2024
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.139 2023/08/01 07:04:15 mrg Exp $	*/
+/*      $NetBSD: hijack.c,v 1.140 2024/08/16 04:23:31 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include <rump/rumpuser_port.h>
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.139 2023/08/01 07:04:15 mrg Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.140 2024/08/16 04:23:31 ozaki-r Exp $");
 #endif
 
 #include <sys/param.h>
@@ -88,7 +88,7 @@ __RCSID("$NetBSD: hijack.c,v 1.139 2023/
  */
 enum dualcall {
 	DUALCALL_WRITE, DUALCALL_WRITEV, DUALCALL_PWRITE, DUALCALL_PWRITEV,
-	DUALCALL_IOCTL, DUALCALL_FCNTL,
+	DUALCALL_IOCTL, DUALCALL_FCNTL, DUALCALL_FLOCK,
 	DUALCALL_SOCKET, DUALCALL_ACCEPT,
 #ifndef __linux__
 	DUALCALL_PACCEPT,
@@ -327,6 +327,7 @@ struct sysnames {
 	{ DUALCALL_PWRITEV,	"pwritev",	RSYS_NAME(PWRITEV)	},
 	{ DUALCALL_IOCTL,	"ioctl",	RSYS_NAME(IOCTL)	},
 	{ DUALCALL_FCNTL,	"fcntl",	RSYS_NAME(FCNTL)	},
+	{ DUALCALL_FLOCK,	"flock",	RSYS_NAME(FLOCK)	},
 	{ DUALCALL_DUP2,	"dup2",		RSYS_NAME(DUP2)		},
 	{ DUALCALL_CLOSE,	"close",	RSYS_NAME(CLOSE)	},
 	{ DUALCALL_POLLTS,	S(REALPOLLTS),	RSYS_NAME(POLLTS)	},
@@ -1632,6 +1633,23 @@ fcntl(int fd, int cmd, ...)
 }
 
 int
+flock(int fd, int operation)
+{
+	int (*op_flock)(int, int);
+
+	DPRINTF(("flock -> %d (operation %d)\n", fd, operation));
+
+	if (fd_isrump(fd)) {
+		fd = fd_host2rump(fd);
+		op_flock = GETSYSCALL(rump, FLOCK);
+	} else {
+		op_flock = GETSYSCALL(host, FLOCK);
+	}
+
+	return op_flock(fd, operation);
+}
+
+int
 close(int fd)
 {
 	int (*op_close)(int);

Reply via email to