aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/ls.c
diff options
context:
space:
mode:
authorPeter Collingbourne <pcc@google.com>2019-01-08 15:22:50 -0800
committerRob Landley <rob@landley.net>2019-01-08 19:21:17 -0600
commit93e1b9ecb17481a15f4681d07125892c16eeb10b (patch)
tree6dedd2435fd1295f52cea33d6ec92f8b19030694 /toys/posix/ls.c
parentae04b513b269db6300bce71eb303d23ab162b2da (diff)
downloadtoybox-93e1b9ecb17481a15f4681d07125892c16eeb10b.tar.gz
ls: Fix -t to also sort by st_mtim.tv_nsec.
Diffstat (limited to 'toys/posix/ls.c')
-rw-r--r--toys/posix/ls.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 976b3343..d24168d6 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -169,6 +169,8 @@ static int compare(void *a, void *b)
if (toys.optflags & FLAG_t) {
if (dta->st.st_mtime > dtb->st.st_mtime) ret = -1;
else if (dta->st.st_mtime < dtb->st.st_mtime) ret = 1;
+ else if (dta->st.st_mtim.tv_nsec > dtb->st.st_mtim.tv_nsec) ret = -1;
+ else if (dta->st.st_mtim.tv_nsec < dtb->st.st_mtim.tv_nsec) ret = 1;
}
if (!ret) ret = strcmp(dta->name, dtb->name);
return ret * reverse;