9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 6b834aee719d8e6a6db38710ebac7df47d208de5
parent 2a246405c053e425bd04ea2945bc5d2e642294c8
Author: Ambroise Vincent <ambroise.vincent@arm.com>
Date:   Thu,  9 May 2019 14:34:20 +0100

[rom] Add stat function to shell

Change-Id: I1ce0765682452bc5e655ddc9036db084f64dee18
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>

Diffstat:
Msrc/romfw/dlang.c | 36++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/romfw/dlang.c b/src/romfw/dlang.c @@ -285,6 +285,35 @@ err: return 0; } +static int +do_stat(const struct cmd *cmd, struct args *args) +{ + Dir dir; + + if (dirstat(args->argv[1], &dir) < 0) + goto err; + kprint(kout, + "name: %s\n" + "length: %ld\n" + "mode: %x\n" + "type: %d\n" + "dev: %d\n" + "qid: %x\n", + dir.name, + dir.length, + dir.mode, + dir.type, + dir.dev, + dir.qid + ); + + return 0; + +err: + kerror(PREFIX "ERR stat"); + return 0; +} + static const struct cmd * parse_cmd(char *buf, struct args *args) { @@ -439,6 +468,13 @@ static const struct cmd cmds[] = { .helpmsg = "write content to a file: echo path string ...", }, { + .name = "stat", + .eval = do_stat, + .min = 2, + .max = 2, + .helpmsg = "display stat attribute: stat path", + }, + { .name = NULL } };