Skip to content

Added changes for ls-l time support#3406

Open
Biancaa-R wants to merge 1 commit intoapache:masterfrom
Biancaa-R:feature-ls-timestamp
Open

Added changes for ls-l time support#3406
Biancaa-R wants to merge 1 commit intoapache:masterfrom
Biancaa-R:feature-ls-timestamp

Conversation

@Biancaa-R
Copy link

Fixes the issue : apache/nuttx#17063

image

a) modification aims to add human-readable timestamp reporting to the ls command by utilizing the struct stat information.
b) time_t st_mtime; / Time of last modification / from stat register to maintain time records.
c) Epoch entries replaced by ---.
d) ls -l (without options) implementation done here.

Note: Please adhere to Contributing Guidelines.

Summary

  • So basically displaying the last modified time that is stored in the stat struct in ls -l command.
  • stat(fullpath, &buf): This fills the buf structure with metadata from the filesystem.
  • buf.st_mtime: This specifically targets the "Last Modified" timestamp.
  • Safety Check: if (ret == 0 && buf.st_mtime > 0 ...) ensures that the stat call was successful and that the time value is valid before trying to process it.
  • localtime_r(&t, &tm): This takes the Unix epoch time (seconds since 1970) and breaks it down into a struct tm (years, months, days, etc.).
  • Formatting: %04d-%02d-%02d, which outputs the ISO 8601 standard (e.g., 2023-10-27).

Impact

Previously the ls -l didnt display the time of last modification , this is a small fix for more "linux like" experience.

Testing

  • Apache NuttX Simulation Mode allows you to run the OS as a native Linux process.
  • Building and running it and executing the ls -l command in the shell.

a) modification aims to add human-readable timestamp reporting to the ls command by utilizing the struct stat information.
b) time_t st_mtime; / Time of last modification / from stat register to
maintain time records.
c) Epoch entries replaced by ---.
d) ls -l (without options) implementation done here.

Signed-off-by: Biancaa Ramesh <biancaa2210329@ssn.edu.in>
@cederom
Copy link
Contributor

cederom commented Feb 19, 2026

Thank you @Biancaa-R :-) Can you please provide output of ls -l command from Linux/Unix shell and ls -l from nsh after your change? Are these outputs comparable for parse (i.e. information order) :-)

@linguini1
Copy link
Contributor

Hi! To fix the CI errors, please run ./tools/checkpatch.sh on your changes and fix the issues.

Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI build failed.

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

Comments