Hi, This patch will lock the VT that is active just after splash is initialized and release it just before the splash system is stopped.
I haven't tested it extensively with bootsplash.org, but it seems to work with that (in vmware) too. Comments? Index: suspend.c =================================================================== RCS file: /cvsroot/suspend/suspend/suspend.c,v retrieving revision 1.52 diff -u -r1.52 suspend.c --- suspend.c 14 Sep 2006 14:18:58 -0000 1.52 +++ suspend.c 14 Sep 2006 20:48:53 -0000 @@ -25,6 +25,7 @@ #include <stdlib.h> #include <string.h> #include <errno.h> +#include <signal.h> #ifdef CONFIG_COMPRESS #include <lzf.h> #else @@ -66,6 +67,8 @@ static int suspend_swappiness = SUSPEND_SWAPPINESS; static struct splash splash; +static struct vt_mode orig_vtm; +static int vfd; static struct config_par parameters[PARAM_NO] = { { @@ -487,7 +490,7 @@ * write_image - Write entire image and metadata. */ -int write_image(int snapshot_fd, int resume_fd, int vt_no) +int write_image(int snapshot_fd, int resume_fd) { static struct swap_map_handle handle; struct swsusp_info *header = mem_pool; @@ -644,7 +647,7 @@ while(1); } -int suspend_system(int snapshot_fd, int resume_fd, int vt_fd, int vt_no) +int suspend_system(int snapshot_fd, int resume_fd) { loff_t avail_swap; unsigned long image_size; @@ -683,7 +686,7 @@ free_snapshot(snapshot_fd); break; } - error = write_image(snapshot_fd, resume_fd, vt_no); + error = write_image(snapshot_fd, resume_fd); if (!error) { splash.progress(100); #ifdef CONFIG_BOTH @@ -1027,6 +1030,75 @@ } #endif + +static void release_vt(int signo) +{ + printf("Ignoring request to release VT\n"); + ioctl(vfd, VT_RELDISP, 0); +} + +static void acquire_vt(int signo) +{ + printf("Ignoring request to acquire VT\n"); + ioctl(vfd, VT_RELDISP, VT_ACKACQ); +} + +static void unlock_vt(void) +{ + ioctl(vfd, VT_SETMODE, &orig_vtm); + close(vfd); +} + +static int lock_vt() +{ + struct sigaction sa; + struct vt_mode vtm; + struct vt_stat vtstat; + char *vt_name = mem_pool; + int fd, error; + + fd = console_fd("/dev/console"); + if (fd < 0) + return fd; + + error = ioctl(fd, VT_GETSTATE, &vtstat); + close(fd); + + if ( error < 0 ) + return -1; + + sprintf(vt_name, "/dev/tty%d", vtstat.v_active); + vfd = open(vt_name, O_RDWR); + if (vfd < 0) + return vfd; + + if (ioctl(vfd, VT_GETMODE, &vtm) < 0) + return -1; + + /* Setting vt mode to VT_PROCESS means this process + * will handle vt switching requests. + * We installed handlers for release and acquire requests. + */ + sigemptyset(&(sa.sa_mask)); + sa.sa_flags = SA_RESTART; + sa.sa_handler = release_vt; + sigaction(SIGUSR1, &sa, NULL); + sa.sa_handler = acquire_vt; + sigaction(SIGUSR2, &sa, NULL); + + orig_vtm = vtm; + vtm.mode = VT_PROCESS; + vtm.relsig = SIGUSR1; + vtm.acqsig = SIGUSR2; + if (ioctl(vfd, VT_SETMODE, &vtm) < 0) + return -1; + + printf("Locked against VT switching\n"); + return 0; +} + + + int main(int argc, char *argv[]) { unsigned int mem_size; @@ -1161,6 +1233,9 @@ splash_prepare(&splash, splash_param); + if (lock_vt() < 0) + goto Restore_console; + splash.progress(5); #ifdef CONFIG_BOTH @@ -1187,7 +1262,7 @@ if (!s2ram && chroot(chroot_path)) { ret = errno; fprintf(stderr, "suspend: Could not chroot to %s\n", chroot_path); - goto Restore_console; + goto Unlock_vt; } chdir("/"); @@ -1195,7 +1270,7 @@ splash.progress(10); - ret = suspend_system(snapshot_fd, resume_fd, vt_fd, suspend_vc); + ret = suspend_system(snapshot_fd, resume_fd); if (orig_loglevel >= 0) set_kernel_console_loglevel(orig_loglevel); @@ -1205,6 +1280,8 @@
signature.asc
Description: PGP signature
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Suspend-devel mailing list Suspend-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/suspend-devel