Lines Matching refs:fg

133 void fg_free(struct fileglob *fg);
135 void fileport_releasefg(struct fileglob *fg);
141 static int closef_finish(struct fileproc *fp, struct fileglob *fg, proc_t p, vfs_context_t ctx);
821 struct fileglob *fg = fp->f_fglob;
823 lck_mtx_lock_spin(&fg->fg_lock);
825 fg->fg_lflags |= FG_NOSIGPIPE;
827 fg->fg_lflags &= FG_NOSIGPIPE;
828 lck_mtx_unlock(&fg->fg_lock);
3973 struct fileglob *fg;
4012 MALLOC_ZONE(fg, struct fileglob *, sizeof(struct fileglob), M_FILEGLOB, M_WAITOK);
4013 if (fg == NULL) {
4020 bzero(fg, sizeof(struct fileglob));
4021 lck_mtx_init(&fg->fg_lock, file_lck_grp, file_lck_attr);
4024 fg->fg_count = 1;
4025 fp->f_fglob = fg;
4027 mac_file_label_init(fg);
4037 mac_file_label_associate(fp->f_cred, fg);
4063 * Parameters: fg Pointer to fileglob to be
4069 fg_free(struct fileglob *fg)
4073 if (IS_VALID_CRED(fg->fg_cred)) {
4074 kauth_cred_unref(&fg->fg_cred);
4076 lck_mtx_destroy(&fg->fg_lock, file_lck_grp);
4079 mac_file_label_destroy(fg);
4081 FREE_ZONE(fg, sizeof *fg, M_FILEGLOB);
4481 * fg Pointer to fileglob for fd
4489 * then fg must eith be locked (FHASLOCK) or must not have a
4492 * On return, the fg is freed.
4498 closef_finish(struct fileproc *fp, struct fileglob *fg, proc_t p, vfs_context_t ctx)
4504 if (fg->fg_ops)
4505 error = fo_close(fg, ctx);
4517 fg_free(fg);
4528 * fg Pointer to fileglob for fd
4543 closef_locked(struct fileproc *fp, struct fileglob *fg, proc_t p)
4550 if (fg == NULL) {
4554 /* Set up context with cred stashed in fg */
4559 context.vc_ucred = fg->fg_cred;
4569 if (p && (p->p_ladvflag & P_LADVLOCK) && fg->fg_type == DTYPE_VNODE) {
4576 vp = (struct vnode *)fg->fg_data;
4584 lck_mtx_lock_spin(&fg->fg_lock);
4585 fg->fg_count--;
4587 if (fg->fg_count > 0) {
4588 lck_mtx_unlock(&fg->fg_lock);
4592 if (fg->fg_count != 0)
4593 panic("fg %p: being freed with bad fg_count (%d)", fg, fg->fg_count);
4597 fg->fg_flag |= FWASWRITTEN;
4599 fg->fg_lflags |= FG_TERM;
4600 lck_mtx_unlock(&fg->fg_lock);
4604 error = closef_finish(fp, fg, p, &context);
4806 struct fileglob *fg = NULL;
4821 fg = fp->f_fglob;
4825 fileport = fileport_alloc(fg);
4845 lck_mtx_lock_spin(&fg->fg_lock);
4846 fg->fg_lflags |= FG_PORTMADE;
4847 lck_mtx_unlock(&fg->fg_lock);
4867 fileport_releasefg(struct fileglob *fg)
4869 (void)closef_locked(NULL, fg, PROC_NULL);
4894 struct fileglob *fg;
4910 fg = fileport_port_to_fileglob(port);
4911 if (fg == NULL) {
4924 fp->f_fglob = fg;
5066 struct fileglob *fg;
5068 fg = fp->f_fglob;
5070 lck_mtx_lock_spin(&fg->fg_lock);
5076 if (fg->fg_count == 0)
5077 panic("fg_ref: adding fgcount to zeroed fg: fp %p fg %p",
5078 fp, fg);
5080 fg->fg_count++;
5081 lck_mtx_unlock(&fg->fg_lock);
5100 struct fileglob *fg;
5102 fg = fp->f_fglob;
5103 lck_mtx_lock_spin(&fg->fg_lock);
5104 fg->fg_count--;
5105 lck_mtx_unlock(&fg->fg_lock);
5114 * Parameters: fg Fileglob pointer to insert
5121 fg_insertuipc(struct fileglob * fg)
5125 lck_mtx_lock_spin(&fg->fg_lock);
5127 while (fg->fg_lflags & FG_RMMSGQ) {
5128 lck_mtx_convert_spin(&fg->fg_lock);
5130 fg->fg_lflags |= FG_WRMMSGQ;
5131 msleep(&fg->fg_lflags, &fg->fg_lock, 0, "fg_insertuipc", NULL);
5134 fg->fg_count++;
5135 fg->fg_msgcount++;
5136 if (fg->fg_msgcount == 1) {
5137 fg->fg_lflags |= FG_INSMSGQ;
5140 lck_mtx_unlock(&fg->fg_lock);
5145 LIST_INSERT_HEAD(&fmsghead, fg, f_msglist);
5147 lck_mtx_lock(&fg->fg_lock);
5148 fg->fg_lflags &= ~FG_INSMSGQ;
5149 if (fg->fg_lflags & FG_WINSMSGQ) {
5150 fg->fg_lflags &= ~FG_WINSMSGQ;
5151 wakeup(&fg->fg_lflags);
5153 lck_mtx_unlock(&fg->fg_lock);
5164 * Parameters: fg Fileglob pointer to remove
5171 fg_removeuipc(struct fileglob * fg)
5175 lck_mtx_lock_spin(&fg->fg_lock);
5176 while (fg->fg_lflags & FG_INSMSGQ) {
5177 lck_mtx_convert_spin(&fg->fg_lock);
5179 fg->fg_lflags |= FG_WINSMSGQ;
5180 msleep(&fg->fg_lflags, &fg->fg_lock, 0, "fg_removeuipc", NULL);
5182 fg->fg_msgcount--;
5183 if (fg->fg_msgcount == 0) {
5184 fg->fg_lflags |= FG_RMMSGQ;
5187 lck_mtx_unlock(&fg->fg_lock);
5192 LIST_REMOVE(fg, f_msglist);
5194 lck_mtx_lock(&fg->fg_lock);
5195 fg->fg_lflags &= ~FG_RMMSGQ;
5196 if (fg->fg_lflags & FG_WRMMSGQ) {
5197 fg->fg_lflags &= ~FG_WRMMSGQ;
5198 wakeup(&fg->fg_lflags);
5200 lck_mtx_unlock(&fg->fg_lock);
5316 fo_close(struct fileglob *fg, vfs_context_t ctx)
5318 return((*fg->fg_ops->fo_close)(fg, ctx));