Skip to content

Commit 8026eb8

Browse files
maciej-w-rozyckigregkh
authored andcommitted
vt_ioctl: Revert VT_RESIZEX parameter handling removal
commit a90c275 upstream. Revert the removal of code handling extra VT_RESIZEX ioctl's parameters beyond those that VT_RESIZE supports, fixing a functional regression causing `svgatextmode' not to resize the VT anymore. As a consequence of the reverted change when the video adapter is reprogrammed from the original say 80x25 text mode using a 9x16 character cell (720x400 pixel resolution) to say 80x37 text mode and the same character cell (720x592 pixel resolution), the VT geometry does not get updated and only upper two thirds of the screen are used for the VT, and the lower part remains blank. The proportions change according to text mode geometries chosen. Revert the change verbatim then, bringing back previous VT resizing. Signed-off-by: Maciej W. Rozycki <[email protected]> Fixes: 988d076 ("vt_ioctl: make VT_RESIZEX behave like VT_RESIZE") Cc: [email protected] # v5.10+ Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a3de468 commit 8026eb8

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

drivers/tty/vt/vt_ioctl.c

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -771,21 +771,58 @@ static int vt_resizex(struct vc_data *vc, struct vt_consize __user *cs)
771771
if (copy_from_user(&v, cs, sizeof(struct vt_consize)))
772772
return -EFAULT;
773773

774-
if (v.v_vlin)
775-
pr_info_once("\"struct vt_consize\"->v_vlin is ignored. Please report if you need this.\n");
776-
if (v.v_clin)
777-
pr_info_once("\"struct vt_consize\"->v_clin is ignored. Please report if you need this.\n");
774+
/* FIXME: Should check the copies properly */
775+
if (!v.v_vlin)
776+
v.v_vlin = vc->vc_scan_lines;
777+
778+
if (v.v_clin) {
779+
int rows = v.v_vlin / v.v_clin;
780+
if (v.v_rows != rows) {
781+
if (v.v_rows) /* Parameters don't add up */
782+
return -EINVAL;
783+
v.v_rows = rows;
784+
}
785+
}
786+
787+
if (v.v_vcol && v.v_ccol) {
788+
int cols = v.v_vcol / v.v_ccol;
789+
if (v.v_cols != cols) {
790+
if (v.v_cols)
791+
return -EINVAL;
792+
v.v_cols = cols;
793+
}
794+
}
795+
796+
if (v.v_clin > 32)
797+
return -EINVAL;
778798

779-
console_lock();
780799
for (i = 0; i < MAX_NR_CONSOLES; i++) {
781-
vc = vc_cons[i].d;
800+
struct vc_data *vcp;
782801

783-
if (vc) {
784-
vc->vc_resize_user = 1;
785-
vc_resize(vc, v.v_cols, v.v_rows);
802+
if (!vc_cons[i].d)
803+
continue;
804+
console_lock();
805+
vcp = vc_cons[i].d;
806+
if (vcp) {
807+
int ret;
808+
int save_scan_lines = vcp->vc_scan_lines;
809+
int save_font_height = vcp->vc_font.height;
810+
811+
if (v.v_vlin)
812+
vcp->vc_scan_lines = v.v_vlin;
813+
if (v.v_clin)
814+
vcp->vc_font.height = v.v_clin;
815+
vcp->vc_resize_user = 1;
816+
ret = vc_resize(vcp, v.v_cols, v.v_rows);
817+
if (ret) {
818+
vcp->vc_scan_lines = save_scan_lines;
819+
vcp->vc_font.height = save_font_height;
820+
console_unlock();
821+
return ret;
822+
}
786823
}
824+
console_unlock();
787825
}
788-
console_unlock();
789826

790827
return 0;
791828
}

0 commit comments

Comments
 (0)