summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2023-06-11 13:12:40 +0800
committerGitHub <[email protected]>2023-06-11 13:12:40 +0800
commitcd3f0f9c8a2df258fbd3cc6ba6dca17f44c91fd9 (patch)
treea3e12c25ebc7abd062d0c32748e87c09267471a0
parent0cb2a5e735dd5c671985bf69720ccc60cc1d0390 (diff)
Add color ls for executable file. (#7654)
-rw-r--r--components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c18
-rw-r--r--components/dfs/dfs_v2/src/dfs_file.c7
2 files changed, 14 insertions, 11 deletions
diff --git a/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c b/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c
index 512c2ecdf2..32ddad821c 100644
--- a/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c
+++ b/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c
@@ -111,9 +111,9 @@ static int _free_subdir(struct tmpfs_file *dfile)
return 0;
}
-static int dfs_tmpfs_mount(struct dfs_mnt *mnt,
- unsigned long rwflag,
- const void *data)
+static int dfs_tmpfs_mount(struct dfs_mnt *mnt,
+ unsigned long rwflag,
+ const void *data)
{
struct tmpfs_sb *superblock;
@@ -295,7 +295,6 @@ static int dfs_tmpfs_read(struct dfs_file *file, void *buf, size_t count, off_t
return length;
}
-
static int dfs_tmpfs_write(struct dfs_file *file, const void *buf, size_t count, off_t *pos)
{
struct tmpfs_file *d_file;
@@ -347,13 +346,13 @@ static int dfs_tmpfs_lseek(struct dfs_file *file, off_t offset, int wherece)
return -EIO;
}
-int dfs_tmpfs_close(struct dfs_file *file)
+static int dfs_tmpfs_close(struct dfs_file *file)
{
RT_ASSERT(file->vnode->ref_count > 0);
return RT_EOK;
}
-int dfs_tmpfs_open(struct dfs_file *file)
+static int dfs_tmpfs_open(struct dfs_file *file)
{
struct tmpfs_file *d_file;
@@ -416,7 +415,7 @@ static int dfs_tmpfs_stat(struct dfs_dentry *dentry, struct stat *st)
return RT_EOK;
}
-int dfs_tmpfs_getdents(struct dfs_file *file,
+static int dfs_tmpfs_getdents(struct dfs_file *file,
struct dirent *dirp,
uint32_t count)
{
@@ -471,7 +470,7 @@ int dfs_tmpfs_getdents(struct dfs_file *file,
return count * sizeof(struct dirent);
}
-int dfs_tmpfs_unlink(struct dfs_dentry *dentry)
+static int dfs_tmpfs_unlink(struct dfs_dentry *dentry)
{
rt_size_t size;
struct tmpfs_sb *superblock;
@@ -497,7 +496,7 @@ int dfs_tmpfs_unlink(struct dfs_dentry *dentry)
return RT_EOK;
}
-int dfs_tmpfs_rename(struct dfs_dentry *old_dentry, struct dfs_dentry *new_dentry)
+static int dfs_tmpfs_rename(struct dfs_dentry *old_dentry, struct dfs_dentry *new_dentry)
{
struct tmpfs_file *d_file, *p_file;
struct tmpfs_sb *superblock;
@@ -538,7 +537,6 @@ int dfs_tmpfs_rename(struct dfs_dentry *old_dentry, struct dfs_dentry *new_dentr
return RT_EOK;
}
-
static struct dfs_vnode *_dfs_tmpfs_lookup(struct dfs_dentry *dentry)
{
struct dfs_vnode *vnode = RT_NULL;
diff --git a/components/dfs/dfs_v2/src/dfs_file.c b/components/dfs/dfs_v2/src/dfs_file.c
index ca917ba9b7..0bc08bf562 100644
--- a/components/dfs/dfs_v2/src/dfs_file.c
+++ b/components/dfs/dfs_v2/src/dfs_file.c
@@ -1668,6 +1668,11 @@ void ls(const char *pathname)
rt_kprintf(_COLOR_RED "-> link_error\n" _COLOR_NORMAL);
}
}
+ else if (stat.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
+ {
+ rt_kprintf(_COLOR_GREEN "%-20s" _COLOR_NORMAL, dirent.d_name);
+ rt_kprintf("%-25lu\n", (unsigned long)stat.st_size);
+ }
else
{
rt_kprintf("%-20s", dirent.d_name);
@@ -1676,7 +1681,7 @@ void ls(const char *pathname)
}
else
{
- rt_kprintf("BAD file: %s\n", dirent.d_name);
+ rt_kprintf(_COLOR_RED "%-20s" _COLOR_NORMAL, dirent.d_name);
}
rt_free(fullpath);