Lines Matching +full:mode +full:- +full:capable
1 // SPDX-License-Identifier: GPL-2.0
5 * Dynamic diacritical handling - [email protected] - Dec 1993
6 * Dynamic keymap and string allocation - [email protected] - May 1994
7 * Restrict VT switching via ioctl() - [email protected] - Dec 1995
8 * Some code moved for less code duplication - Andi Kleen - Mar 1997
9 * Check put/get_user, cleanups - [email protected] - 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()
602 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()
719 vcp->vc_scan_lines = save_scan_lines; in vt_resizex()
720 vcp->vc_cell_height = save_cell_height; in vt_resizex()
732 * We handle the console-specific ioctl's here. We allow the
738 struct vc_data *vc = tty->driver_data; in vt_ioctl()
748 if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) in vt_ioctl()
752 if (ret != -ENOIOCTLCMD) in vt_ioctl()
756 if (ret != -ENOIOCTLCMD) in vt_ioctl()
767 return -EPERM; in vt_ioctl()
769 return -EFAULT; in vt_ioctl()
770 if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) in vt_ioctl()
771 return -EINVAL; in vt_ioctl()
774 vc->vt_mode = tmp; in vt_ioctl()
776 vc->vt_mode.frsig = 0; in vt_ioctl()
777 put_pid(vc->vt_pid); in vt_ioctl()
778 vc->vt_pid = get_pid(task_pid(current)); in vt_ioctl()
779 /* no switch is required -- [email protected] */ in vt_ioctl()
780 vc->vt_newvt = -1; in vt_ioctl()
791 memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode)); in vt_ioctl()
796 return -EFAULT; in vt_ioctl()
810 if (put_user(fg_console + 1, &vtstat->v_active)) in vt_ioctl()
811 return -EFAULT; in vt_ioctl()
820 return put_user(state, &vtstat->v_state); in vt_ioctl()
824 * Returns the first available (non-opened) console. in vt_ioctl()
832 i = i < MAX_NR_CONSOLES ? (i+1) : -1; in vt_ioctl()
842 return -EPERM; in vt_ioctl()
844 return -ENXIO; in vt_ioctl()
846 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()
905 arg = array_index_nospec(arg - 1, MAX_NR_CONSOLES); in vt_ioctl()
915 return -EPERM; in vt_ioctl()
916 if (get_user(ll, &vtsizes->v_rows) || in vt_ioctl()
917 get_user(cc, &vtsizes->v_cols)) in vt_ioctl()
918 return -EFAULT; in vt_ioctl()
935 return -EPERM; in vt_ioctl()
940 if (!capable(CAP_SYS_TTY_CONFIG)) in vt_ioctl()
941 return -EPERM; in vt_ioctl()
945 if (!capable(CAP_SYS_TTY_CONFIG)) in vt_ioctl()
946 return -EPERM; in vt_ioctl()
950 return put_user(vc->vc_hi_font_mask, in vt_ioctl()
955 return -ENOIOCTLCMD; in vt_ioctl()
963 vc->vc_mode = KD_TEXT; in reset_vc()
964 vt_reset_unicode(vc->vc_num); in reset_vc()
965 vc->vt_mode.mode = VT_AUTO; in reset_vc()
966 vc->vt_mode.waitv = 0; in reset_vc()
967 vc->vt_mode.relsig = 0; in reset_vc()
968 vc->vt_mode.acqsig = 0; in reset_vc()
969 vc->vt_mode.frsig = 0; in reset_vc()
970 put_pid(vc->vt_pid); in reset_vc()
971 vc->vt_pid = NULL; in reset_vc()
972 vc->vt_newvt = -1; in reset_vc()
984 vc = vc_con->d; in vc_SAK()
987 tty = vc->port.tty; in vc_SAK()
1016 return -EFAULT; in compat_kdfontop_ioctl()
1017 if (!perm && op->op != KD_FONT_OP_GET) in compat_kdfontop_ioctl()
1018 return -EPERM; in compat_kdfontop_ioctl()
1019 op->data = compat_ptr(((struct compat_console_font_op *)op)->data); in compat_kdfontop_ioctl()
1023 ((struct compat_console_font_op *)op)->data = (unsigned long)op->data; in compat_kdfontop_ioctl()
1025 return -EFAULT; in compat_kdfontop_ioctl()
1042 return -EFAULT; in compat_unimap_ioctl()
1047 return -EPERM; in compat_unimap_ioctl()
1050 if (!perm && fg_console != vc->vc_num) in compat_unimap_ioctl()
1051 return -EPERM; in compat_unimap_ioctl()
1052 return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), tmp_entries); in compat_unimap_ioctl()
1060 struct vc_data *vc = tty->driver_data; in vt_compat_ioctl()
1070 if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) in vt_compat_ioctl()
1136 * KD_TEXT mode or vice versa, which means we need to blank or in complete_change_console()
1139 old_vc_mode = vc_cons[fg_console].d->vc_mode; in complete_change_console()
1152 if (old_vc_mode != vc->vc_mode) { in complete_change_console()
1153 if (vc->vc_mode == KD_TEXT) in complete_change_console()
1164 if (vc->vt_mode.mode == VT_PROCESS) { in complete_change_console()
1166 * Send the signal as privileged - kill_pid() will in complete_change_console()
1170 if (kill_pid(vc->vt_pid, vc->vt_mode.acqsig, 1) != 0) { in complete_change_console()
1174 * to KD_TEXT mode. I'm not sure if this is strictly correct in complete_change_console()
1182 if (old_vc_mode != vc->vc_mode) { in complete_change_console()
1183 if (vc->vc_mode == KD_TEXT) in complete_change_console()
1194 vt_event_post(VT_EVENT_SWITCH, old, vc->vc_num); in complete_change_console()
1199 * Performs the front-end of a vt switch
1205 if (!new_vc || new_vc->vc_num == fg_console || vt_dont_switch) in change_console()
1209 * If this vt is in process mode, then we need to handshake with in change_console()
1215 * If it doesn't, we reset this vt to auto mode and continue. in change_console()
1220 * the user waits just the right amount of time :-) and revert the in change_console()
1224 if (vc->vt_mode.mode == VT_PROCESS) { in change_console()
1226 * Send the signal as privileged - kill_pid() will in change_console()
1233 vc->vt_newvt = new_vc->vc_num; in change_console()
1234 if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) { in change_console()
1246 * to KD_TEXT mode. I'm not sure if this is strictly correct in change_console()
1260 * Ignore all switches in KD_GRAPHICS+VT_AUTO mode in change_console()
1262 if (vc->vc_mode == KD_GRAPHICS) in change_console()
1277 /* Graphics mode - up to X */ in vt_move_to_console()
1288 return -ENOSPC; in vt_move_to_console()
1298 return -EIO; in vt_move_to_console()
1303 return -EINTR; in vt_move_to_console()