Skip to content

Commit cd3f0f9

Browse files
authored
Add color ls for executable file. (#7654)
1 parent 0cb2a5e commit cd3f0f9

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ static int _free_subdir(struct tmpfs_file *dfile)
111111
return 0;
112112
}
113113

114-
static int dfs_tmpfs_mount(struct dfs_mnt *mnt,
115-
unsigned long rwflag,
116-
const void *data)
114+
static int dfs_tmpfs_mount(struct dfs_mnt *mnt,
115+
unsigned long rwflag,
116+
const void *data)
117117
{
118118
struct tmpfs_sb *superblock;
119119

@@ -295,7 +295,6 @@ static int dfs_tmpfs_read(struct dfs_file *file, void *buf, size_t count, off_t
295295
return length;
296296
}
297297

298-
299298
static int dfs_tmpfs_write(struct dfs_file *file, const void *buf, size_t count, off_t *pos)
300299
{
301300
struct tmpfs_file *d_file;
@@ -347,13 +346,13 @@ static int dfs_tmpfs_lseek(struct dfs_file *file, off_t offset, int wherece)
347346
return -EIO;
348347
}
349348

350-
int dfs_tmpfs_close(struct dfs_file *file)
349+
static int dfs_tmpfs_close(struct dfs_file *file)
351350
{
352351
RT_ASSERT(file->vnode->ref_count > 0);
353352
return RT_EOK;
354353
}
355354

356-
int dfs_tmpfs_open(struct dfs_file *file)
355+
static int dfs_tmpfs_open(struct dfs_file *file)
357356
{
358357
struct tmpfs_file *d_file;
359358

@@ -416,7 +415,7 @@ static int dfs_tmpfs_stat(struct dfs_dentry *dentry, struct stat *st)
416415
return RT_EOK;
417416
}
418417

419-
int dfs_tmpfs_getdents(struct dfs_file *file,
418+
static int dfs_tmpfs_getdents(struct dfs_file *file,
420419
struct dirent *dirp,
421420
uint32_t count)
422421
{
@@ -471,7 +470,7 @@ int dfs_tmpfs_getdents(struct dfs_file *file,
471470
return count * sizeof(struct dirent);
472471
}
473472

474-
int dfs_tmpfs_unlink(struct dfs_dentry *dentry)
473+
static int dfs_tmpfs_unlink(struct dfs_dentry *dentry)
475474
{
476475
rt_size_t size;
477476
struct tmpfs_sb *superblock;
@@ -497,7 +496,7 @@ int dfs_tmpfs_unlink(struct dfs_dentry *dentry)
497496
return RT_EOK;
498497
}
499498

500-
int dfs_tmpfs_rename(struct dfs_dentry *old_dentry, struct dfs_dentry *new_dentry)
499+
static int dfs_tmpfs_rename(struct dfs_dentry *old_dentry, struct dfs_dentry *new_dentry)
501500
{
502501
struct tmpfs_file *d_file, *p_file;
503502
struct tmpfs_sb *superblock;
@@ -538,7 +537,6 @@ int dfs_tmpfs_rename(struct dfs_dentry *old_dentry, struct dfs_dentry *new_dentr
538537
return RT_EOK;
539538
}
540539

541-
542540
static struct dfs_vnode *_dfs_tmpfs_lookup(struct dfs_dentry *dentry)
543541
{
544542
struct dfs_vnode *vnode = RT_NULL;

components/dfs/dfs_v2/src/dfs_file.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,11 @@ void ls(const char *pathname)
16681668
rt_kprintf(_COLOR_RED "-> link_error\n" _COLOR_NORMAL);
16691669
}
16701670
}
1671+
else if (stat.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
1672+
{
1673+
rt_kprintf(_COLOR_GREEN "%-20s" _COLOR_NORMAL, dirent.d_name);
1674+
rt_kprintf("%-25lu\n", (unsigned long)stat.st_size);
1675+
}
16711676
else
16721677
{
16731678
rt_kprintf("%-20s", dirent.d_name);
@@ -1676,7 +1681,7 @@ void ls(const char *pathname)
16761681
}
16771682
else
16781683
{
1679-
rt_kprintf("BAD file: %s\n", dirent.d_name);
1684+
rt_kprintf(_COLOR_RED "%-20s" _COLOR_NORMAL, dirent.d_name);
16801685
}
16811686

16821687
rt_free(fullpath);

0 commit comments

Comments
 (0)