static int bus1_fop_mmap(struct file *file, struct vm_area_struct *vma) { struct bus1_peer *peer = file->private_data; struct bus1_pool *pool; int r; if (!bus1_peer_acquire(peer)) return -ESHUTDOWN; pool = &bus1_peer_dereference(peer)->pool; if (vma->vm_flags & VM_WRITE) { /* deny write access to the pool */ r = -EPERM; } else { /* replace the connection file with our shmem file */ if (vma->vm_file) fput(vma->vm_file); vma->vm_file = get_file(pool->f); vma->vm_flags &= ~VM_MAYWRITE; /* calls into shmem_mmap(), which simply sets vm_ops */ r = pool->f->f_op->mmap(pool->f, vma); } bus1_peer_release(peer); return r; }
static long bus1_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct bus1_peer *peer = file->private_data; int r; switch (cmd) { case BUS1_CMD_PEER_INIT: return bus1_peer_ioctl_init(peer, arg); case BUS1_CMD_PEER_QUERY: case BUS1_CMD_PEER_RESET: case BUS1_CMD_PEER_CLONE: case BUS1_CMD_NODE_DESTROY: case BUS1_CMD_HANDLE_RELEASE: case BUS1_CMD_SLICE_RELEASE: case BUS1_CMD_SEND: case BUS1_CMD_RECV: if (bus1_active_is_new(&peer->active)) return -ENOTCONN; if (!bus1_peer_acquire(peer)) return -ESHUTDOWN; r = bus1_peer_ioctl(peer, file, cmd, arg); bus1_peer_release(peer); return r; } return -ENOTTY; }
static long bus1_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct bus1_peer *peer = file->private_data; int r; if (!bus1_peer_acquire(peer)) return -ESHUTDOWN; r = bus1_peer_ioctl(peer, cmd, arg); bus1_peer_release(peer); return r; }