readlink handler of resource manager

Hello,
it’s not very clear to me how the _IO_CONNECT_READLINK messages should be
properly handled in filesystem resource manager.
I found an example in the documentation of iofunc_open() but it doesn’t seem
to be working.
Here’s snippet of my code:

/* _IO_CONNECT_READLINK handler */
int io_readlink( resmgr_context_t *ctp, io_readlink_t *msg, IOFUNC_ATTR_T *attr, void *reserved )
{
int len;
struct {
struct _io_connect_link_reply r;
char *path;
} reply;

/* Get the redirect path */
reply.path = get_new_path(msg->connect.path);
len = strlen(reply.path+1);

_IO_SET_CONNECT_RET(ctp, _IO_CONNECT_RET_LINK);
memset(reply.r, 0, sizeof( reply.r ));
reply.r.eflag = msg->connect.eflag;
reply.r.nentries = 0;
reply.r.path_len = len;

len += sizeof(reply.r);

return(_RESMGR_PTR(ctp, &reply, len));
}

Thanks,
Martin.

Martin ?ev??k <sevcik@esys.cz> wrote:

it’s not very clear to me how the _IO_CONNECT_READLINK messages should be
properly handled in filesystem resource manager.
I found an example in the documentation of iofunc_open() but it doesn’t seem
to be working.
Here’s snippet of my code:

/* _IO_CONNECT_READLINK handler */
int io_readlink( resmgr_context_t *ctp, io_readlink_t *msg, IOFUNC_ATTR_T *attr, void *reserved )
{
int len;
struct {
struct _io_connect_link_reply r;
char *path;
} reply;

Unless you are going to perform a 2-part reply yourself, then you’ll
want the actual link pathname itself (and not a pointer) to follow the
reply header (ie “path[]” not “*path”). Now the “io_readlink_t” is
actually a union which has the header and the original message, so
has room itself to copy the redirected pathname into (although no
explicit field name, get at it with “(char *)(&msg->link_reply + 1)”
and copy the new pathname into there). So, I’d get rid of your “reply”
local (being on the stack it is not safe to reply with _RESMGR_PTR
anyway!) and re-use “msg”.

_IO_SET_CONNECT_RET(ctp, _IO_CONNECT_RET_LINK);

I don’t know if this is necessary/desirable … the disk filesystems
don’t set this status bit for their symlinks.

return(_RESMGR_PTR(ctp, &reply, len));

_RESMGR_PTR(ctp, &msg->link_reply, sizeof(msg->link_reply) + len + 1);