Pure Erlang implementation of 9p2000 protocol
filesystem fs 9p2000 erlang 9p
at master 56 lines 1.8 kB view raw
1diff --git i/compat.h w/compat.h 2index 2819b0e..349865e 100644 3--- i/compat.h 4+++ w/compat.h 5@@ -193,4 +193,7 @@ long long strtonum(const char *, long long, long long, const char **); 6 # include "compat/vis.h" 7 #endif 8 9+#define SOCK_CLOEXEC 0 10+#define SOCK_NONBLOCK 0 11+ 12 #endif /* COMPAT_H */ 13diff --git i/kamid/client.c w/kamid/client.c 14index 33e0206..063c698 100644 15--- i/kamid/client.c 16+++ w/kamid/client.c 17@@ -418,7 +418,7 @@ qid_update_from_sb(struct qid *qid, struct stat *sb) 18 * Theoretically (and hopefully!) this should be a 64 bit 19 * number. Unfortunately, 9P uses 32 bit timestamps. 20 */ 21- qid->vers = sb->st_mtim.tv_sec; 22+ qid->vers = sb->st_mtime; 23 24 if (S_ISREG(sb->st_mode)) 25 qid->type = QTFILE; 26@@ -1477,8 +1477,8 @@ serialize_stat(const char *fname, struct stat *sb, struct evbuffer *evb) 27 np_write32(evb, sb->st_dev); /* dev[4] */ 28 np_qid(evb, &qid); /* qid[13] */ 29 np_write32(evb, mode); /* mode[4] */ 30- np_write32(evb, sb->st_atim.tv_sec); /* atime[4] */ 31- np_write32(evb, sb->st_mtim.tv_sec); /* mtime[4] */ 32+ np_write32(evb, sb->st_atime); /* atime[4] */ 33+ np_write32(evb, sb->st_mtime); /* mtime[4] */ 34 35 /* special case: directories have size 0 */ 36 if (qid.type & QTDIR) 37diff --git i/kamid/control.c w/kamid/control.c 38index 9fef9a5..dd44435 100644 39--- i/kamid/control.c 40+++ w/kamid/control.c 41@@ -67,12 +67,14 @@ control_init(const char *path) 42 int fd; 43 mode_t old_umask; 44 45- if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 46+ if ((fd = socket(AF_UNIX, SOCK_STREAM, 47 0)) == -1) { 48 log_warn("%s: socket", __func__); 49 return (-1); 50 } 51 52+ fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK | O_CLOEXEC); 53+ 54 memset(&sun, 0, sizeof(sun)); 55 sun.sun_family = AF_UNIX; 56 strlcpy(sun.sun_path, path, sizeof(sun.sun_path));