inode_find: Now takes struct inode_desc_s type as input. This was necessary before that structure includes some data storage. It was used within inode_find(), but that means that the life of the data was the life of inode_find(). That data must persist longer. It is now provided by the caller so that the life of the data persists for the entire life of the caller.

This commit is contained in:
Gregory Nutt
2017-02-05 09:51:42 -06:00
parent 990bed903e
commit 8f2c7198ed
20 changed files with 284 additions and 129 deletions

View File

@@ -89,8 +89,8 @@
mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
{
FAR struct inode *inode;
FAR const char *relpath = NULL;
FAR struct mqueue_inode_s *msgq;
struct inode_search_s desc;
char fullpath[MAX_MQUEUE_PATH];
va_list ap;
struct mq_attr *attr;
@@ -133,10 +133,18 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
* have incremented the reference count on the inode.
*/
inode = inode_find(fullpath, &relpath, false);
if (inode)
RESET_SEARCH(&desc);
desc.path = fullpath;
ret = inode_find(&desc);
if (ret >= 0)
{
/* It exists. Verify that the inode is a message queue */
/* Something exists at this path. Get the search results */
inode = desc.node;
DEBUGASSERT(inode != NULL);
/* Verify that the inode is a message queue */
if (!INODE_IS_MQUEUE(inode))
{

View File

@@ -76,7 +76,7 @@
int mq_unlink(FAR const char *mq_name)
{
FAR struct inode *inode;
FAR const char *relpath = NULL;
struct inode_search_s desc;
char fullpath[MAX_MQUEUE_PATH];
int errcode;
int ret;
@@ -87,16 +87,24 @@ int mq_unlink(FAR const char *mq_name)
/* Get the inode for this message queue. */
RESET_SEARCH(&desc);
desc.path = fullpath;
sched_lock();
inode = inode_find(fullpath, &relpath, false);
if (!inode)
ret = inode_find(&desc);
if (ret < 0)
{
/* There is no inode that includes in this path */
errcode = ENOENT;
errcode = -ret;
goto errout;
}
/* Get the search results */
inode = desc.node;
DEBUGASSERT(inode != NULL);
/* Verify that what we found is, indeed, a message queue */
if (!INODE_IS_MQUEUE(inode))