Remove code supporting SOCK_STREAM, as SOCK_DGRAM works fine
This commit is contained in:
parent
f782f0a9e3
commit
f4f951a0c1
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ops.c,v 1.22 2010/10/11 01:52:05 manu Exp $ */
|
||||
/* $NetBSD: ops.c,v 1.23 2010/10/11 05:37:58 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: perfuse.c,v 1.10 2010/10/03 05:46:47 manu Exp $ */
|
||||
/* $NetBSD: perfuse.c,v 1.11 2010/10/11 05:37:58 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
|
||||
@ -115,7 +115,7 @@ perfuse_open(path, flags, mode)
|
||||
if (strcmp(path, _PATH_FUSE) != 0)
|
||||
return open(path, flags, mode);
|
||||
|
||||
if ((sv[0] = socket(PF_LOCAL, PERFUSE_SOCKTYPE, 0)) == -1) {
|
||||
if ((sv[0] = socket(PF_LOCAL, SOCK_DGRAM, 0)) == -1) {
|
||||
#ifdef PERFUSE_DEBUG
|
||||
DWARN("%s:%d socket failed: %s", __func__, __LINE__);
|
||||
#endif
|
||||
@ -149,7 +149,7 @@ perfuse_open(path, flags, mode)
|
||||
* we will talk using a socketpair
|
||||
* instead of /dev/fuse.
|
||||
*/
|
||||
if (socketpair(PF_LOCAL, PERFUSE_SOCKTYPE, 0, sv) != 0) {
|
||||
if (socketpair(PF_LOCAL, SOCK_DGRAM, 0, sv) != 0) {
|
||||
DWARN("%s:%d: socketpair failed", __func__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
@ -218,12 +218,10 @@ perfuse_mount(source, target, filesystemtype, mountflags, data)
|
||||
int s;
|
||||
size_t len;
|
||||
struct perfuse_mount_out *pmo;
|
||||
#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
|
||||
struct sockaddr_storage ss;
|
||||
struct sockaddr_un *sun;
|
||||
struct sockaddr *sa;
|
||||
socklen_t sa_len;
|
||||
#endif
|
||||
size_t sock_len;
|
||||
char *frame;
|
||||
char *cp;
|
||||
@ -244,7 +242,6 @@ perfuse_mount(source, target, filesystemtype, mountflags, data)
|
||||
* XXX This socket is not removed at exit time yet
|
||||
*/
|
||||
sock_len = 0;
|
||||
#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
|
||||
sa = (struct sockaddr *)(void *)&ss;
|
||||
sun = (struct sockaddr_un *)(void *)&ss;
|
||||
sa_len = sizeof(ss);
|
||||
@ -263,7 +260,6 @@ perfuse_mount(source, target, filesystemtype, mountflags, data)
|
||||
|
||||
sock_len = strlen(sun->sun_path) + 1;
|
||||
}
|
||||
#endif /* PERFUSE_SOCKTYPE */
|
||||
|
||||
len = sizeof(*pmo);
|
||||
len += source ? (uint32_t)strlen(source) + 1 : 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: perfuse_if.h,v 1.9 2010/09/23 16:02:34 manu Exp $ */
|
||||
/* $NetBSD: perfuse_if.h,v 1.10 2010/10/11 05:37:58 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
|
||||
@ -36,7 +36,6 @@
|
||||
#define PERFUSE_MOUNT_MAGIC "noFuseRq"
|
||||
#define PERFUSE_UNKNOWN_INO 0xffffffff
|
||||
|
||||
#define PERFUSE_SOCKTYPE SOCK_DGRAM
|
||||
/*
|
||||
* Diagnostic flags. This global is used only for DPRINTF/DERR/DWARN
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: perfuse_priv.h,v 1.15 2010/10/11 01:08:26 manu Exp $ */
|
||||
/* $NetBSD: perfuse_priv.h,v 1.16 2010/10/11 05:37:58 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr.c,v 1.9 2010/10/11 01:08:26 manu Exp $ */
|
||||
/* $NetBSD: subr.c,v 1.10 2010/10/11 05:37:58 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
|
||||
@ -44,12 +44,9 @@ perfuse_new_pn(pu, name, parent)
|
||||
const char *name;
|
||||
struct puffs_node *parent;
|
||||
{
|
||||
struct perfuse_state *ps;
|
||||
struct puffs_node *pn;
|
||||
struct perfuse_node_data *pnd;
|
||||
|
||||
ps = puffs_getspecific(pu);
|
||||
|
||||
if ((pnd = malloc(sizeof(*pnd))) == NULL)
|
||||
DERR(EX_OSERR, "malloc failed");
|
||||
|
||||
@ -84,10 +81,8 @@ perfuse_destroy_pn(pu, pn)
|
||||
struct puffs_usermount *pu;
|
||||
struct puffs_node *pn;
|
||||
{
|
||||
struct perfuse_state *ps;
|
||||
struct perfuse_node_data *pnd;
|
||||
|
||||
ps = puffs_getspecific(pu);
|
||||
pnd = PERFUSE_NODE_DATA(pn);
|
||||
|
||||
if (pnd->pnd_parent != NULL) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: msg.c,v 1.8 2010/10/11 01:12:25 manu Exp $ */
|
||||
/* $NetBSD: msg.c,v 1.9 2010/10/11 05:37:58 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
|
||||
@ -59,7 +59,7 @@ perfuse_open_sock(void)
|
||||
|
||||
(void)unlink(_PATH_FUSE);
|
||||
|
||||
if ((s = socket(AF_LOCAL, PERFUSE_SOCKTYPE, 0)) == -1)
|
||||
if ((s = socket(AF_LOCAL, SOCK_DGRAM, 0)) == -1)
|
||||
err(EX_OSERR, "socket failed");
|
||||
|
||||
sa = (const struct sockaddr *)(void *)&sun;
|
||||
@ -90,13 +90,8 @@ perfuse_open_sock(void)
|
||||
if (bind(s, sa, (socklen_t )sun.sun_len) == -1)
|
||||
err(EX_OSERR, "cannot open \"%s\" socket", _PATH_FUSE);
|
||||
|
||||
#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
|
||||
if (connect(s, sa, (socklen_t )sun.sun_len) == -1)
|
||||
err(EX_OSERR, "cannot open \"%s\" socket", _PATH_FUSE);
|
||||
#else
|
||||
if (listen(s, 1) == -1)
|
||||
err(EX_OSERR, "listen failed");
|
||||
#endif
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -475,117 +470,86 @@ perfuse_readframe(pu, pufbuf, fd, done)
|
||||
int *done;
|
||||
{
|
||||
struct fuse_out_header foh;
|
||||
size_t offset;
|
||||
size_t remain;
|
||||
size_t len;
|
||||
ssize_t readen;
|
||||
void *data;
|
||||
int peek = 0;
|
||||
|
||||
#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
|
||||
peek = MSG_PEEK;
|
||||
#endif
|
||||
offset = puffs_framebuf_telloff(pufbuf);
|
||||
|
||||
/*
|
||||
* Read the header
|
||||
* MSG_PEEK is used so that this code works for SOCK_DGRAM
|
||||
* socket. The loop is only needed to work with SOCK_STREAM.
|
||||
*/
|
||||
while (offset < sizeof(foh)) {
|
||||
remain = sizeof(foh) - offset;
|
||||
PUFFS_FRAMEBUF_GETWINDOW(pufbuf, offset, &data, &remain);
|
||||
len = sizeof(foh);
|
||||
PUFFS_FRAMEBUF_GETWINDOW(pufbuf, 0, &data, &len);
|
||||
|
||||
switch (readen = recv(fd, data, remain, MSG_NOSIGNAL|peek)) {
|
||||
case 0:
|
||||
DWARNX("%s: recv retunred 0", __func__);
|
||||
return ECONNRESET;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case -1:
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
DWARN("%s: recv retunred -1", __func__);
|
||||
return errno;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
#if defined(PERFUSE_DEBUG) && (PERFUSE_SOCKTYPE == SOCK_DGRAM)
|
||||
if (readen != remain)
|
||||
DERRX(EX_SOFTWARE, "%s: short recv %zd/%zd",
|
||||
__func__, readen, remain);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
offset += readen;
|
||||
if (puffs_framebuf_seekset(pufbuf, offset) == -1)
|
||||
DERR(EX_OSERR, "puffs_framebuf_seekset failed");
|
||||
switch (readen = recv(fd, data, len, MSG_NOSIGNAL|MSG_PEEK)) {
|
||||
case 0:
|
||||
DWARNX("%s: recv retunred 0", __func__);
|
||||
return ECONNRESET;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case -1:
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
DWARN("%s: recv retunred -1", __func__);
|
||||
return errno;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
|
||||
/*
|
||||
* We had a peek at the header, now really read it.
|
||||
*/
|
||||
offset = 0;
|
||||
#ifdef PERFUSE_DEBUG
|
||||
if (readen != len)
|
||||
DERRX(EX_SOFTWARE, "%s: short recv %zd/%zd",
|
||||
__func__, readen, len);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* We have a header, get remaing length to read
|
||||
*/
|
||||
if (puffs_framebuf_getdata_atoff(pufbuf, 0, &foh, sizeof(foh)) != 0)
|
||||
DERR(EX_SOFTWARE, "puffs_framebuf_getdata_atoff failed");
|
||||
;
|
||||
|
||||
len = foh.len;
|
||||
|
||||
#ifdef PERFUSE_DEBUG
|
||||
if (foh.len > FUSE_BUFSIZE)
|
||||
DERRX(EX_SOFTWARE, "%s: foh.len = %d (this is huge!)",
|
||||
__func__, foh.len);
|
||||
if (len > FUSE_BUFSIZE)
|
||||
DERRX(EX_SOFTWARE, "%s: foh.len = %d", __func__, len);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If we have only readen the header so far,
|
||||
* this is time to reserve space.
|
||||
* This is time to reserve space.
|
||||
*/
|
||||
remain = foh.len - offset;
|
||||
if (offset == sizeof(foh))
|
||||
if (puffs_framebuf_reserve_space(pufbuf, remain) == -1)
|
||||
DERR(EX_OSERR, "puffs_framebuf_reserve_space failed");
|
||||
|
||||
if (puffs_framebuf_reserve_space(pufbuf, len) == -1)
|
||||
DERR(EX_OSERR, "puffs_framebuf_reserve_space failed");
|
||||
|
||||
/*
|
||||
* And read the remaining data
|
||||
*/
|
||||
while (remain != 0) {
|
||||
PUFFS_FRAMEBUF_GETWINDOW(pufbuf, offset, &data, &remain);
|
||||
PUFFS_FRAMEBUF_GETWINDOW(pufbuf, 0, &data, &len);
|
||||
|
||||
switch (readen = recv(fd, data, remain, MSG_NOSIGNAL)) {
|
||||
case 0:
|
||||
DWARNX("%s: recv retunred 0", __func__);
|
||||
return ECONNRESET;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case -1:
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
DWARN("%s: recv retunred -1", __func__);
|
||||
return errno;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
#if defined(PERFUSE_DEBUG) && (PERFUSE_SOCKTYPE == SOCK_DGRAM)
|
||||
if (readen != remain)
|
||||
DERRX(EX_SOFTWARE, "%s: short recv %zd/%zd",
|
||||
__func__, readen, remain);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
offset += readen;
|
||||
remain -= readen;
|
||||
|
||||
if (puffs_framebuf_seekset(pufbuf, offset) == -1)
|
||||
DERR(EX_OSERR, "puffs_framebuf_seekset failed");
|
||||
switch (readen = recv(fd, data, len, MSG_NOSIGNAL)) {
|
||||
case 0:
|
||||
DWARNX("%s: recv retunred 0", __func__);
|
||||
return ECONNRESET;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case -1:
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
DWARN("%s: recv retunred -1", __func__);
|
||||
return errno;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef PERFUSE_DEBUG
|
||||
if (readen != len)
|
||||
DERRX(EX_SOFTWARE, "%s: short recv %zd/%zd",
|
||||
__func__, readen, len);
|
||||
#endif
|
||||
|
||||
*done = 1;
|
||||
return 0;
|
||||
}
|
||||
@ -598,48 +562,36 @@ perfuse_writeframe(pu, pufbuf, fd, done)
|
||||
int fd;
|
||||
int *done;
|
||||
{
|
||||
size_t offset;
|
||||
size_t len;
|
||||
ssize_t written;
|
||||
size_t remain;
|
||||
void *data;
|
||||
|
||||
offset = puffs_framebuf_telloff(pufbuf);
|
||||
len = puffs_framebuf_tellsize(pufbuf) - offset;
|
||||
remain = len;
|
||||
len = puffs_framebuf_tellsize(pufbuf);
|
||||
PUFFS_FRAMEBUF_GETWINDOW(pufbuf, 0, &data, &len);
|
||||
|
||||
while (remain != 0) {
|
||||
PUFFS_FRAMEBUF_GETWINDOW(pufbuf, offset, &data, &len);
|
||||
|
||||
switch (written = send(fd, data, remain, MSG_NOSIGNAL)) {
|
||||
case 0:
|
||||
DWARNX("%s: send retunred 0", __func__);
|
||||
return ECONNRESET;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case -1:
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
DWARN("%s: send retunred -1", __func__);
|
||||
return errno;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
#if defined(PERFUSE_DEBUG) && (PERFUSE_SOCKTYPE == SOCK_DGRAM)
|
||||
if (written != remain)
|
||||
DERRX(EX_SOFTWARE, "%s: short send %zd/%zd",
|
||||
__func__, written, remain);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
remain -= written;
|
||||
offset += written;
|
||||
|
||||
if (puffs_framebuf_seekset(pufbuf, offset) == -1)
|
||||
DERR(EX_OSERR, "puffs_framebuf_seekset failed");
|
||||
switch (written = send(fd, data, len, MSG_NOSIGNAL)) {
|
||||
case 0:
|
||||
DWARNX("%s: send retunred 0", __func__);
|
||||
return ECONNRESET;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case -1:
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
DWARN("%s: send retunred -1", __func__);
|
||||
return errno;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef PERFUSE_DEBUG
|
||||
if (written != len)
|
||||
DERRX(EX_SOFTWARE, "%s: short send %zd/%zd",
|
||||
__func__, written, len);
|
||||
#endif
|
||||
|
||||
*done = 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: perfused.c,v 1.10 2010/09/23 16:02:34 manu Exp $ */
|
||||
/* $NetBSD: perfused.c,v 1.11 2010/10/11 05:37:58 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
|
||||
@ -400,33 +400,11 @@ main(argc, argv)
|
||||
s = perfuse_open_sock();
|
||||
|
||||
do {
|
||||
#if (PERFUSE_SOCKTYPE != SOCK_DGRAM)
|
||||
struct sockaddr *sa;
|
||||
struct sockaddr_storage ss;
|
||||
socklen_t ss_len;
|
||||
#endif
|
||||
int fd;
|
||||
|
||||
#ifdef PERFUSE_DEBUG
|
||||
if (perfuse_diagflags & PDF_MISC)
|
||||
DPRINTF("waiting connexion\n");
|
||||
DPRINTF("perfused ready\n");
|
||||
#endif
|
||||
#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
|
||||
fd = s;
|
||||
#else
|
||||
sa = (struct sockaddr *)(void *)&ss;
|
||||
ss_len = sizeof(ss);
|
||||
|
||||
if ((fd = accept(s, sa, &ss_len)) == -1)
|
||||
DERR(EX_OSERR, "accept failed");
|
||||
|
||||
#ifdef PERFUSE_DEBUG
|
||||
if (perfuse_diagflags & PDF_MISC)
|
||||
DPRINTF("connexion accepted\n");
|
||||
#endif /* PERFUSE_DEBUG */
|
||||
#endif /* PERFUSE_SOCKTYPE */
|
||||
|
||||
new_mount(fd, PMNT_DEVFUSE);
|
||||
new_mount(s, PMNT_DEVFUSE);
|
||||
} while (1 /* CONSTCOND */);
|
||||
|
||||
/* NOTREACHED */
|
||||
|
Loading…
Reference in New Issue
Block a user