Lines Matching +full:mode +full:- +full:capable
1 // SPDX-License-Identifier: GPL-2.0
5 * Dynamic diacritical handling - aeb@cwi.nl - Dec 1993
6 * Dynamic keymap and string allocation - aeb@cwi.nl - May 1994
7 * Restrict VT switching via ioctl() - grif@cs.ucr.edu - Dec 1995
8 * Some code moved for less code duplication - Andi Kleen - Mar 1997
9 * Check put/get_user, cleanups - acme@conectiva.com.br - Jun 2001
50 * while we're checking whether it's in-use. in vt_in_use()
54 return vc && kref_read(&vc->port.kref) > 1; in vt_in_use()
77 * ttys 0..MAX_NR_CONSOLES-1). Explicitly naming VT 0 is illegal, but using
123 if (!(ve->event.event & event)) in vt_event_post()
125 ve->event.event = event; in vt_event_post()
126 /* kernel view is consoles 0..n-1, user space view is in vt_event_post()
128 ve->event.oldev = old + 1; in vt_event_post()
129 ve->event.newev = new + 1; in vt_event_post()
131 ve->done = 1; in vt_event_post()
142 INIT_LIST_HEAD(&vw->list); in __vt_event_queue()
143 vw->done = 0; in __vt_event_queue()
146 list_add(&vw->list, &vt_events); in __vt_event_queue()
153 wait_event_interruptible(vt_event_waitqueue, vw->done); in __vt_event_wait()
162 list_del(&vw->list); in __vt_event_dequeue()
167 * vt_event_wait - wait for an event
171 * structure. On return the structure has wv->done set to 1 for success
183 * vt_event_wait_ioctl - event ioctl handler
194 return -EFAULT; in vt_event_wait_ioctl()
197 return -EINVAL; in vt_event_wait_ioctl()
203 return -EFAULT; in vt_event_wait_ioctl()
206 return -EINTR; in vt_event_wait_ioctl()
210 * vt_waitactive - active console wait
230 return -EINTR; in vt_waitactive()
241 #define GPNUM (GPLAST - GPFIRST + 1)
244 * currently, setting the mode from KD_TEXT to KD_GRAPHICS doesn't do a whole
248 * restore their engine state. --BenH
252 static int vt_kdsetmode(struct vc_data *vc, unsigned long mode) in vt_kdsetmode() argument
254 switch (mode) { in vt_kdsetmode()
259 mode = KD_TEXT; in vt_kdsetmode()
264 return -EINVAL; in vt_kdsetmode()
267 if (vc->vc_mode == mode) in vt_kdsetmode()
270 vc->vc_mode = mode; in vt_kdsetmode()
271 if (vc->vc_num != fg_console) in vt_kdsetmode()
275 if (mode == KD_TEXT) in vt_kdsetmode()
286 struct vc_data *vc = tty->driver_data; in vt_k_ioctl()
288 unsigned int console = vc->vc_num; in vt_k_ioctl()
294 return -EPERM; in vt_k_ioctl()
297 * the platform-dependent CLOCK_TICK_RATE between 2.6.12 in vt_k_ioctl()
308 return -EPERM; in vt_k_ioctl()
346 return -EINVAL; in vt_k_ioctl()
348 return ksys_ioperm(arg, 1, (cmd == KDADDIO)) ? -ENXIO : 0; in vt_k_ioctl()
353 (cmd == KDENABIO)) ? -ENXIO : 0; in vt_k_ioctl()
362 if (!capable(CAP_SYS_TTY_CONFIG)) in vt_k_ioctl()
363 return -EPERM; in vt_k_ioctl()
366 return -EFAULT; in vt_k_ioctl()
372 return -EFAULT; in vt_k_ioctl()
378 return -EPERM; in vt_k_ioctl()
386 return put_user(vc->vc_mode, (int __user *)arg); in vt_k_ioctl()
394 return -EINVAL; in vt_k_ioctl()
398 return -EPERM; in vt_k_ioctl()
419 if(!capable(CAP_SYS_TTY_CONFIG)) in vt_k_ioctl()
440 /* don't use them - they will go away without warning */ in vt_k_ioctl()
455 if (!perm || !capable(CAP_KILL)) in vt_k_ioctl()
456 return -EPERM; in vt_k_ioctl()
458 return -EINVAL; in vt_k_ioctl()
471 return -EFAULT; in vt_k_ioctl()
473 return -EPERM; in vt_k_ioctl()
478 return -EFAULT; in vt_k_ioctl()
483 return -ENOIOCTLCMD; in vt_k_ioctl()
495 return -EFAULT; in do_unimap_ioctl()
499 return -EPERM; in do_unimap_ioctl()
502 if (!perm && fg_console != vc->vc_num) in do_unimap_ioctl()
503 return -EPERM; in do_unimap_ioctl()
504 return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), in do_unimap_ioctl()
516 return -EPERM; in vt_io_ioctl()
524 return -EPERM; in vt_io_ioctl()
532 return -EPERM; in vt_io_ioctl()
540 return -EPERM; in vt_io_ioctl()
549 return -ENOIOCTLCMD; in vt_io_ioctl()
559 if (vc->vt_mode.mode != VT_PROCESS) in vt_reldisp()
560 return -EINVAL; in vt_reldisp()
562 /* Switched-to response */ in vt_reldisp()
563 if (vc->vt_newvt < 0) { in vt_reldisp()
565 return swtch == VT_ACKACQ ? 0 : -EINVAL; in vt_reldisp()
568 /* Switching-from response */ in vt_reldisp()
571 vc->vt_newvt = -1; in vt_reldisp()
576 newvt = vc->vt_newvt; in vt_reldisp()
577 vc->vt_newvt = -1; in vt_reldisp()
598 return -EFAULT; in vt_setactivate()
600 return -ENXIO; in vt_setactivate()
603 vsa.console--; in vt_setactivate()
616 nvc->vt_mode = vsa.mode; in vt_setactivate()
617 nvc->vt_mode.frsig = 0; in vt_setactivate()
618 put_pid(nvc->vt_pid); in vt_setactivate()
619 nvc->vt_pid = get_pid(task_pid(current)); in vt_setactivate()
637 ret = -EBUSY; in vt_disallocate()
643 tty_port_put(&vc->port); in vt_disallocate()
664 tty_port_put(&vc[i]->port); in vt_disallocate_all()
674 return -EFAULT; in vt_resizex()
678 v.v_vlin = vc->vc_scan_lines; in vt_resizex()
684 return -EINVAL; in vt_resizex()
693 return -EINVAL; in vt_resizex()
699 return -EINVAL; in vt_resizex()
710 int save_scan_lines = vcp->vc_scan_lines; in vt_resizex()
711 int save_cell_height = vcp->vc_cell_height; in vt_resizex()
714 vcp->vc_scan_lines = v.v_vlin; in vt_resizex()
716 vcp->vc_cell_height = v.v_clin; in vt_resizex()
717 vcp->vc_resize_user = 1; in vt_resizex()
720 vcp->vc_scan_lines = save_scan_lines; in vt_resizex()
721 vcp->vc_cell_height = save_cell_height; in vt_resizex()
733 * We handle the console-specific ioctl's here. We allow the
739 struct vc_data *vc = tty->driver_data; in vt_ioctl()
749 if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) in vt_ioctl()
753 if (ret != -ENOIOCTLCMD) in vt_ioctl()
757 if (ret != -ENOIOCTLCMD) in vt_ioctl()
768 return -EPERM; in vt_ioctl()
770 return -EFAULT; in vt_ioctl()
771 if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) in vt_ioctl()
772 return -EINVAL; in vt_ioctl()
775 vc->vt_mode = tmp; in vt_ioctl()
777 vc->vt_mode.frsig = 0; in vt_ioctl()
778 put_pid(vc->vt_pid); in vt_ioctl()
779 vc->vt_pid = get_pid(task_pid(current)); in vt_ioctl()
780 /* no switch is required -- saw@shade.msu.ru */ in vt_ioctl()
781 vc->vt_newvt = -1; in vt_ioctl()
792 memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode)); in vt_ioctl()
797 return -EFAULT; in vt_ioctl()
811 if (put_user(fg_console + 1, &vtstat->v_active)) in vt_ioctl()
812 return -EFAULT; in vt_ioctl()
821 return put_user(state, &vtstat->v_state); in vt_ioctl()
825 * Returns the first available (non-opened) console. in vt_ioctl()
833 i = i < MAX_NR_CONSOLES ? (i+1) : -1; in vt_ioctl()
843 return -EPERM; in vt_ioctl()
845 return -ENXIO; in vt_ioctl()
847 arg--; in vt_ioctl()
858 return -EPERM; in vt_ioctl()
867 return -EPERM; in vt_ioctl()
869 return -ENXIO; in vt_ioctl()
878 * 0: pending switch-from not OK in vt_ioctl()
879 * 1: pending switch-from OK in vt_ioctl()
880 * 2: completed switch-to OK in vt_ioctl()
884 return -EPERM; in vt_ioctl()
898 return -ENXIO; in vt_ioctl()
903 return vt_disallocate(--arg); in vt_ioctl()
913 return -EPERM; in vt_ioctl()
914 if (get_user(ll, &vtsizes->v_rows) || in vt_ioctl()
915 get_user(cc, &vtsizes->v_cols)) in vt_ioctl()
916 return -EFAULT; in vt_ioctl()
923 vc->vc_resize_user = 1; in vt_ioctl()
934 return -EPERM; in vt_ioctl()
939 if (!capable(CAP_SYS_TTY_CONFIG)) in vt_ioctl()
940 return -EPERM; in vt_ioctl()
944 if (!capable(CAP_SYS_TTY_CONFIG)) in vt_ioctl()
945 return -EPERM; in vt_ioctl()
949 return put_user(vc->vc_hi_font_mask, in vt_ioctl()
954 return -ENOIOCTLCMD; in vt_ioctl()
962 vc->vc_mode = KD_TEXT; in reset_vc()
963 vt_reset_unicode(vc->vc_num); in reset_vc()
964 vc->vt_mode.mode = VT_AUTO; in reset_vc()
965 vc->vt_mode.waitv = 0; in reset_vc()
966 vc->vt_mode.relsig = 0; in reset_vc()
967 vc->vt_mode.acqsig = 0; in reset_vc()
968 vc->vt_mode.frsig = 0; in reset_vc()
969 put_pid(vc->vt_pid); in reset_vc()
970 vc->vt_pid = NULL; in reset_vc()
971 vc->vt_newvt = -1; in reset_vc()
983 vc = vc_con->d; in vc_SAK()
986 tty = vc->port.tty; in vc_SAK()
1015 return -EFAULT; in compat_kdfontop_ioctl()
1016 if (!perm && op->op != KD_FONT_OP_GET) in compat_kdfontop_ioctl()
1017 return -EPERM; in compat_kdfontop_ioctl()
1018 op->data = compat_ptr(((struct compat_console_font_op *)op)->data); in compat_kdfontop_ioctl()
1022 ((struct compat_console_font_op *)op)->data = (unsigned long)op->data; in compat_kdfontop_ioctl()
1024 return -EFAULT; in compat_kdfontop_ioctl()
1041 return -EFAULT; in compat_unimap_ioctl()
1046 return -EPERM; in compat_unimap_ioctl()
1049 if (!perm && fg_console != vc->vc_num) in compat_unimap_ioctl()
1050 return -EPERM; in compat_unimap_ioctl()
1051 return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), tmp_entries); in compat_unimap_ioctl()
1059 struct vc_data *vc = tty->driver_data; in vt_compat_ioctl()
1069 if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) in vt_compat_ioctl()
1135 * KD_TEXT mode or vice versa, which means we need to blank or in complete_change_console()
1138 old_vc_mode = vc_cons[fg_console].d->vc_mode; in complete_change_console()
1151 if (old_vc_mode != vc->vc_mode) { in complete_change_console()
1152 if (vc->vc_mode == KD_TEXT) in complete_change_console()
1163 if (vc->vt_mode.mode == VT_PROCESS) { in complete_change_console()
1165 * Send the signal as privileged - kill_pid() will in complete_change_console()
1169 if (kill_pid(vc->vt_pid, vc->vt_mode.acqsig, 1) != 0) { in complete_change_console()
1173 * to KD_TEXT mode. I'm not sure if this is strictly correct in complete_change_console()
1181 if (old_vc_mode != vc->vc_mode) { in complete_change_console()
1182 if (vc->vc_mode == KD_TEXT) in complete_change_console()
1193 vt_event_post(VT_EVENT_SWITCH, old, vc->vc_num); in complete_change_console()
1198 * Performs the front-end of a vt switch
1204 if (!new_vc || new_vc->vc_num == fg_console || vt_dont_switch) in change_console()
1208 * If this vt is in process mode, then we need to handshake with in change_console()
1214 * If it doesn't, we reset this vt to auto mode and continue. in change_console()
1219 * the user waits just the right amount of time :-) and revert the in change_console()
1223 if (vc->vt_mode.mode == VT_PROCESS) { in change_console()
1225 * Send the signal as privileged - kill_pid() will in change_console()
1232 vc->vt_newvt = new_vc->vc_num; in change_console()
1233 if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) { in change_console()
1245 * to KD_TEXT mode. I'm not sure if this is strictly correct in change_console()
1259 * Ignore all switches in KD_GRAPHICS+VT_AUTO mode in change_console()
1261 if (vc->vc_mode == KD_GRAPHICS) in change_console()
1276 /* Graphics mode - up to X */ in vt_move_to_console()
1287 return -ENOSPC; in vt_move_to_console()
1297 return -EIO; in vt_move_to_console()
1302 return -EINTR; in vt_move_to_console()