Hum, I wonder if I really understand your problem.
Alain.
Yes, I have done all that.
My problem is that while in the ocb_calloc() function, where I have the
perfect opportunity to save away the ioflag value, I don’t know (while
in this function) where to find it. The only place I know where the
ioflag field exists is in the connect message, and sometime later, in
the ocb.attr structure. Presumably, the ocb.attr stucture is loaded
sometime after my ocb_calloc() function, and is therefore
theoretically there by the time iofunc_open_default() returns back to
the io_open(). But as I said, from within the io_open() function, I
don’t know how to find that particular OCB.
Doing it all manually (that is, not using iofunc_open_default()) doesn’t
work for me.
I need this open mode value at this point do that I can pass it to
another object in the resource manager.
I had thought of waiting until a first read, write, devctl, or something
to catch the OCB there. But I feel this approach is somewhat ugly, even
if it worked! Besides, I need that value prior to the client accessing
the device.
Geoff.
Alain Bonnefoy wrote:
I would suggest you to attach a couple of ocb_calloc()/ocb_free() funcs
where you could anything you need in your ocb.
/* necessary HERE for correct io_func prototypes */
struct my_ocb_s;
#define IOFUNC_OCB_T struct my_ocb_s
#include <sys/iofunc.h
#include <sys/dispatch.h
#include <sys/neutrino.h
typedef struct my_ocb_s
{
iofunc_ocb_t ocb;
unsigned my_flag;
}my_ocb_t;
static iofunc_funcs_t my_ocb_funcs = {
_IOFUNC_NFUNCS,
my_ocb_calloc,
my_ocb_free
};
static iofunc_mount_t my_mount = {0, 0, 0, 0, &my_ocb_funcs};
my_init_resmgr(void){
…
my_resmgr_attr[numDev].attr.mount = &my_mount;
if (resmgr_attach(dpp, &resmgr_attr, “my_resmgr”, _FTYPE_ANY,
_RESMGR_FLAG_SELF, &my_connect_funcs, &my_io_funcs, &my_server_attr) ==
-1) {
puts(“Gloups!!”);
exit(errno);
}
…
}
my_ocb_t *
my_ocb_calloc (resmgr_context_t *ctp, my_resmgr_attr_t *tattr)
{
my_ocb_t *tocb;
if ((tocb = calloc (1, sizeof (my_ocb_t))) == NULL) {
puts(“gloups!!”);
return(0);
}
tocb->my_flag = my_value;
// do anything else to the ocb
return(tocb);
}
void
my_ocb_free (my_ocb_t *tocb)
{
free (tocb);
}
Hope I didn’t forget anything!
Regards,
Alain.
Geoff Roberts a écrit:
Hi,
I have managed to make myself a resource manager that is a thread
running in an io-net shared object. It mainly works, but I am now
stumbling.
I want to save the msg->connect.ioflag value (O_RDONLY, etc) in the
[extended] OCB while still in the io_open() function, but am not sure
how to find the proper, and newly created OCB (by ocb_calloc()). I have
been using iofunc_open_default() and I know that a valid OCB has been
created.
I thought I would try using the sequence suggested in the doc for
iofunc_open_default() instead. This is basically calls to iofunc_open(),
iofunc_ocb_calloc(), iofunc_ocb_attach(), and resmgr_open_bind(). This
results in a failure by io-net to load the shared object when I try to
mount it.
Can someone please let me know what the recommended way to create and
gain access to a new OCB while still in the io_open() function is? I’m
probably missing something simple here…
Thanks,
Geoff Roberts.
\