From 0100a6e5bea180aa938ad618d7ed853dd0b7ed10 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 27 Jun 2002 19:19:13 +0000 Subject: hurd/ 2002-06-26 Marcus Brinkmann * fs_notify.defs: Add MsgOption for send timeout. (dir_changed): Changed to simpleroutine. Change type of first argument to fs_notify_t. Add TICKNO argument. (file_changed): Likewise. * hurd_types.defs (fs_notify_t): New type. * hurd_types.h (fs_notify_t): Likewise. libdiskfs/ 2002-06-26 Marcus Brinkmann * Makefile (DIST_FILES): Variable removed. (MIGSTUBS): Use fs_notifyUser.o, not ourfs_notifyUser.o. * ourfs_notify.defs: File removed. * diskfs.h (struct node): New members DIRMOD_TICK and FILEMOD_TICK. * node-make.c (diskfs_make_node): Initialize DIRMOD_TICK and FILEMOD_TICK. * dir-chg.c: Include "fs_notify_U.h" instead "ourfs_notify_U.h". (diskfs_S_dir_notice_changes): Use new dir_changed invocation instead nowait_dir_changed. (diskfs_notice_dirchange): Likewise. Increase tick number. Ignore send timeout error. * file-chg.c: Include "fs_notify_U.h" instead "ourfs_notify_U.h". (diskfs_S_file_notice_changes): Use new file_changed invocation instead nowait_file_changed. (diskfs_notice_filechange): Likewise. Increase tick number. Ignore send timeout error. console/ 2002-06-27 Marcus Brinkmann * Makefile (MIGSTUBS): Add fs_notifyUser.o. (MIGSFLAGS): New variable. * console.c: Include "fs_notify_U.h". (struct modreq): New structure. (struct cons): New members DIRMOD_REQS and DIRMOD_TICK. (cons_notice_dirchange): New function. (vcons_lookup): Call cons_notice_dirchange. (netfs_S_dir_notice_changes): New function. (main): Initialize new members in CONS. * display.c (nowait_file_changed): Update to new interface (new argument TICKNO). (do_mach_notify_msg_accepted): Call nowait_file_changed with new argument. (display_notice_changes): Likewise. (display_notice_filechange): Likewise. --- console/console.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'console/console.c') diff --git a/console/console.c b/console/console.c index d75cf9c7..d25a3cf3 100644 --- a/console/console.c +++ b/console/console.c @@ -43,6 +43,8 @@ /* We include console.h for the color numbers. */ #include "console.h" +#include "fs_notify_U.h" + const char *argp_program_version = STANDARD_HURD_VERSION (console); char *netfs_server_name = "console"; @@ -91,6 +93,13 @@ struct vcons struct node *inpt_node; }; +/* Pending directory modification requests. */ +struct modreq +{ + mach_port_t port; + struct modreq *next; +}; + struct cons { /* The lock protects the console, all virtual consoles contained in @@ -104,12 +113,42 @@ struct cons int foreground; int background; + /* Requester of directory modification notifications. */ + struct modreq *dirmod_reqs; + unsigned int dirmod_tick; + struct node *node; mach_port_t underlying; /* A template for the stat information of all nodes. */ struct stat stat_template; }; + +/* Requires CONS to be locked. */ +static void +cons_notice_dirchange (cons_t cons, dir_changed_type_t type, char *name) +{ + error_t err; + struct modreq **preq = &cons->dirmod_reqs; + + cons->dirmod_tick++; + while (*preq) + { + struct modreq *req = *preq; + + err = dir_changed (req->port, cons->dirmod_tick, type, name); + if (err && err != MACH_SEND_TIMEOUT) + { + /* Remove notify port. */ + *preq = req->next; + mach_port_deallocate (mach_task_self (), req->port); + free (req); + } + else + preq = &req->next; + } +} + /* Lookup the virtual console with number ID in the console CONS, acquire a reference for it, and return it in R_VCONS. If CREATE is @@ -215,6 +254,8 @@ vcons_lookup (cons_t cons, int id, int create, vcons_t *r_vcons) } cons->vcons_list = vcons; } + cons_notice_dirchange (cons, DIR_CHANGED_NEW, vcons->name); + mutex_unlock (&cons->lock); *r_vcons = vcons; return 0; @@ -253,6 +294,8 @@ vcons_release (vcons_t vcons) if (vcons->next) vcons->next->prev = vcons->prev; + cons_notice_dirchange (cons, DIR_CHANGED_UNLINK, vcons->name); + /* XXX Destroy the state. */ display_destroy (vcons->display); input_destroy (vcons->input); @@ -1185,6 +1228,40 @@ netfs_S_io_map (struct protid *cred, } +kern_return_t +netfs_S_dir_notice_changes (struct protid *cred, mach_port_t notify) +{ + error_t err; + cons_t cons; + struct modreq *req; + + if (!cred) + return EOPNOTSUPP; + + cons = cred->po->np->nn->cons; + if (!cons) + return EOPNOTSUPP; + + mutex_lock (&cons->lock); + err = dir_changed (notify, cons->dirmod_tick, DIR_CHANGED_NULL, ""); + if (err) + { + mutex_unlock (&cons->lock); + return err; + } + req = malloc (sizeof (struct modreq)); + if (!req) + { + mutex_unlock (&cons->lock); + return errno; + } + req->port = notify; + req->next = cons->dirmod_reqs; + cons->dirmod_reqs = req; + mutex_unlock (&cons->lock); + return 0; +} + kern_return_t netfs_S_file_notice_changes (struct protid *cred, mach_port_t notify) { @@ -1676,6 +1753,8 @@ main (int argc, char **argv) cons->foreground = DEFAULT_FOREGROUND; cons->background = DEFAULT_BACKGROUND; cons->vcons_list = NULL; + cons->dirmod_reqs = NULL; + cons->dirmod_tick = 0; root_nn.cons = cons; /* Parse our command line arguments (all none of them). */ -- cgit v1.2.3