fd wasn't returned in reorganised sys_open. Fixed.

This commit is contained in:
Bahadir Balban
2008-04-19 00:55:11 +01:00
parent 8c4c436925
commit ce26835968
3 changed files with 22 additions and 7 deletions

View File

@@ -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;
}