From 7771204cf7bc161822eb636ff6fb30a1579b622d Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 6 Jun 2019 15:29:29 -0700 Subject: Implement stat %C and find %Z. We'd documented find %Z but not implemented it. We'd neither documented nor implemented stat's corresponding %C (they'd already taken %Z for ctime, which is ironic because %c/%C sounds more obvious than %z/%Z for that to me). --- toys/posix/find.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'toys/posix/find.c') diff --git a/toys/posix/find.c b/toys/posix/find.c index 3f24c0dc..fe712c88 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -53,7 +53,7 @@ config FIND or "+" (next argument after "{}") to collect and run with multiple files. -printf FORMAT characters are \ escapes and: - %b 512 byte blocks used + %b 512 byte blocks used %f basename %g textual gid %G numeric gid %i decimal inode %l target of symlink %m octal mode %M ls format type/mode %p path to file %P path to file minus DIR @@ -600,6 +600,11 @@ static int do_find(struct dirtree *new) sprintf(buf, "%ld.%ld", new->st.st_mtim.tv_sec, new->st.st_mtim.tv_nsec); ll = (long)buf; + } else if (ch == 'Z') { + char *path = dirtree_path(new, 0); + + ll = (lsm_get_context(path, &ff) != -1) ? (long)ff : (long)"?"; + free(path); } else error_exit("bad -printf %%%c", ch); printf(next, ll); -- cgit v1.2.3