From 8212fc144ffec44b5a5e2d321a52b608ad1ff176 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 3 Feb 2017 07:42:19 -0600 Subject: [PATCH] Cosmetic changes, mostly to comments. --- fs/inode/fs_inodefind.c | 5 +++-- fs/vfs/fs_rmdir.c | 5 +++-- fs/vfs/fs_unlink.c | 4 ++-- include/nuttx/fs/fs.h | 11 ++++++++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/fs/inode/fs_inodefind.c b/fs/inode/fs_inodefind.c index 3ff249d348d..37ca35bf900 100644 --- a/fs/inode/fs_inodefind.c +++ b/fs/inode/fs_inodefind.c @@ -61,7 +61,7 @@ FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath) { FAR struct inode *node; - if (path == NULL || path[0] == '\0' || path[0] != '/') + if (path == NULL || *path != '/') { return NULL; } @@ -71,7 +71,8 @@ FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath) */ inode_semtake(); - node = inode_search(&path, (FAR struct inode**)NULL, (FAR struct inode**)NULL, relpath); + node = inode_search(&path, (FAR struct inode**)NULL, + (FAR struct inode**)NULL, relpath); if (node) { node->i_crefs++; diff --git a/fs/vfs/fs_rmdir.c b/fs/vfs/fs_rmdir.c index ecef33558e3..d3e15bce139 100644 --- a/fs/vfs/fs_rmdir.c +++ b/fs/vfs/fs_rmdir.c @@ -84,8 +84,9 @@ int rmdir(FAR const char *pathname) const char *relpath = NULL; int errcode; - /* Get an inode for this file. inode_find() automatically increments the - * reference count on the inode if one is found. + /* Get an inode for the directory (or for the mountpoint containing the + * directory). inode_find() automatically increments the reference count + * on the inode if one is found. */ inode = inode_find(pathname, &relpath); diff --git a/fs/vfs/fs_unlink.c b/fs/vfs/fs_unlink.c index 9de8ea2f2f7..2cc6c23a7d7 100644 --- a/fs/vfs/fs_unlink.c +++ b/fs/vfs/fs_unlink.c @@ -131,10 +131,10 @@ int unlink(FAR const char *pathname) if (!INODE_IS_SPECIAL(inode) && inode->u.i_ops) { /* If this is a pseudo-file node (i.e., it has no operations) - * then rmdir should remove the node. + * then unlink should remove the node. */ - if (inode->u.i_ops) + if (inode->u.i_ops != NULL) { inode_semtake(); diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index 238a6b8ef96..cc01a643507 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/fs/fs.h * - * Copyright (C) 2007-2009, 2011-2013, 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013, 2015-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -66,7 +66,11 @@ #define __FS_FLAG_EOF (1 << 0) /* EOF detected by a read operation */ #define __FS_FLAG_ERROR (1 << 1) /* Error detected by any operation */ -/* Inode i_flag values */ +/* Inode i_flag values: + * + * Bit 0-3: Inode type (Bit 4 indicates internal OS types) + * Bit 4: Set if inode has been unlinked and is pending removal. + */ #define FSNODEFLAG_TYPE_MASK 0x00000007 /* Isolates type field */ #define FSNODEFLAG_TYPE_DRIVER 0x00000000 /* Character driver */ @@ -118,7 +122,7 @@ * descriptor instead. * * This case is when SUSv1 pseudo-terminals are used (CONFIG_PSEUDOTERM_SUSV1=y). - * In this case, the output is encoded and decoded using these macros in + * In this case, the output is encoded and decoded using these macros in * order to support (a) returning file descriptor 0 (which really should * not happen), and (b) avoiding confusion if some other open method returns * a positive, non-zero value which is not a file descriptor. @@ -337,6 +341,7 @@ struct inode FAR void *i_private; /* Per inode driver private data */ char i_name[1]; /* Name of inode (variable) */ }; + #define FSNODE_SIZE(n) (sizeof(struct inode) + (n)) /* This is the underlying representation of an open file. A file