Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Resource Manager Example Error?: (2 Items)
   
Resource Manager Example Error?  
The d_name member of struct dirent seems to require a null terminator (http://www.qnx.com/developers/docs/6.4.1/neutrino
/lib_ref/d/dirent.html). Unfortunately, the examples in http://www.qnx.com/developers/docs/6.4.1/neutrino/
getting_started/s1_resmgr.html do not allocate space a null terminator so file names that are an even multiple of 4 
characters in length cause all kinds of bad things to happen. dirent_size() (http://www.qnx.com/developers/docs/6.4.1/
neutrino/getting_started/s1_resmgr.html#rc_dirent_size) and dirent_fill() (http://www.qnx.com/developers/docs/6.4.1/
neutrino/getting_started/s1_resmgr.html#rc_dirent_fill) should include space for a null character. At least from my 
experimentation, dirent_size() should look something like

int
dirent_size (char *fname)
{
  return (ALIGN (offsetof (struct dirent, d_name) + strlen (fname) + 1 /* for \0 */));
}

A similar '+1' change is also required for dirent_fill()

Are the examples indeed lacking or have I missed something? Thanks.

Mark
RE: Resource Manager Example Error?  
I think you're right, so I'll create a doc PR. Thanks for pointing this
out. 


Steve Reid (stever@qnx.com)
Technical Editor
QNX Software Systems 
 

> -----Original Message-----
> From: Mark Dowdy [mailto:community-noreply@qnx.com] 
> Sent: Friday, April 02, 2010 2:21 PM
> To: ostech-core_os
> Subject: Resource Manager Example Error?
> 
> The d_name member of struct dirent seems to require a null 
> terminator 
> (http://www.qnx.com/developers/docs/6.4.1/neutrino/lib_ref/d/d
> irent.html). Unfortunately, the examples in 
> http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_star
> ted/s1_resmgr.html do not allocate space a null terminator so 
> file names that are an even multiple of 4 characters in 
> length cause all kinds of bad things to happen. dirent_size() 
> (http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_sta
> rted/s1_resmgr.html#rc_dirent_size) and dirent_fill() 
> (http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_sta
> rted/s1_resmgr.html#rc_dirent_fill) should include space for 
> a null character. At least from my experimentation, 
> dirent_size() should look something like
> 
> int
> dirent_size (char *fname)
> {
>   return (ALIGN (offsetof (struct dirent, d_name) + strlen 
> (fname) + 1 /* for \0 */));
> }
> 
> A similar '+1' change is also required for dirent_fill()
> 
> Are the examples indeed lacking or have I missed something? Thanks.
> 
> Mark
> 
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post51106
> 
>