Skip to content

Comments

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.

@simbit18
Copy link
Contributor

@Biancaa-R @cederom, this is the error `flash' overflowed by 4 bytes

====================================================================================
Configuration/Tool: weact-stm32h750/nsh,CONFIG_ARM_TOOLCHAIN_CLANG
2026-02-19 20:01:01
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_CLANG
  Building NuttX...
arm-none-eabi-ld: /github/workspace/sources/nuttx/nuttx section `.data' will not fit in region `flash'
arm-none-eabi-ld: region `flash' overflowed by 4 bytes
make[1]: *** [Makefile:217: nuttx] Error 1
make: *** [tools/Unix.mk:552: nuttx] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize weact-stm32h750/nsh
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	boards/arm/stm32h7/weact-stm32h750/scripts/flash.ld.tmp

nothing added to commit but untracked files present (use "git add" to track)
====================================================================================

@Biancaa-R
Copy link
Author

@Biancaa-R @cederom, this is the error `flash' overflowed by 4 bytes

====================================================================================
Configuration/Tool: weact-stm32h750/nsh,CONFIG_ARM_TOOLCHAIN_CLANG
2026-02-19 20:01:01
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_CLANG
  Building NuttX...
arm-none-eabi-ld: /github/workspace/sources/nuttx/nuttx section `.data' will not fit in region `flash'
arm-none-eabi-ld: region `flash' overflowed by 4 bytes
make[1]: *** [Makefile:217: nuttx] Error 1
make: *** [tools/Unix.mk:552: nuttx] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize weact-stm32h750/nsh
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	boards/arm/stm32h7/weact-stm32h750/scripts/flash.ld.tmp

nothing added to commit but untracked files present (use "git add" to track)
====================================================================================

is // Instead of: " %04d-%02d-%02d %02d:%02d"
nsh_output(vtbl, " %d-%d-%d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
better ? @simbit18 ? I think that is causing the overflow..

@cederom
Copy link
Contributor

cederom commented Feb 21, 2026

this looks ai generated without understanding. do we have more time to play?

@Biancaa-R
Copy link
Author

this looks ai generated without understanding. do we have more time to play?

Im sorry Ill check the dump and come back..

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.

4 participants