From 9474dcf08999fb89bb6aac05f104041dcf72f9cb Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Mon, 10 Aug 1998 17:42:39 +0000 Subject: Sun Aug 9 21:09:24 1998 Jose M. Moya * diskfs.h (struct node): Add filemod_reqs member. (struct modreq): Rename struct dirmod to reqmod as it is used for directory and file notifications. (diskfs_notice_filechange): Add prototype. * dir-chg.c (diskfs_S_dir_notice_changes): Check nowait_dir_changed return value for errors. (diskfs_notice_dirchange): Remove requests when the notification fails. * file-chg.c (diskfs_S_file_notice_changes): Implement. (diskfs_notice_filechange): New function. * node-make.c (diskfs_make_node): Initialize filemod_reqs. * node-drop.c (free_modreqs): New function. (diskfs_drop_node): Free filemod_reqs. * file-chauthor.c (dithkfth_TH_file_chauthor): Add file notifications. * file-chflags.c (diskfs_S_file_chflags): Likewise. * file-chmod.c (diskfs_S_file_chmod): Likewise. * file-chown.c (diskfs_S_file_chown): Likewise. * file-set-size.c (diskfs_S_file_set_size): Likewise. * io-prenotify.c (diskfs_S_io_prenotify): Likewise. * io-write.c (diskfs_S_io_write): Likewise. * node-rdwr.c (diskfs_node_rdwr): Likewise. --- libdiskfs/dir-chg.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'libdiskfs/dir-chg.c') diff --git a/libdiskfs/dir-chg.c b/libdiskfs/dir-chg.c index 42dfb161..12b169c6 100644 --- a/libdiskfs/dir-chg.c +++ b/libdiskfs/dir-chg.c @@ -23,24 +23,30 @@ kern_return_t diskfs_S_dir_notice_changes (struct protid *cred, mach_port_t notify) { - struct dirmod *req; + error_t err; + struct modreq *req; struct node *np; if (!cred) return EOPNOTSUPP; np = cred->po->np; - req = malloc (sizeof (struct dirmod)); mutex_lock (&np->lock); if (!S_ISDIR (np->dn_stat.st_mode)) { mutex_unlock (&np->lock); return ENOTDIR; } + err = nowait_dir_changed (notify, DIR_CHANGED_NULL, ""); + if (err) + { + mutex_unlock (&np->lock); + return err; + } + req = malloc (sizeof (struct modreq)); req->port = notify; req->next = np->dirmod_reqs; np->dirmod_reqs = req; - nowait_dir_changed (notify, DIR_CHANGED_NULL, ""); mutex_unlock (&np->lock); return 0; } @@ -49,8 +55,21 @@ void diskfs_notice_dirchange (struct node *dp, enum dir_changed_type type, char *name) { - struct dirmod *req; + error_t err; + struct modreq **preq; - for (req = dp->dirmod_reqs; req; req = req->next) - nowait_dir_changed (req->port, type, name); + preq = &dp->dirmod_reqs; + while (*preq) + { + struct modreq *req = *preq; + err = nowait_dir_changed (req->port, type, name); + if (err) + { /* remove notify port */ + *preq = req->next; + mach_port_deallocate (mach_task_self (), req->port); + free (req); + } + else + preq = &req->next; + } } -- cgit v1.2.3