Skip to contentSkip to conversation

net/unix: Allow Unix sockets to be treated like normal files.

PATCH New Jeff Hansen 1 participant 1 message Nov 16, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/unix: Allow Unix sockets to be treated like normal files.

This is an update to my previous patch that fixes crashes on systems that used filp->private_data for their own purposes.

For some reason, it doesn't look like this will ever get main-lined. But, just in case someone wants to be able to write to a Unix socket with:

$ echo send_cmd > /tmp/my_socket

This is the patch that will let you do that.

This allows Unix sockets to be opened, written, read, and closed, like normal files. This can be especially handy from, for example, a shell script that wants to send a short message to a Unix socket, but doesn't want to and/or cannot create the socket itself.

---
 net/unix/Kconfig   |   10 +++
 net/unix/af_unix.c |  177 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 187 insertions(+), 0 deletions(-)
net/unix/Kconfig +10 -0
index 5a69733..68df4f1 100644
@@ -19,3 +19,13 @@ config UNIX
 
 	  Say Y unless you know what you are doing.
 
+config UNIX_FOPS
+	boolean "Allow Unix sockets to be treated like normal files"
+	depends on UNIX
+	---help---
+	  If you say Y here, Unix sockets may be opened, written, read, and
+	  closed, like normal files.  This is handy for sending short commands
+	  to Unix sockets (i.e. from shell scripts), without having to create
+	  a Unix socket.
+
+	  Say Y unless you know what you are doing.
net/unix/af_unix.c +177 -0

189 lines not on this page · raw message

Signature · 1 line
1.7.0.4