static void client_input_callback (struct running_client *cl, int fd, GdkInputCondition condition) { int res; int pid; char *tmp; if (!cl->buffer) cl->buffer = g_malloc (CLIENT_ERROR_BUFFER); res = read (fd, cl->buffer + cl->pos, CLIENT_ERROR_BUFFER - 1 - cl->pos); if (res < 0) { /* read error or EOF */ if (errno == EAGAIN || errno == EWOULDBLOCK) return; client_detach (cl); return; } else if (res == 0) { client_detach (cl); return; } if (cl->pos + res == CLIENT_ERROR_BUFFER - 1) { tmp = &cl->buffer[CLIENT_ERROR_BUFFER - 1]; *tmp = '\0'; } else { tmp = memchr (cl->buffer + cl->pos, '\0', res); cl->pos += res; } if (tmp) { gdk_input_remove (cl->tag); close (cl->fd); cl->fd = -1; if (!strncmp (cl->buffer, CLIENT_ERROR_MSG_HEAD, strlen (CLIENT_ERROR_MSG_HEAD))) { dialog_ok (_("XQF: ERROR!"), _("ERROR!\n\n%s"), cl->buffer + strlen (CLIENT_ERROR_MSG_HEAD)); pid = cl->pid; /* save PID value */ client_detach (cl); if (pid) kill (pid, SIGTERM); // kill(0) would kill this process too! } else { client_detach (cl); } } }
int nvrm_close(struct inode *inode, struct file *file) { struct nvrm_file_priv *priv = file->private_data; client_detach(priv->rt_client); kfree(priv); return 0; }
void gmm_fini(void) { if (initialized) { // NOTE: gmm_context_fini has to happen before client_detach // because garbage collections will need to update global info. gmm_context_fini(); client_detach(); initialized = 0; } gprint_fini(); }
void client_send_to_monitor(Client *c, Monitor *m) { if(c->mon == m) return; client_unfocus(c, true); client_detach(c); client_detach_stack(c); c->mon = m; c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ client_attach(c); client_attach_stack(c); client_focus(NULL); arrange(NULL); }
static void detach_unused (void) { GSList *tmp = clients; struct running_client *cl; while (tmp) { cl = (struct running_client *) tmp->data; if (cl->pid == 0) { client_detach (cl); tmp = clients; continue; } tmp = tmp->next; } }
/** Set the client as master * \param c Client */ void layout_set_client_master(Client *c) { screen_get_sel(); if(!c || (c->flags & HintFlag) || !(c->flags & TileFlag) || (c->flags & FSSFlag)) return; if(c == tiled_client(selscreen, clients)) CHECK((c = tiled_client(selscreen, c->next))); client_detach(c); client_attach(c); tags[selscreen][seltag[selscreen]].layout.func(selscreen); return; }
void client_unmanage(Client *c, bool destroyed) { Monitor *m = c->mon; /* The server grab construct avoids race conditions. */ client_detach(c); client_detach_stack(c); printf("unmanage %i, %i\n", destroyed, c->win); if(!destroyed) { uint32_t values[] = { c->oldbw }; xcb_grab_server(conn); xcb_configure_window_checked(conn, c->win, XCB_CONFIG_WINDOW_BORDER_WIDTH, values); xcb_ungrab_button_checked(conn, XCB_BUTTON_INDEX_ANY, c->win, XCB_GRAB_ANY); client_set_state(c, XCB_ICCCM_WM_STATE_WITHDRAWN); xcb_flush(conn); xcb_ungrab_server(conn); } free(c); client_focus(NULL); arrange(m); }
long nvrm_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { NvError err; NvOsIoctlParams p; NvU32 size; NvU32 small_buf[8]; void *ptr = 0; long e; NvBool bAlloc = NV_FALSE; struct nvrm_file_priv *priv = file->private_data; switch( cmd ) { case NvRmIoctls_Generic: { NvDispatchCtx dctx; dctx.Rt = s_RtHandle; dctx.Client = priv->rt_client; dctx.PackageIdx = 0; err = NvOsCopyIn( &p, (void *)arg, sizeof(p) ); if( err != NvSuccess ) { printk( "NvRmIoctls_Generic: copy in failed\n" ); goto fail; } //printk( "NvRmIoctls_Generic: %d %d %d\n", p.InBufferSize, // p.InOutBufferSize, p.OutBufferSize ); size = p.InBufferSize + p.InOutBufferSize + p.OutBufferSize; if( size <= sizeof(small_buf) ) { ptr = small_buf; } else { ptr = NvOsAlloc( size ); if( !ptr ) { printk( "NvRmIoctls_Generic: alloc failure (%d bytes)\n", size ); goto fail; } bAlloc = NV_TRUE; } err = NvOsCopyIn( ptr, p.pBuffer, p.InBufferSize + p.InOutBufferSize ); if( err != NvSuccess ) { printk( "NvRmIoctls_Generic: copy in failure\n" ); goto fail; } if (priv->su) { err = NvRm_Dispatch( ptr, p.InBufferSize + p.InOutBufferSize, ((NvU8 *)ptr) + p.InBufferSize, p.InOutBufferSize + p.OutBufferSize, &dctx ); } else { err = NvRm_Dispatch_Others( ptr, p.InBufferSize + p.InOutBufferSize, ((NvU8 *)ptr) + p.InBufferSize, p.InOutBufferSize + p.OutBufferSize, &dctx ); } if( err != NvSuccess ) { printk( "NvRmIoctls_Generic: dispatch failure\n" ); goto fail; } if( p.InOutBufferSize || p.OutBufferSize ) { err = NvOsCopyOut( ((NvU8 *)((NvOsIoctlParams *)arg)->pBuffer) + p.InBufferSize, ((NvU8 *)ptr) + p.InBufferSize, p.InOutBufferSize + p.OutBufferSize ); if( err != NvSuccess ) { printk( "NvRmIoctls_Generic: copy out failure\n" ); goto fail; } } break; } case NvRmIoctls_NvRmGraphics: printk( "NvRmIoctls_NvRmGraphics: not supported\n" ); goto fail; case NvRmIoctls_NvRmFbControl: printk( "NvRmIoctls_NvRmFbControl: deprecated \n" ); break; case NvRmIoctls_NvRmMemRead: case NvRmIoctls_NvRmMemWrite: case NvRmIoctls_NvRmMemReadStrided: case NvRmIoctls_NvRmGetCarveoutInfo: case NvRmIoctls_NvRmMemWriteStrided: goto fail; case NvRmIoctls_NvRmMemMapIntoCallerPtr: // FIXME: implement? printk( "NvRmIoctls_NvRmMemMapIntoCallerPtr: not supported\n" ); goto fail; case NvRmIoctls_NvRmBootDone: return tegra_start_dvfsd(); case NvRmIoctls_NvRmGetClientId: err = NvOsCopyIn(&p, (void*)arg, sizeof(p)); if (err != NvSuccess) { NvOsDebugPrintf("NvRmIoctls_NvRmGetClientId: copy in failed\n"); goto fail; } NV_ASSERT(p.InBufferSize == 0); NV_ASSERT(p.OutBufferSize == sizeof(NvRtClientHandle)); NV_ASSERT(p.InOutBufferSize == 0); if (NvOsCopyOut(p.pBuffer, &priv->rt_client, sizeof(NvRtClientHandle)) != NvSuccess) { NvOsDebugPrintf("Failed to copy client id\n"); goto fail; } break; case NvRmIoctls_NvRmClientAttach: { NvRtClientHandle Client; err = NvOsCopyIn(&p, (void*)arg, sizeof(p)); if (err != NvSuccess) { NvOsDebugPrintf("NvRmIoctls_NvRmClientAttach: copy in failed\n"); goto fail; } NV_ASSERT(p.InBufferSize == sizeof(NvRtClientHandle)); NV_ASSERT(p.OutBufferSize == 0); NV_ASSERT(p.InOutBufferSize == 0); if (NvOsCopyIn((void*)&Client, p.pBuffer, sizeof(NvRtClientHandle)) != NvSuccess) { NvOsDebugPrintf("Failed to copy client id\n"); goto fail; } NV_ASSERT(Client || !"Bad client"); if (Client == priv->rt_client) { // The daemon is attaching to itself, no need to add refcount break; } if (NvRtAddClientRef(s_RtHandle, Client) != NvSuccess) { NvOsDebugPrintf("Client ref add unsuccessful\n"); goto fail; } break; } case NvRmIoctls_NvRmClientDetach: { NvRtClientHandle Client; err = NvOsCopyIn(&p, (void*)arg, sizeof(p)); if (err != NvSuccess) { NvOsDebugPrintf("NvRmIoctls_NvRmClientAttach: copy in failed\n"); goto fail; } NV_ASSERT(p.InBufferSize == sizeof(NvRtClientHandle)); NV_ASSERT(p.OutBufferSize == 0); NV_ASSERT(p.InOutBufferSize == 0); if (NvOsCopyIn((void*)&Client, p.pBuffer, sizeof(NvRtClientHandle)) != NvSuccess) { NvOsDebugPrintf("Failed to copy client id\n"); goto fail; } NV_ASSERT(Client || !"Bad client"); if (Client == priv->rt_client) { // The daemon is detaching from itself, no need to dec refcount break; } client_detach(Client); break; } // FIXME: power ioctls? default: printk( "unknown ioctl code\n" ); goto fail; } e = 0; goto clean; fail: e = -EINVAL; clean: if( bAlloc ) { NvOsFree( ptr ); } return e; }