summaryrefslogtreecommitdiff
path: root/console/console.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2002-06-27 19:19:13 +0000
committerMarcus Brinkmann <marcus@gnu.org>2002-06-27 19:19:13 +0000
commit0100a6e5bea180aa938ad618d7ed853dd0b7ed10 (patch)
treefd7f58e3f4eea5a4bfad0509dad6619fc01a54f5 /console/console.c
parent38a8adf4ff9c0ecfbb4adb432feeff58e5058180 (diff)
hurd/
2002-06-26 Marcus Brinkmann <marcus@gnu.org> * 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 <marcus@gnu.org> * 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 <marcus@gnu.org> * 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.
Diffstat (limited to 'console/console.c')
-rw-r--r--console/console.c79
1 files changed, 79 insertions, 0 deletions
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,6 +113,10 @@ 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. */
@@ -111,6 +124,32 @@ struct cons
};
+/* 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
true, the virtual console will be created if it doesn't exist yet.
@@ -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);
@@ -1186,6 +1229,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)
{
struct node *np;
@@ -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). */