Added a new write_stat() call to the file descriptor operations (plus syscall).

Renamed sys_read_stat() to sys_read_path_stat() - sys_read_stat() is now
the fd operation (same for the corresponding write call).
Removed the sys_write_attr_stat() call because it is no longer needed.
Added stat(), fstat(), and other POSIX calls to the kernel - many are still
missing (mainly from stdio).
Added symbols (but no implementation) for unistd.h's process id functions.
Adapted libroot calls that used sys_read_stat() before to the new architecture.
module.c and bus_man.c now use stat() directly instead of the sys_read_path_stat()
call.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1555 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2002-10-17 03:09:25 +00:00
parent 8e5ca65bc9
commit f4e51a2dfb
17 changed files with 315 additions and 197 deletions
+19 -10
View File
@@ -26,7 +26,8 @@ static bus *bus_list;
static mutex bus_lock;
int bus_man_init(kernel_args *ka)
int
bus_man_init(kernel_args *ka)
{
mutex_init(&bus_lock, "bus_lock");
@@ -35,7 +36,9 @@ int bus_man_init(kernel_args *ka)
return 0;
}
static bus *find_bus(const char *path)
static bus *
find_bus(const char *path)
{
bus *b;
@@ -46,7 +49,9 @@ static bus *find_bus(const char *path)
return b;
}
int bus_register_bus(const char *path)
int
bus_register_bus(const char *path)
{
bus *b;
int err = 0;
@@ -74,6 +79,7 @@ int bus_register_bus(const char *path)
bus_list = b;
} else {
err = ENODEV;
goto err;
}
err = 0;
@@ -82,16 +88,18 @@ err:
return err;
}
static int bus_find_device_recurse(int *n, char *base_path, int max_path_len, int base_fd, id_list *vendor_ids, id_list *device_ids)
static int
bus_find_device_recurse(int *n, char *base_path, int max_path_len, int base_fd, id_list *vendor_ids, id_list *device_ids)
{
char buffer[sizeof(struct dirent) + SYS_MAX_NAME_LEN + 1];
struct dirent *dirent = (struct dirent *)buffer;
int base_path_len = strlen(base_path);
ssize_t len;
int err;
struct stat stat;
while ((len = sys_read_dir(base_fd, dirent, sizeof(buffer), 1)) > 0) {
struct stat st;
int fd;
// reset the base_path to the original string passed in
@@ -99,11 +107,11 @@ static int bus_find_device_recurse(int *n, char *base_path, int max_path_len, in
dirent->d_name[dirent->d_reclen] = '\0';
strlcat(base_path, dirent->d_name, max_path_len);
err = sys_read_stat(base_path, true, &stat);
err = stat(base_path, &st);
if (err < 0)
continue;
if (S_ISDIR(stat.st_mode)) {
if (S_ISDIR(st.st_mode)) {
fd = sys_open_dir(base_path);
if (fd < 0)
continue;
@@ -114,7 +122,7 @@ static int bus_find_device_recurse(int *n, char *base_path, int max_path_len, in
if (err >= 0)
return err;
continue;
} else if (S_ISREG(stat.st_mode)) {
} else if (S_ISREG(st.st_mode)) {
// we opened the device
// XXX assumes PCI
struct pci_cfg cfg;
@@ -146,7 +154,9 @@ static int bus_find_device_recurse(int *n, char *base_path, int max_path_len, in
return ENODEV;
}
int bus_find_device(int n, id_list *vendor_ids, id_list *device_ids, device *dev)
int
bus_find_device(int n, id_list *vendor_ids, id_list *device_ids, device *dev)
{
int base_fd;
int fd;
@@ -189,4 +199,3 @@ int bus_find_device(int n, id_list *vendor_ids, id_list *device_ids, device *dev
return err;
}