Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Feb 2019 22:00:36 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344670 - head/sys/kern
Message-ID:  <201902282200.x1SM0aKn022551@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Thu Feb 28 22:00:36 2019
New Revision: 344670
URL: https://svnweb.freebsd.org/changeset/base/344670

Log:
  Allow FIONBIO and FIOASYNC ioctls on POSIX shm descriptors.
  
  They have no effect, as with filesystem file descriptors.
  This improves compatibility with some existing userspace code.
  
  Submitted by:	Greg V <greg@unrelenting.technology>
  Reviewed by:	kib
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D19330

Modified:
  head/sys/kern/uipc_shm.c

Modified: head/sys/kern/uipc_shm.c
==============================================================================
--- head/sys/kern/uipc_shm.c	Thu Feb 28 21:07:16 2019	(r344669)
+++ head/sys/kern/uipc_shm.c	Thu Feb 28 22:00:36 2019	(r344670)
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/fcntl.h>
 #include <sys/file.h>
 #include <sys/filedesc.h>
+#include <sys/filio.h>
 #include <sys/fnv_hash.h>
 #include <sys/kernel.h>
 #include <sys/uio.h>
@@ -126,6 +127,7 @@ static int	shm_remove(char *path, Fnv32_t fnv, struct 
 static fo_rdwr_t	shm_read;
 static fo_rdwr_t	shm_write;
 static fo_truncate_t	shm_truncate;
+static fo_ioctl_t	shm_ioctl;
 static fo_stat_t	shm_stat;
 static fo_close_t	shm_close;
 static fo_chmod_t	shm_chmod;
@@ -139,7 +141,7 @@ struct fileops shm_ops = {
 	.fo_read = shm_read,
 	.fo_write = shm_write,
 	.fo_truncate = shm_truncate,
-	.fo_ioctl = invfo_ioctl,
+	.fo_ioctl = shm_ioctl,
 	.fo_poll = invfo_poll,
 	.fo_kqfilter = invfo_kqfilter,
 	.fo_stat = shm_stat,
@@ -361,6 +363,24 @@ shm_truncate(struct file *fp, off_t length, struct ucr
 		return (error);
 #endif
 	return (shm_dotruncate(shmfd, length));
+}
+
+int
+shm_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
+    struct thread *td)
+{
+
+	switch (com) {
+	case FIONBIO:
+	case FIOASYNC:
+		/*
+		 * Allow fcntl(fd, F_SETFL, O_NONBLOCK) to work,
+		 * just like it would on an unlinked regular file
+		 */
+		return (0);
+	default:
+		return (ENOTTY);
+	}
 }
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902282200.x1SM0aKn022551>