Lines Matching refs:fg
120 void fg_free(struct fileglob *fg);
127 static int closef_finish(struct fileproc *fp, struct fileglob *fg, proc_t p, vfs_context_t ctx);
3363 struct fileglob *fg;
3402 MALLOC_ZONE(fg, struct fileglob *, sizeof(struct fileglob), M_FILEGLOB, M_WAITOK);
3403 if (fg == NULL) {
3410 bzero(fg, sizeof(struct fileglob));
3411 lck_mtx_init(&fg->fg_lock, file_lck_grp, file_lck_attr);
3414 fg->fg_count = 1;
3415 fp->f_fglob = fg;
3417 mac_file_label_init(fg);
3427 mac_file_label_associate(fp->f_cred, fg);
3435 LIST_INSERT_AFTER(fq->f_fglob, fg, f_list);
3437 LIST_INSERT_HEAD(&filehead, fg, f_list);
3462 * Parameters: fg Pointer to fileglob to be
3468 fg_free(struct fileglob *fg)
3471 LIST_REMOVE(fg, f_list);
3475 if (IS_VALID_CRED(fg->fg_cred)) {
3476 kauth_cred_unref(&fg->fg_cred);
3478 lck_mtx_destroy(&fg->fg_lock, file_lck_grp);
3481 mac_file_label_destroy(fg);
3483 FREE_ZONE(fg, sizeof *fg, M_FILEGLOB);
3853 * fg Pointer to fileglob for fd
3861 * then fg must eith be locked (FHASLOCK) or must not have a
3864 * On return, the fg is freed.
3870 closef_finish(struct fileproc *fp, struct fileglob *fg, proc_t p, vfs_context_t ctx)
3876 if (fg->fg_ops)
3877 error = fo_close(fg, ctx);
3889 fg_free(fg);
3900 * fg Pointer to fileglob for fd
3915 closef_locked(struct fileproc *fp, struct fileglob *fg, proc_t p)
3922 if (fg == NULL) {
3926 /* Set up context with cred stashed in fg */
3931 context.vc_ucred = fg->fg_cred;
3941 if (p && (p->p_ladvflag & P_LADVLOCK) && fg->fg_type == DTYPE_VNODE) {
3948 vp = (struct vnode *)fg->fg_data;
3956 lck_mtx_lock_spin(&fg->fg_lock);
3957 fg->fg_count--;
3959 if (fg->fg_count > 0) {
3960 lck_mtx_unlock(&fg->fg_lock);
3964 if (fg->fg_count != 0)
3965 panic("fg %p: being freed with bad fg_count (%d)", fg, fg->fg_count);
3969 fg->fg_flag |= FWASWRITTEN;
3971 fg->fg_lflags |= FG_TERM;
3972 lck_mtx_unlock(&fg->fg_lock);
3976 error = closef_finish(fp, fg, p, &context);
4258 struct fileglob *fg;
4260 fg = fp->f_fglob;
4262 lck_mtx_lock_spin(&fg->fg_lock);
4268 if (fg->fg_count == 0)
4269 panic("fg_ref: adding fgcount to zeroed fg :fp %x, fg%x\n ", (unsigned int)fp, (unsigned int)fg);
4271 fg->fg_count++;
4272 lck_mtx_unlock(&fg->fg_lock);
4291 struct fileglob *fg;
4293 fg = fp->f_fglob;
4294 lck_mtx_lock_spin(&fg->fg_lock);
4295 fg->fg_count--;
4296 lck_mtx_unlock(&fg->fg_lock);
4305 * Parameters: fg Fileglob pointer to insert
4312 fg_insertuipc(struct fileglob * fg)
4316 lck_mtx_lock_spin(&fg->fg_lock);
4318 while (fg->fg_lflags & FG_RMMSGQ) {
4319 lck_mtx_convert_spin(&fg->fg_lock);
4321 fg->fg_lflags |= FG_WRMMSGQ;
4322 msleep(&fg->fg_lflags, &fg->fg_lock, 0, "fg_insertuipc", NULL);
4325 fg->fg_count++;
4326 fg->fg_msgcount++;
4327 if (fg->fg_msgcount == 1) {
4328 fg->fg_lflags |= FG_INSMSGQ;
4331 lck_mtx_unlock(&fg->fg_lock);
4336 LIST_INSERT_HEAD(&fmsghead, fg, f_msglist);
4338 lck_mtx_lock(&fg->fg_lock);
4339 fg->fg_lflags &= ~FG_INSMSGQ;
4340 if (fg->fg_lflags & FG_WINSMSGQ) {
4341 fg->fg_lflags &= ~FG_WINSMSGQ;
4342 wakeup(&fg->fg_lflags);
4344 lck_mtx_unlock(&fg->fg_lock);
4355 * Parameters: fg Fileglob pointer to remove
4362 fg_removeuipc(struct fileglob * fg)
4366 lck_mtx_lock_spin(&fg->fg_lock);
4367 while (fg->fg_lflags & FG_INSMSGQ) {
4368 lck_mtx_convert_spin(&fg->fg_lock);
4370 fg->fg_lflags |= FG_WINSMSGQ;
4371 msleep(&fg->fg_lflags, &fg->fg_lock, 0, "fg_removeuipc", NULL);
4373 fg->fg_msgcount--;
4374 if (fg->fg_msgcount == 0) {
4375 fg->fg_lflags |= FG_RMMSGQ;
4378 lck_mtx_unlock(&fg->fg_lock);
4383 LIST_REMOVE(fg, f_msglist);
4385 lck_mtx_lock(&fg->fg_lock);
4386 fg->fg_lflags &= ~FG_RMMSGQ;
4387 if (fg->fg_lflags & FG_WRMMSGQ) {
4388 fg->fg_lflags &= ~FG_WRMMSGQ;
4389 wakeup(&fg->fg_lflags);
4391 lck_mtx_unlock(&fg->fg_lock);
4507 fo_close(struct fileglob *fg, vfs_context_t ctx)
4509 return((*fg->fg_ops->fo_close)(fg, ctx));