diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2002-06-27 19:19:13 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2002-06-27 19:19:13 +0000 |
commit | 0100a6e5bea180aa938ad618d7ed853dd0b7ed10 (patch) | |
tree | fd7f58e3f4eea5a4bfad0509dad6619fc01a54f5 /console | |
parent | 38a8adf4ff9c0ecfbb4adb432feeff58e5058180 (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')
-rw-r--r-- | console/ChangeLog | 17 | ||||
-rw-r--r-- | console/Makefile | 4 | ||||
-rw-r--r-- | console/console.c | 79 | ||||
-rw-r--r-- | console/display.c | 29 |
4 files changed, 121 insertions, 8 deletions
diff --git a/console/ChangeLog b/console/ChangeLog index 2432860b..b9d85c97 100644 --- a/console/ChangeLog +++ b/console/ChangeLog @@ -1,3 +1,20 @@ +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. + 2002-06-25 Marcus Brinkmann <marcus@gnu.org> * Makefile (HURDLIBS): Add pager, reported by Alfred M. Szmidt. diff --git a/console/Makefile b/console/Makefile index a9a15e8c..434d80e6 100644 --- a/console/Makefile +++ b/console/Makefile @@ -26,11 +26,13 @@ target = console SRCS = console.c display.c input.c LCLHDRS = console.h display.h input.h priv.h mutations.h -MIGSTUBS = notifyServer.o tioctlServer.o +MIGSTUBS = notifyServer.o tioctlServer.o fs_notifyUser.o HURDLIBS = netfs fshelp iohelp pager threads ports ihash shouldbeinlibc OBJS = $(sort $(SRCS:.c=.o) $(MIGSTUBS)) +MIGSFLAGS += -imacros $(srcdir)/mutations.h + # This is the old monolithic version of the console server. #SRCS = main.c vcons.c focus.c vga-display.c vga.c dynafont.c bdf.c #LCLHDRS = focus.h input-drv.h vcons.h display-drv.h vga.h vga-hw.h \ 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). */ diff --git a/console/display.c b/console/display.c index a418ca73..7765af8e 100644 --- a/console/display.c +++ b/console/display.c @@ -291,12 +291,15 @@ static struct port_class *notify_class; /* SimpleRoutine file_changed */ kern_return_t -nowait_file_changed (mach_port_t notify_port, file_changed_type_t change, +nowait_file_changed (mach_port_t notify_port, natural_t tickno, + file_changed_type_t change, off_t start, off_t end, mach_port_t notify) { typedef struct { mach_msg_header_t Head; + mach_msg_type_t ticknoType; + natural_t tickno; mach_msg_type_t changeType; file_changed_type_t change; mach_msg_type_t startType; @@ -309,7 +312,17 @@ nowait_file_changed (mach_port_t notify_port, file_changed_type_t change, Request In; } Mess; register Request *InP = &Mess.In; - + + static const mach_msg_type_t ticknoType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + static const mach_msg_type_t changeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, @@ -340,6 +353,8 @@ nowait_file_changed (mach_port_t notify_port, file_changed_type_t change, /* msgt_unused = */ 0 }; + InP->ticknoType = ticknoType; + InP->tickno = tickno; InP->changeType = changeType; InP->change = change; InP->startType = startType; @@ -356,11 +371,11 @@ nowait_file_changed (mach_port_t notify_port, file_changed_type_t change, if (notify == MACH_PORT_NULL) return mach_msg (&InP->Head, MACH_SEND_MSG | MACH_MSG_OPTION_NONE, - 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, + 56, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); else return mach_msg (&InP->Head, MACH_SEND_MSG | MACH_SEND_NOTIFY, - 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, + 56, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, notify); } @@ -435,7 +450,7 @@ do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t send) /* A request was desired while we were blocking. Send it now and stay in pending queue. */ req->pending = 0; - err = nowait_file_changed (req->port, FILE_CHANGED_WRITE, -1, -1, + err = nowait_file_changed (req->port, 0, FILE_CHANGED_WRITE, -1, -1, notify); if (err && err != MACH_SEND_WILL_NOTIFY) { @@ -484,7 +499,7 @@ display_notice_changes (display_t display, mach_port_t notify) struct modreq *req; mutex_lock (&display->lock); - err = nowait_file_changed (notify, FILE_CHANGED_NULL, 0, 0, MACH_PORT_NULL); + err = nowait_file_changed (notify, 0, FILE_CHANGED_NULL, 0, 0, MACH_PORT_NULL); if (err) { mutex_unlock (&display->lock); @@ -523,7 +538,7 @@ display_notice_filechange (display_t display) { req = *preq; - err = nowait_file_changed (req->port, FILE_CHANGED_WRITE, -1, -1, + err = nowait_file_changed (req->port, 0, FILE_CHANGED_WRITE, -1, -1, notify_port); if (err) { |