Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - io_mknod callout in resource manager and differentiating between mkdir() and mknod(): (4 Items)
   
io_mknod callout in resource manager and differentiating between mkdir() and mknod()  
I am implementing a resource manager for my mount point on the file system.

As part of that, I have specified a callout for mknod() as follows:

resmgr_connect_funcs_t  connect_funcs;
connect_funcs.mknod = io_mknod;

and the mknod callout is defined as:
int io_mknod(resmgr_context_t *ctp, io_mknod_t *msg, RESMGR_HANDLE_T *handle, void *reserved);

in this callout, io_mknod() how do I differentiate between a client call to mknod() and a client call to mkdir().

Empirical observations led me to assume that when the mode value is 16384, the callout was invoked for a client call to 
mknod() and when the mode value is 16877, the callout was invoked for a client call to mkdir(). So my code becomes 
something like this:

int io_mknod(resmgr_context_t *ctp, io_mknod_t *msg, RESMGR_HANDLE_T *handle, void *reserved)
{
if(  msg->connect.mode == 16877)
     // we got called for mkdir()
else
    // we got called for mknod()
}

Is there any other way to differentiate? I have not been able to reconcile these values (16384 or 16877) to any ORing of
 constants in the header files.

Thanks,
ms
Re: io_mknod callout in resource manager and differentiating between mkdir() and mknod()  
Hi Manoj,

I'm afraid you are out of luck trying to differentiate mknod() and mkdir(), because internally, mkdir() essentially does
:
   mknod(path, (mode & ~S_IFMT) | S_IFDIR, 0);

Is there a specific reason you want to distinguish those two client API calls?

Kind regard,
Thomas
Re: io_mknod callout in resource manager and differentiating between mkdir() and mknod()  
Thanks Thomas for the quick reply.

Yeah, from what you explained it pretty much seems impossible to differentiate the calls. The reason to do so was to 
know if the user was trying to create a directory (mkdir) or a special file (mknod) and appropriately log it.

Thanks,
Manoj
Re: io_mknod callout in resource manager and differentiating between mkdir() and mknod()  
Hi Manoj,

for logging the type of node (i.e., directory, special, ...), (msg->connect.mode & S_IFMT) should give you all required 
information. I suggest using the S_IF*** macros from sys/stat.h for comparison.

Kind regards,
Thomas