mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 10:53:16 +01:00
fd wasn't returned in reorganised sys_open. Fixed.
This commit is contained in:
@@ -93,7 +93,7 @@ void handle_fs_requests(void)
|
||||
(unsigned long)mr[2], (void *)mr[3]);
|
||||
break;
|
||||
default:
|
||||
printf("%s: Unrecognised ipc tag (%d)"
|
||||
printf("%s: Unrecognised ipc tag (%d) "
|
||||
"received. Ignoring.\n", __TASKNAME__, mr[MR_TAG]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ int sys_open(l4id_t sender, const char *pathname, int flags, unsigned int mode)
|
||||
|
||||
/* Get a new fd */
|
||||
BUG_ON((fd = id_new(task->fdpool)) < 0);
|
||||
retval = fd;
|
||||
|
||||
/* Assign the new fd with the vnode's number */
|
||||
task->fd[fd] = v->vnum;
|
||||
@@ -339,6 +340,11 @@ int sys_readdir(l4id_t sender, int fd, void *buf, int count)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fd < 0 || fd > TASK_OFILES_MAX) {
|
||||
l4_ipc_return(-EBADF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Convert fd to vnum. */
|
||||
BUG_ON((vnum = t->fd[fd]) < 0);
|
||||
|
||||
|
||||
@@ -111,14 +111,14 @@ int lsdir(char *path)
|
||||
memset(dents, 0, sizeof(struct dirent) * DENTS_TOTAL);
|
||||
|
||||
if ((fd = open(path, O_RDONLY)) < 0) {
|
||||
printf("OPEN failed.");
|
||||
return 0;
|
||||
printf("OPEN failed.\n");
|
||||
return -1;
|
||||
} else
|
||||
printf("Got fd: %d for opening %s\n", fd, path);
|
||||
|
||||
if ((bytes = os_readdir(fd, dents, sizeof(struct dirent) * DENTS_TOTAL)) < 0) {
|
||||
perror("GETDENTS\n");
|
||||
return 0;
|
||||
printf("GETDENTS error: %d\n", bytes);
|
||||
return -1;
|
||||
} else {
|
||||
print_dirents(path, dents, bytes);
|
||||
}
|
||||
@@ -130,9 +130,15 @@ int lsdir(char *path)
|
||||
int dirtest(void)
|
||||
{
|
||||
printf("\nlsdir current directory:\n");
|
||||
lsdir(".");
|
||||
if (lsdir(".") < 0) {
|
||||
printf("lsdir failed.\n");
|
||||
goto out_err;
|
||||
}
|
||||
printf("\nlsdir root directory:\n");
|
||||
lsdir("/");
|
||||
if (lsdir("/") < 0) {
|
||||
printf("lsdir failed.\n");
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
printf("\nCreating directories: usr, etc, tmp, var, home, opt, bin, boot, lib, dev\n");
|
||||
if (mkdir("/usr", 0) < 0)
|
||||
@@ -173,5 +179,8 @@ int dirtest(void)
|
||||
printf("\nlsdir /usr/./././bin//\n");
|
||||
lsdir("/usr/./././bin//");
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user