cmd: ls: print file name when file is not dir
This commit is contained in:
parent
0f5da3c539
commit
42acd462b3
1 changed files with 8 additions and 2 deletions
10
init/cmd.c
10
init/cmd.c
|
|
@ -129,12 +129,18 @@ int kcmd_ls(int argc, char **argv)
|
|||
else
|
||||
path = argv[1];
|
||||
|
||||
struct file *dir = vfs_open(path, NULL);
|
||||
int err;
|
||||
struct file *dir = vfs_open(path, &err);
|
||||
if (!dir) {
|
||||
kprintf("Failed to open directory %s\n", path);
|
||||
kprintf("Failed to open %s: %s\n", path, strerror(-err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(dir->vnode->flags & VFS_VNO_DIR)) {
|
||||
kprintf("%s\n", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct dirent *ent;
|
||||
for (size_t i = 0; i < dir->vnode->num_dirents; i++) {
|
||||
ent = &dir->vnode->dirents[i];
|
||||
|
|
|
|||
Loading…
Reference in a new issue