Skip to content

nshlib/nsh_fscmds: Display modification time in ls -l output#3571

Merged
acassis merged 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/ls-long-timestamp
Jun 30, 2026
Merged

nshlib/nsh_fscmds: Display modification time in ls -l output#3571
acassis merged 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/ls-long-timestamp

Conversation

@Zepp-Hanzj

Copy link
Copy Markdown
Contributor

Summary

Add modification time display to ls -l long format output.

Fixes #17063

Details

The ls -l command now shows the modification time (st_mtime) in
YYYY-MM-DD HH:MM format (ISO long-iso style) between the permission
string and the file size.

Files with st_mtime == 0 (e.g., procfs, tmpfs pseudo-entries) skip
the timestamp display to avoid showing a meaningless epoch time.

Changes

  • nshlib/nsh_fscmds.c: Add #include <time.h> and timestamp display
    logic in ls_handler() after the permission details output.

Verification

Built and tested on sim:nsh configuration.

ls -l /:

 dr-xr-xr-x           0 bin/
 drwxr-xr-x 2026-06-29 11:21        4096 data/
 drwxrwxrwx           0 dev/
 dr-xr-xr-x           0 etc/

ls -l /data:

 -rw-r--r-- 2026-06-29 11:20         152 .version
 -rw-r--r-- 2026-06-29 11:20        1883 .config.backup
 drwxr-xr-x 2026-06-29 11:21        4096 binfmt/
 -rw-r--r-- 2026-06-01 08:56        3107 NOTICE
 -rw-r--r-- 2026-06-05 15:33           6 hello.txt

ls -l /proc (procfs, st_mtime == 0, timestamp correctly skipped):

 dr--r--r--           0 0/
 dr--r--r--           0 1/
 -r--r--r--           0 cpuinfo

ls -l /dev (pseudo-devices, st_mtime set to boot time):

 crw-rw-rw- 2026-06-29 11:21           0 console
 crw-rw-rw-           0 rtc0

rtc0 has st_mtime == 0 so the timestamp is correctly omitted.

Signed-off-by: hanzhijian hanzhijian@zepp.com

Comment thread nshlib/nsh_fscmds.c Outdated
Comment thread nshlib/nsh_fscmds.c
acassis
acassis previously approved these changes Jun 29, 2026
Fixes #17063

Add modification time display to ls -l long format output.
The timestamp is shown as 'YYYY-MM-DD HH:MM' between the permission
string and the file size, following the ISO long-iso format.

Files with st_mtime == 0 (e.g., procfs, tmpfs pseudo-entries) skip
the timestamp display to avoid showing a meaningless epoch time.

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
@acassis

acassis commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@jerpelea please add to V13 RC1

@acassis acassis merged commit f57aa7b into apache:master Jun 30, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants