version 1.40.4.6, 2007/11/11 16:47:50 |
version 1.40.4.7, 2007/11/14 19:04:36 |
Line 43 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 43 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/proc.h> |
#include <sys/proc.h> |
#include <sys/vnode.h> |
#include <sys/vnode.h> |
|
|
#include <dev/puttervar.h> |
#include <dev/putter/putter_sys.h> |
|
|
#include <fs/puffs/puffs_msgif.h> |
#include <fs/puffs/puffs_msgif.h> |
#include <fs/puffs/puffs_sys.h> |
#include <fs/puffs/puffs_sys.h> |
Line 630 puffs_msgif_getout(void *this, size_t ma |
|
Line 630 puffs_msgif_getout(void *this, size_t ma |
|
puffs_msgpark_release(park); |
puffs_msgpark_release(park); |
continue; |
continue; |
} |
} |
|
preq = park->park_preq; |
|
|
|
#if 0 |
/* check size */ |
/* check size */ |
preq = park->park_preq; |
/* |
|
* XXX: this check is not valid for now, we don't know |
|
* the size of the caller's input buffer. i.e. this |
|
* will most likely go away |
|
*/ |
if (maxsize < preq->preq_frhdr.pfr_len) { |
if (maxsize < preq->preq_frhdr.pfr_len) { |
DPRINTF(("buffer too small\n")); |
DPRINTF(("buffer too small\n")); |
puffs_msgpark_release(park); |
puffs_msgpark_release(park); |
error = E2BIG; |
error = E2BIG; |
break; |
break; |
} |
} |
|
#endif |
|
|
DPRINTF(("returning\n")); |
DPRINTF(("returning\n")); |
|
|
Line 665 puffs_msgif_getout(void *this, size_t ma |
|
Line 672 puffs_msgif_getout(void *this, size_t ma |
|
|
|
if (error == 0) { |
if (error == 0) { |
*data = (uint8_t *)preq; |
*data = (uint8_t *)preq; |
preq->preq_frhdr.pfr_len = park->park_copylen; |
preq->preq_pth.pth_framelen = park->park_copylen; |
preq->preq_frhdr.pfr_alloclen = park->park_maxlen; |
*dlen = preq->preq_pth.pth_framelen; |
preq->preq_frhdr.pfr_type = preq->preq_opclass; /* yay! */ |
|
*dlen = preq->preq_frhdr.pfr_len; |
|
*parkptr = park; |
*parkptr = park; |
} |
} |
|
|
Line 727 puffs_msgif_waitcount(void *this) |
|
Line 732 puffs_msgif_waitcount(void *this) |
|
* XXX: locking with this one? |
* XXX: locking with this one? |
*/ |
*/ |
static void |
static void |
puffs_msgif_incoming(void *this, void *buf) |
puffsop_msg(void *this, struct puffs_req *preq) |
{ |
{ |
struct puffs_mount *pmp = this; |
struct puffs_mount *pmp = this; |
struct puffs_req *preq = buf; |
struct putter_hdr *pth = &preq->preq_pth; |
struct puffs_frame *pfr = &preq->preq_frhdr; |
|
struct puffs_msgpark *park; |
struct puffs_msgpark *park; |
int release, wgone; |
int release, wgone; |
|
|
Line 756 puffs_msgif_incoming(void *this, void *b |
|
Line 760 puffs_msgif_incoming(void *this, void *b |
|
|
|
mutex_enter(&park->park_mtx); |
mutex_enter(&park->park_mtx); |
puffs_msgpark_reference(park); |
puffs_msgpark_reference(park); |
if (pfr->pfr_len > park->park_maxlen) { |
if (pth->pth_framelen > park->park_maxlen) { |
DPRINTF(("puffs_msgif_income: invalid buffer length: " |
DPRINTF(("puffs_msgif_income: invalid buffer length: " |
"%zu (req %" PRIu64 ", \n", pfr->pfr_len, preq->preq_id)); |
"%" PRIu64 " (req %" PRIu64 ", \n", pth->pth_framelen, |
|
preq->preq_id)); |
park->park_preq->preq_rv = EPROTO; |
park->park_preq->preq_rv = EPROTO; |
cv_signal(&park->park_cv); |
cv_signal(&park->park_cv); |
puffs_msgpark_release(park); |
puffs_msgpark_release(park); |
Line 780 puffs_msgif_incoming(void *this, void *b |
|
Line 785 puffs_msgif_incoming(void *this, void *b |
|
if (park->park_flags & PARKFLAG_CALL) { |
if (park->park_flags & PARKFLAG_CALL) { |
DPRINTF(("puffs_msgif_income: call for %p, arg %p\n", |
DPRINTF(("puffs_msgif_income: call for %p, arg %p\n", |
park->park_preq, park->park_donearg)); |
park->park_preq, park->park_donearg)); |
park->park_done(pmp, buf, park->park_donearg); |
park->park_done(pmp, preq, park->park_donearg); |
release = 2; |
release = 2; |
} else { |
} else { |
/* XXX: yes, I know */ |
/* XXX: yes, I know */ |
memcpy(park->park_preq, buf, pfr->pfr_len); |
memcpy(park->park_preq, preq, pth->pth_framelen); |
release = 1; |
release = 1; |
} |
} |
} |
} |
Line 939 puffsop_flush(struct puffs_mount *pmp, s |
|
Line 944 puffsop_flush(struct puffs_mount *pmp, s |
|
} |
} |
|
|
int |
int |
puffs_msgif_dispatch(void *this, uint8_t *buf) |
puffs_msgif_dispatch(void *this, struct putter_hdr *pth) |
{ |
{ |
struct puffs_mount *pmp = this; |
struct puffs_mount *pmp = this; |
struct puffs_frame *pfr = (struct puffs_frame *)buf; |
struct puffs_req *preq = (struct puffs_req *)pth; |
|
|
|
/* XXX: need to send error to userspace */ |
|
if (pth->pth_framelen < sizeof(struct puffs_req)) |
|
return EINVAL; /* E2SMALL */ |
|
|
switch (PUFFSOP_OPCLASS(pfr->pfr_type)) { |
switch (PUFFSOP_OPCLASS(preq->preq_opclass)) { |
case PUFFSOP_VN: |
case PUFFSOP_VN: |
case PUFFSOP_VFS: |
case PUFFSOP_VFS: |
puffs_msgif_incoming(pmp, buf); |
puffsop_msg(pmp, preq); |
break; |
break; |
case PUFFSOP_FLUSH: |
case PUFFSOP_FLUSH: |
puffsop_flush(pmp, (void *)buf); |
if (pth->pth_framelen != sizeof(struct puffs_flush)) |
|
return EINVAL; |
|
puffsop_flush(pmp, (struct puffs_flush *)preq); |
break; |
break; |
case PUFFSOP_SUSPEND: |
case PUFFSOP_SUSPEND: |
puffsop_suspend(pmp); |
puffsop_suspend(pmp); |