Skip to contentSkip to conversation

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

PATCH New Jeff Hansen 1 participant 1 message Oct 26, 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 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.

This will try to open the Unix socket first in SOCK_DGRAM mode, then SOCK_STREAM mode if that fails.

---
 net/unix/Kconfig   |   10 +++++
 net/unix/af_unix.c |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 123 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 +113 -0

125 lines not on this page · raw message

Signature · 1 line
1.7.0.4