io_stat fog!

I don’t really understand how to reply correctly to an IO_STAT message.
i.e.

I write a ressource manager. Without doing anything special, when we do
a ls -l on a basic ressource manager, we get 0 as file size.
In my application, I want to have the real size of my ‘pseudo-file’.

First, I didn’t supply an io_stat function and I tried to set the
ocb->attr.nbytes field.
ls -l always gave 0
Strange if iofunc_stat_default() really use that structure to fill in
the io_stat returned structure ?!?

After, I tried to supply my own io-stat function begining with a very
simple code (your course code).

int io_stat(…)
{
msg->o.st_ino = 1;
msg->o.st_dev = 2;
msg->o.st_size = 10;

return(RESMGR_PTR(ctp, &msg->o, sizeof(msg->o));
}

Good for the size but, of course, not for the other information.

So, let’s go to use the helper function according to the help. In
parenthesis, there is an error in this code snipet, the resmgr_context_t
parameter is missing in the iofunc_stat() function.

io_stat(…)
{
iofunc_time_update(…);
iofunc_stat(…);

msg->o.st_size = 10;

return(_RESMGR_PTR(…));
}

Now, ok for all informations given by ls -l EXCEPT the size which is 0!!

gasp!

Maybe the difference is about st_ino and st_dev fields but I don’t
really know what to do with!

Could you tell me what it’s all about!

Alain.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

I don’t really understand how to reply correctly to an IO_STAT message.
i.e.

I write a ressource manager. Without doing anything special, when we do
a ls -l on a basic ressource manager, we get 0 as file size.
In my application, I want to have the real size of my ‘pseudo-file’.

First, I didn’t supply an io_stat function and I tried to set the
ocb->attr.nbytes field.
ls -l always gave 0
Strange if iofunc_stat_default() really use that structure to fill in
the io_stat returned structure ?!?

I just tried the above and it worked fine. First I set it in the
iofunc_attr_t that I pass to resmgr_attach(), worked fine. Then
I set ocb->attr->nbytes in an io_write() handler, worked fine.
When you call iofunc_attr_init() do you pass S_IFREG or S_IFNAM
for the second parameter? With something like S_IFCHR, ls displays
the major and minor device numbers.

In general it is best to not override the default stat handler if
you can, since as you’ve found out, it ain’t easy. Try setting
things in the attr structure instead, as you originally did try.

After, I tried to supply my own io-stat function begining with a very
simple code (your course code).

This has since been removed from the course (it’s not very useful,
as you’ve found).

int io_stat(…)
{
msg->o.st_ino = 1;
msg->o.st_dev = 2;
msg->o.st_size = 10;

return(RESMGR_PTR(ctp, &msg->o, sizeof(msg->o));
}

Good for the size but, of course, not for the other information.

So, let’s go to use the helper function according to the help. In
parenthesis, there is an error in this code snipet, the resmgr_context_t
parameter is missing in the iofunc_stat() function.

io_stat(…)
{
iofunc_time_update(…);
iofunc_stat(…);

msg->o.st_size = 10;

return(_RESMGR_PTR(…));
}

Now, ok for all informations given by ls -l EXCEPT the size which is 0!!

gasp!

Maybe the difference is about st_ino and st_dev fields but I don’t
really know what to do with!

Could you tell me what it’s all about!

Alain.

Steven Dufresne a écrit :

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
I don’t really understand how to reply correctly to an IO_STAT message.
i.e.

I write a ressource manager. Without doing anything special, when we do
a ls -l on a basic ressource manager, we get 0 as file size.
In my application, I want to have the real size of my ‘pseudo-file’.

First, I didn’t supply an io_stat function and I tried to set the
ocb->attr.nbytes field.
ls -l always gave 0
Strange if iofunc_stat_default() really use that structure to fill in
the io_stat returned structure ?!?

I just tried the above and it worked fine. First I set it in the
iofunc_attr_t that I pass to resmgr_attach(), worked fine. Then
I set ocb->attr->nbytes in an io_write() handler, worked fine.
When you call iofunc_attr_init() do you pass S_IFREG or S_IFNAM
for the second parameter? With something like S_IFCHR, ls displays
the major and minor device numbers.

Yes, that was the case, I didn’t pay attention to that point!
Thank you
Alain.