Add color ls for executable file. (#7654)

This commit is contained in:
Bernard Xiong 2023-06-11 13:12:40 +08:00 committed by GitHub
parent 0cb2a5e735
commit cd3f0f9c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -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;

View File

@ -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);