aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2016-03-10 15:52:28 -0600
committerPeter Seebach <peter.seebach@windriver.com>2016-03-10 15:52:28 -0600
commitbbc4bcac601833a2aa82019d08325e63822db726 (patch)
tree177db110f5d10304021ffa11214e7c21290ae061
parent80c6334a2e4204cdc7132216f64d1660eed62fd9 (diff)
downloadpseudo-seebs/evlog.tar.gz
pseudo-seebs/evlog.tar.bz2
pseudo-seebs/evlog.zip
add wrapper for bindseebs/evlog
Since the pseudo socket is actually created by a call to bind, the bind call could create a file, which means it needs to record a database entry.
-rw-r--r--ChangeLog.txt3
-rw-r--r--ports/unix/guts/bind.c30
-rw-r--r--ports/unix/wrapfuncs.in1
-rw-r--r--pseudo_wrappers.c2
4 files changed, 36 insertions, 0 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index ede9969..a511e27 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,6 @@
+2016-03-10:
+ * (seebs) make bind work (so userspace NFS server can handle pseudo)
+
2016-03-09:
* (seebs) workaround for bash redefining getenv/unsetenv/etc.
diff --git a/ports/unix/guts/bind.c b/ports/unix/guts/bind.c
new file mode 100644
index 0000000..93e4749
--- /dev/null
+++ b/ports/unix/guts/bind.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Wind River Systems; see
+ * guts/COPYRIGHT for information.
+ *
+ * int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
+ * int rc = -1;
+ */
+
+ rc = real_bind(sockfd, addr, addrlen);
+ /* we have created a thing! we need to record it in the
+ * database.
+ */
+ if (addr && addr->sa_family == AF_UNIX && rc >= 0) {
+ struct sockaddr_un *addr_un = (struct sockaddr_un *) addr;
+ /* Linux supports a special hackery where the name starts
+ * with a nul byte, I don't care about those
+ * probably.
+ */
+ if (addr_un->sun_path[0]) {
+ char *path = pseudo_root_path(__func__, __LINE__, AT_FDCWD, addr_un->sun_path, AT_SYMLINK_NOFOLLOW);
+ PSEUDO_STATBUF buf;
+ base_fstat(rc, &buf);
+ /* we don't really care that much whether this works, I suspect */
+ pseudo_client_op(OP_MKNOD, 0, -1, -1, path, &buf);
+ }
+ }
+
+/* return rc;
+ * }
+ */
diff --git a/ports/unix/wrapfuncs.in b/ports/unix/wrapfuncs.in
index 5f30ae6..1245593 100644
--- a/ports/unix/wrapfuncs.in
+++ b/ports/unix/wrapfuncs.in
@@ -68,3 +68,4 @@ int syncfs(int fd); /* async_skip=0 */
int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags); /* async_skip=0 */
int msync(void *addr, size_t length, int flags); /* async_skip=0 */
mode_t umask(mode_t mask);
+int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c
index 4a38bef..d1b0fca 100644
--- a/pseudo_wrappers.c
+++ b/pseudo_wrappers.c
@@ -28,6 +28,8 @@
#include <signal.h>
#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>