From f9bdcca59cbf81bf938cf10a6a1d5b6f050d6eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 18 Jan 2003 14:04:22 +0000 Subject: [PATCH] Added kernel private node_monitor.h header. Moved definition of "struct io_context" from fd.h to vfs.h. Introduced new fs/ directory; some cleanups to come. Added node monitor syscalls. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2479 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/fd.h | 15 +------------- headers/private/kernel/fs/node_monitor.h | 25 ++++++++++++++++++++++++ headers/private/kernel/ksyscalls.h | 3 +++ headers/private/kernel/syscalls.h | 7 +++++++ headers/private/kernel/vfs.h | 24 +++++++++++++++++++++-- 5 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 headers/private/kernel/fs/node_monitor.h diff --git a/headers/private/kernel/fd.h b/headers/private/kernel/fd.h index f0a47295f6..3a38fffde4 100644 --- a/headers/private/kernel/fd.h +++ b/headers/private/kernel/fd.h @@ -10,22 +10,9 @@ #include #include #include +//#include -struct file_descriptor; -struct select_sync; -struct fs_mount; -struct vnode; - -/** The I/O context of a process/team, holds the fd array */ -struct io_context { - struct vnode *cwd; - mutex io_mutex; - int table_size; - int num_used_fds; - struct file_descriptor **fds; -}; - struct fd_ops { ssize_t (*fd_read) (struct file_descriptor *, off_t pos, void *buffer, size_t *length); ssize_t (*fd_write)(struct file_descriptor *, off_t pos, const void *buffer, size_t *length); diff --git a/headers/private/kernel/fs/node_monitor.h b/headers/private/kernel/fs/node_monitor.h new file mode 100644 index 0000000000..ea14307db0 --- /dev/null +++ b/headers/private/kernel/fs/node_monitor.h @@ -0,0 +1,25 @@ +#ifndef _KERNEL_NODE_MONITOR_H +#define _KERNEL_NODE_MONITOR_H +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + + +#include + + +struct io_context; + +// private kernel API +extern status_t remove_node_monitors(struct io_context *context); +extern status_t node_monitor_init(void); + +// user-space exported calls +extern status_t user_stop_notifying(port_id port, uint32 token); +extern status_t user_start_watching(dev_t device, ino_t node, uint32 flags, + port_id port, uint32 token); +extern status_t user_stop_watching(dev_t device, ino_t node, uint32 flags, + port_id port, uint32 token); + +#endif /* _KRENEL_NODE_MONITOR_H */ diff --git a/headers/private/kernel/ksyscalls.h b/headers/private/kernel/ksyscalls.h index 222d4bf7eb..071389bb98 100755 --- a/headers/private/kernel/ksyscalls.h +++ b/headers/private/kernel/ksyscalls.h @@ -127,6 +127,9 @@ enum { SYSCALL_UNREGISTER_IMAGE, /* 115 */ SYSCALL_GET_IMAGE_INFO, SYSCALL_GET_NEXT_IMAGE_INFO, + SYSCALL_START_WATCHING, + SYSCALL_STOP_WATCHING, + SYSCALL_STOP_NOTIFYING, /* 120 */ }; int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_ret); diff --git a/headers/private/kernel/syscalls.h b/headers/private/kernel/syscalls.h index f44a78d9b3..66896d670f 100644 --- a/headers/private/kernel/syscalls.h +++ b/headers/private/kernel/syscalls.h @@ -70,6 +70,13 @@ status_t sys_unregister_image(image_id id); status_t sys_get_image_info(image_id id, image_info *info, size_t size); status_t sys_get_next_image_info(team_id team, int32 *cookie, image_info *info, size_t size); +// node monitor functions +status_t sys_stop_notifying(port_id port, uint32 token); +status_t sys_start_watching(dev_t device, ino_t node, uint32 flags, + port_id port, uint32 token); +status_t sys_stop_watching(dev_t device, ino_t node, uint32 flags, + port_id port, uint32 token); + // area functions region_id sys_vm_create_anonymous_region(const char *name, void **address, int addr_type, addr size, int wiring, int lock); diff --git a/headers/private/kernel/vfs.h b/headers/private/kernel/vfs.h index fc4d94ab13..261577c273 100755 --- a/headers/private/kernel/vfs.h +++ b/headers/private/kernel/vfs.h @@ -13,19 +13,39 @@ #include #include #include +#include +#include #define DEFAULT_FD_TABLE_SIZE 128 #define MAX_FD_TABLE_SIZE 2048 +#define MAX_NODE_MONITORS 4096 #include + +struct file_descriptor; +struct selectsync; +struct pollfd; + + +/** The I/O context of a process/team, holds the fd array among others */ +typedef struct io_context { + struct vnode *cwd; + mutex io_mutex; + uint32 table_size; + uint32 num_used_fds; + struct file_descriptor **fds; + struct list node_monitors; + uint32 num_monitors; + uint32 max_monitors; +} io_context; + + /* macro to allocate a iovec array on the stack */ #define IOVECS(name, size) \ uint8 _##name[sizeof(iovecs) + (size)*sizeof(iovec)]; \ iovecs *name = (iovecs *)_##name -struct selectsync; -struct pollfd; #ifdef __cplusplus extern "C" {