Determining which device has been contacted.

Hi. I’m currently writing a resource manager that takes over three
prefixes (/somepath/snap, /somepath/sample, /somepath/event). I’m doing
this as illustrated in the “Writing a Resource Manager” document; that
is, I just declare an array of iofunc_attr_t structures and attach each
of them in turn with resmgr_attach().

My question is, how do I determine which prefix a client is using? That
is, how can I tell whether a client has opened “snap” rather than
“sample”? In “Writing a Resource Manager”, it states that the msg->path
data received in io_open() (a wrapper around io_open_default()) will
contain the path data; this only seems to be the case when
resmgr_attach() was used to take over a directory; the path is “” for
multiple files. Any suggestions?

Josh Hamacher
FAAC Incorporated

Josh Hamacher a écrit :

Hi. I’m currently writing a resource manager that takes over three
prefixes (/somepath/snap, /somepath/sample, /somepath/event). I’m doing
this as illustrated in the “Writing a Resource Manager” document; that
is, I just declare an array of iofunc_attr_t structures and attach each
of them in turn with resmgr_attach().

My question is, how do I determine which prefix a client is using? That
is, how can I tell whether a client has opened “snap” rather than
“sample”? In “Writing a Resource Manager”, it states that the msg->path
data received in io_open() (a wrapper around io_open_default()) will
contain the path data; this only seems to be the case when
resmgr_attach() was used to take over a directory; the path is “” for
multiple files.

Yes that right, it’s unusable in your application

Any suggestions?

I think that the best choice is to use to overload the attribute structure
to add an ID that you could test after some client ask for open one of your
pathname. That is:

declare your attribute structure like that:

struct your_server_attr_s;
#define IOFUNC_ATTR_T struct your_server_attr_s

#include <sys/iofunc.h>
#include <sys/dispatch.h>
#include <sys/neutrino.h>

typedef struct your_server_attr_s
{
iofunc_attr_t attr;
int device;
}your_server_attr_t;



give it to you resource manager:

resmgr_attach(dpp,…, &your_server_attr);

in your io_func, just do:

int io_func(resmgr_context_t *ctp, io_func_t *msg, RESMGR_OCB *ocb)
{



switch(ocb.attr->device)
{

}

}



Hope it will help you

Thanks,
Alain.

Josh Hamacher
FAAC Incorporated

Either add to the attr structure to include a device entry (this will
require you writing alloc and free functions for the ocb and putting them in
your mount structure). The device entry can simply be an integer to your
array of pathnames. Make sure you set the device to the correct number
before doing the resmgr_attach. When someone does an open, you can know
which device they opened by checking the device entry in your new (expanded)
attribute structure.

OR

take over the pathname for /somepath and then look at path in the incoming
msg to see which of the three it is trying to open.

Hope this helps

Poseidon

Okay, that’s what I suspected. I was just curious if there was a
built-in Neutrino way of doing it. Thanks for the help.

Josh

I’m already overloading the attribute structure, so this is no problem.
Thanks.

Josh


Alain Bonnefoy wrote:

Josh Hamacher a écrit :


Hi. I’m currently writing a resource manager that takes over three
prefixes (/somepath/snap, /somepath/sample, /somepath/event). I’m doing
this as illustrated in the “Writing a Resource Manager” document; that
is, I just declare an array of iofunc_attr_t structures and attach each
of them in turn with resmgr_attach().

My question is, how do I determine which prefix a client is using? That
is, how can I tell whether a client has opened “snap” rather than
“sample”? In “Writing a Resource Manager”, it states that the msg->path
data received in io_open() (a wrapper around io_open_default()) will
contain the path data; this only seems to be the case when
resmgr_attach() was used to take over a directory; the path is “” for
multiple files.


Yes that right, it’s unusable in your application


Any suggestions?



I think that the best choice is to use to overload the attribute structure
to add an ID that you could test after some client ask for open one of your
pathname. That is:

declare your attribute structure like that:

struct your_server_attr_s;
#define IOFUNC_ATTR_T struct your_server_attr_s

#include <sys/iofunc.h
#include <sys/dispatch.h
#include <sys/neutrino.h

typedef struct your_server_attr_s
{
iofunc_attr_t attr;
int device;
}your_server_attr_t;



give it to you resource manager:

resmgr_attach(dpp,…, &your_server_attr);

in your io_func, just do:

int io_func(resmgr_context_t *ctp, io_func_t *msg, RESMGR_OCB *ocb)
{



switch(ocb.attr->device)
{

}

}



Hope it will help you

Thanks,
Alain.


Josh Hamacher
FAAC Incorporated

\

“Alain Bonnefoy” <alain.bonnefoy@icbt.com> wrote in message
news:3B77E595.77743242@icbt.com

Josh Hamacher a écrit :

Hi. I’m currently writing a resource manager that takes over three
prefixes (/somepath/snap, /somepath/sample, /somepath/event). I’m doing
this as illustrated in the “Writing a Resource Manager” document; that
is, I just declare an array of iofunc_attr_t structures and attach each
of them in turn with resmgr_attach().

My question is, how do I determine which prefix a client is using? That
is, how can I tell whether a client has opened “snap” rather than
“sample”? In “Writing a Resource Manager”, it states that the msg->path
data received in io_open() (a wrapper around io_open_default()) will
contain the path data; this only seems to be the case when
resmgr_attach() was used to take over a directory; the path is “” for
multiple files.

Yes that right, it’s unusable in your application

Any suggestions?


I think that the best choice is to use to overload the attribute structure
to add an ID that you could test after some client ask for open one of
your
pathname. That is:

declare your attribute structure like that:

struct your_server_attr_s;
#define IOFUNC_ATTR_T struct your_server_attr_s

#include <sys/iofunc.h
#include <sys/dispatch.h
#include <sys/neutrino.h

typedef struct your_server_attr_s
{
iofunc_attr_t attr;
int device;
}your_server_attr_t;

You could use the attr.inode. That what this variable is for,
holding a key that uniquely identify each attribute!


give it to you resource manager:

resmgr_attach(dpp,…, &your_server_attr);

in your io_func, just do:

int io_func(resmgr_context_t *ctp, io_func_t *msg, RESMGR_OCB *ocb)
{



switch(ocb.attr->device)
{

}

}



Hope it will help you

Thanks,
Alain.


Josh Hamacher
FAAC Incorporated
\