fs: remove INODE_IS_SPECIAL() use others instead
Change-Id: I949f1ad012836e6cb233d5362fe2542732b5ecf4 Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
f5b59e287a
commit
3386941a10
@ -356,7 +356,7 @@ int nx_mount(FAR const char *source, FAR const char *target,
|
|||||||
* node)?
|
* node)?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (INODE_IS_SPECIAL(mountpt_inode))
|
if (!INODE_IS_PSEUDODIR(mountpt_inode))
|
||||||
{
|
{
|
||||||
ferr("ERROR: target %s exists and is a special node\n", target);
|
ferr("ERROR: target %s exists and is a special node\n", target);
|
||||||
ret = -ENOTDIR;
|
ret = -ENOTDIR;
|
||||||
|
@ -259,8 +259,6 @@ int inode_stat(FAR struct inode *inode, FAR struct stat *buf, int resolve)
|
|||||||
|
|
||||||
/* Handle "special" nodes */
|
/* Handle "special" nodes */
|
||||||
|
|
||||||
if (INODE_IS_SPECIAL(inode))
|
|
||||||
{
|
|
||||||
#if defined(CONFIG_FS_NAMED_SEMAPHORES)
|
#if defined(CONFIG_FS_NAMED_SEMAPHORES)
|
||||||
/* Check for a named semaphore */
|
/* Check for a named semaphore */
|
||||||
|
|
||||||
@ -361,13 +359,10 @@ int inode_stat(FAR struct inode *inode, FAR struct stat *buf, int resolve)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Handle "normal inodes */
|
/* Handle "normal inodes */
|
||||||
|
|
||||||
else if (inode->u.i_ops != NULL)
|
if (inode->u.i_ops != NULL)
|
||||||
{
|
{
|
||||||
/* Determine read/write privileges based on the existence of read
|
/* Determine read/write privileges based on the existence of read
|
||||||
* and write methods.
|
* and write methods.
|
||||||
|
@ -106,25 +106,8 @@ int nx_unlink(FAR const char *pathname)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
/* If this is a "dangling" pseudo-file node (i.e., it has no operations)
|
|
||||||
* or a soft link, then rm should remove the node.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
|
|
||||||
/* A soft link is the only "specal" file that we can remove via unlink(). */
|
|
||||||
|
|
||||||
if (!INODE_IS_SPECIAL(inode) || INODE_IS_SOFTLINK(inode))
|
|
||||||
#else
|
|
||||||
if (!INODE_IS_SPECIAL(inode))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/* If this is a pseudo-file node (i.e., it has no operations)
|
|
||||||
* then unlink should remove the node.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (inode->u.i_ops != NULL)
|
|
||||||
{
|
|
||||||
ret = inode_semtake();
|
ret = inode_semtake();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -138,8 +121,7 @@ int nx_unlink(FAR const char *pathname)
|
|||||||
if (inode->i_child != NULL)
|
if (inode->i_child != NULL)
|
||||||
{
|
{
|
||||||
ret = -ENOTEMPTY;
|
ret = -ENOTEMPTY;
|
||||||
inode_semgive();
|
goto errout_with_sem;
|
||||||
goto errout_with_inode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notify the driver that it has been unlinked. If there are no
|
/* Notify the driver that it has been unlinked. If there are no
|
||||||
@ -154,7 +136,7 @@ int nx_unlink(FAR const char *pathname)
|
|||||||
ret = inode->u.i_ops->unlink(inode);
|
ret = inode->u.i_ops->unlink(inode);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
goto errout_with_inode;
|
goto errout_with_sem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||||
@ -165,10 +147,26 @@ int nx_unlink(FAR const char *pathname)
|
|||||||
ret = inode->u.i_bops->unlink(inode);
|
ret = inode->u.i_bops->unlink(inode);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
goto errout_with_inode;
|
goto errout_with_sem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
|
||||||
|
else if (INODE_IS_PSEUDODIR(inode) || INODE_IS_SOFTLINK(inode))
|
||||||
|
#else
|
||||||
|
else if (INODE_IS_PSEUDODIR(inode))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* If this is a "dangling" pseudo-file node
|
||||||
|
* (i.e., it has no operations) or a soft link,
|
||||||
|
* then rm should remove the node.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = -ENXIO;
|
||||||
|
goto errout_with_sem;
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove the old inode. Because we hold a reference count on the
|
/* Remove the old inode. Because we hold a reference count on the
|
||||||
* inode, it will not be deleted now. It will be deleted when all
|
* inode, it will not be deleted now. It will be deleted when all
|
||||||
@ -184,18 +182,7 @@ int nx_unlink(FAR const char *pathname)
|
|||||||
{
|
{
|
||||||
goto errout_with_inode;
|
goto errout_with_inode;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = -EISDIR;
|
|
||||||
goto errout_with_inode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
ret = -ENXIO;
|
|
||||||
goto errout_with_inode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Successfully unlinked */
|
/* Successfully unlinked */
|
||||||
@ -204,6 +191,9 @@ int nx_unlink(FAR const char *pathname)
|
|||||||
RELEASE_SEARCH(&desc);
|
RELEASE_SEARCH(&desc);
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
|
errout_with_sem:
|
||||||
|
inode_semgive();
|
||||||
|
|
||||||
errout_with_inode:
|
errout_with_inode:
|
||||||
inode_release(inode);
|
inode_release(inode);
|
||||||
|
|
||||||
|
@ -109,22 +109,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define FSNODEFLAG_TYPE_MASK 0x0000000f /* Isolates type field */
|
#define FSNODEFLAG_TYPE_MASK 0x0000000f /* Isolates type field */
|
||||||
#define FSNODEFLAG_TYPE_DRIVER 0x00000000 /* Character driver */
|
#define FSNODEFLAG_TYPE_PSEUDODIR 0x00000000 /* Pseudo dir (default) */
|
||||||
#define FSNODEFLAG_TYPE_BLOCK 0x00000001 /* Block driver */
|
#define FSNODEFLAG_TYPE_DRIVER 0x00000001 /* Character driver */
|
||||||
#define FSNODEFLAG_TYPE_MOUNTPT 0x00000002 /* Mount point */
|
#define FSNODEFLAG_TYPE_BLOCK 0x00000002 /* Block driver */
|
||||||
#define FSNODEFLAG_TYPE_SPECIAL 0x00000008 /* Special OS type */
|
#define FSNODEFLAG_TYPE_MOUNTPT 0x00000003 /* Mount point */
|
||||||
#define FSNODEFLAG_TYPE_NAMEDSEM 0x00000008 /* Named semaphore */
|
#define FSNODEFLAG_TYPE_NAMEDSEM 0x00000004 /* Named semaphore */
|
||||||
#define FSNODEFLAG_TYPE_MQUEUE 0x00000009 /* Message Queue */
|
#define FSNODEFLAG_TYPE_MQUEUE 0x00000005 /* Message Queue */
|
||||||
#define FSNODEFLAG_TYPE_SHM 0x0000000a /* Shared memory region */
|
#define FSNODEFLAG_TYPE_SHM 0x00000006 /* Shared memory region */
|
||||||
#define FSNODEFLAG_TYPE_MTD 0x0000000b /* Named MTD driver */
|
#define FSNODEFLAG_TYPE_MTD 0x00000007 /* Named MTD driver */
|
||||||
#define FSNODEFLAG_TYPE_SOFTLINK 0x0000000c /* Soft link */
|
#define FSNODEFLAG_TYPE_SOFTLINK 0x00000008 /* Soft link */
|
||||||
#define FSNODEFLAG_DELETED 0x00000010 /* Unlinked */
|
#define FSNODEFLAG_DELETED 0x00000010 /* Unlinked */
|
||||||
|
|
||||||
#define INODE_IS_TYPE(i,t) \
|
#define INODE_IS_TYPE(i,t) \
|
||||||
(((i)->i_flags & FSNODEFLAG_TYPE_MASK) == (t))
|
(((i)->i_flags & FSNODEFLAG_TYPE_MASK) == (t))
|
||||||
#define INODE_IS_SPECIAL(i) \
|
|
||||||
(((i)->i_flags & FSNODEFLAG_TYPE_SPECIAL) != 0)
|
|
||||||
|
|
||||||
|
#define INODE_IS_PSEUDODIR(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_PSEUDODIR)
|
||||||
#define INODE_IS_DRIVER(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_DRIVER)
|
#define INODE_IS_DRIVER(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_DRIVER)
|
||||||
#define INODE_IS_BLOCK(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_BLOCK)
|
#define INODE_IS_BLOCK(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_BLOCK)
|
||||||
#define INODE_IS_MOUNTPT(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_MOUNTPT)
|
#define INODE_IS_MOUNTPT(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_MOUNTPT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user