This is an automated email from the ASF dual-hosted git repository. ligd pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 0ab637f57e58bd0e3c62ea9b69af330e69c63327 Author: zhouliang3 <[email protected]> AuthorDate: Thu Sep 2 12:41:08 2021 +0800 fs/littlefs: Add attr to dirA Signed-off-by: zhouliang3 <[email protected]> --- fs/littlefs/lfs_vfs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/littlefs/lfs_vfs.c b/fs/littlefs/lfs_vfs.c index 5c7c7b8592..dfaf17440a 100644 --- a/fs/littlefs/lfs_vfs.c +++ b/fs/littlefs/lfs_vfs.c @@ -1444,6 +1444,25 @@ static int littlefs_mkdir(FAR struct inode *mountpt, FAR const char *relpath, } ret = lfs_mkdir(&fs->lfs, relpath); + if (ret >= 0) + { + struct littlefs_attr_s attr; + struct timespec time; + + clock_gettime(CLOCK_REALTIME, &time); + memset(&attr, 0, sizeof(attr)); + attr.at_mode = mode; + attr.at_ctim = 1000000000ull * time.tv_sec + time.tv_nsec; + attr.at_atim = attr.at_ctim; + attr.at_mtim = attr.at_ctim; + ret = littlefs_convert_result(lfs_setattr(&fs->lfs, relpath, 0, + &attr, sizeof(attr))); + if (ret < 0) + { + lfs_remove(&fs->lfs, relpath); + } + } + nxmutex_unlock(&fs->lock); return ret; @@ -1556,6 +1575,7 @@ static int littlefs_stat(FAR struct inode *mountpt, FAR const char *relpath, ret = 0; memset(&attr, 0, sizeof(attr)); + attr.at_mode = S_IRWXG | S_IRWXU | S_IRWXO; } buf->st_mode = attr.at_mode;
