Lines Matching defs:wd
422 int wd, i, error = 0;
465 /* Check to see if we already have a descriptor to wd's file. */
466 wd = -1;
471 DPRINTF(("%s: wd=%d was closed externally\n",
477 DPRINTF(("%s: wd=%d was replaced "
482 wd = i;
487 if (wd != -1)
492 if (wd == -1) {
494 * If we do not have a descriptor to wd's file, we
508 wd = *retval;
509 wp = fd_getfile(wd);
515 EV_SET(&kev, wd, inotify_filtid, EV_ADD|EV_ENABLE,
525 KASSERT(fd_getfile(wd) != NULL);
526 fd_close(wd);
529 *retval = wd;
531 /* Resize ifd_nwds to accommodate wd. */
532 if (wd+1 > ifd->ifd_nwds) {
534 (wd+1) * sizeof(*ifd->ifd_wds), KM_SLEEP);
542 ifd->ifd_nwds = wd+1;
545 ifd->ifd_wds[wd] = get_inotify_dir_entries(wd, true);
549 * If we do have a descriptor to wd's file, try to edit
557 wp = fd_getfile(wd);
559 DPRINTF(("%s: wd=%d was closed externally "
560 "(race, probably)\n", __func__, wd));
565 DPRINTF(("%s: wd=%d was replace with a non-vnode "
566 "(race, probably)\n", __func__, wd));
600 *retval = wd;
604 fd_putfile(wd);
613 * Remove a wd from ifd and close wd.
616 inotify_close_wd(struct inotifyfd *ifd, int wd)
631 KASSERT(0 <= wd && wd < ifd->ifd_nwds && ifd->ifd_wds[wd] != NULL);
633 kmem_free(ifd->ifd_wds[wd],
634 INOTIFY_DIR_ENTRIES_SIZE(ifd->ifd_wds[wd]->ide_count));
635 ifd->ifd_wds[wd] = NULL;
639 wp = fd_getfile(wd);
641 DPRINTF(("%s: wd=%d is already closed\n", __func__, wd));
647 EV_SET(&kev, wd, EVFILT_VNODE, EV_DELETE, 0, 0, 0);
650 DPRINTF(("%s: attempt to disable all events for wd=%d "
651 "had error=%d\n", __func__, wd, error));
653 return fd_close(wd);
657 * inotify_rm_watch(2). Close wd and remove it from ifd->ifd_wds.
665 syscallarg(int) wd;
671 const int wd = SCARG(uap, wd);
683 if (wd < 0 || wd >= ifd->ifd_nwds || ifd->ifd_wds[wd] == NULL) {
688 error = inotify_close_wd(ifd, wd);
739 do_kevent_to_inotify(int32_t wd, uint32_t mask, uint32_t cookie,
748 buf->ie_event.wd = wd;
815 * Create (and allocate) an appropriate inotify_dir_entries struct for wd to be
821 get_inotify_dir_entries(int wd, bool needs_lock)
830 wp = fd_getfile(wd);
885 fd_putfile(wd);
900 handle_write(struct inotifyfd *ifd, int wd, struct inotify_entry *buf,
908 old_idep = ifd->ifd_wds[wd];
910 new_idep = get_inotify_dir_entries(wd, false);
912 DPRINTF(("%s: directory for wd=%d could not be read\n",
913 __func__, wd));
924 do_kevent_to_inotify(wd, LINUX_IN_CREATE, 0,
935 do_kevent_to_inotify(wd, LINUX_IN_DELETE, 0,
960 do_kevent_to_inotify(wd, LINUX_IN_MOVED_FROM, changed, buf, nbuf,
963 do_kevent_to_inotify(wd, LINUX_IN_MOVED_TO, changed, buf, nbuf,
967 ifd->ifd_wds[wd] = new_idep;
976 kevent_to_inotify(struct inotifyfd *ifd, int wd, enum vtype wtype,
987 do_kevent_to_inotify(wd,
994 do_kevent_to_inotify(wd,
1006 handle_write(ifd, wd, buf, nbuf);
1010 * Need to check if wd is actually has a link count of 0 to issue a
1014 wp = fd_getfile(wd);
1018 fd_putfile(wd);
1021 do_kevent_to_inotify(wd, LINUX_IN_DELETE_SELF, 0,
1025 /* LINUX_IN_IGNORED must be the last event issued for wd. */
1027 do_kevent_to_inotify(wd, LINUX_IN_IGNORED, 0, buf, nbuf, NULL);
1029 * XXX in theory we could call inotify_close_wd(ifd, wd) but if
1031 * wd... so we can't.
1033 * For simplicity we do nothing, and so wd will only be closed