Package: ofbis
Version: 0.1.1
Author: Guillem Jover <guillem@hadrons.org>
Status: obsolete
Description:
 XXX[another-aproach]: Allow non-root users to use the lib. API change.

diff -Naur ofbis-0.1.1/src/mouse.c ofbis-0.1.1-patched/src/mouse.c
--- ofbis-0.1.1/src/mouse.c	2000-02-17 15:39:36.000000000 +0100
+++ ofbis-0.1.1-patched/src/mouse.c	2003-01-25 17:07:52.000000000 +0100
@@ -35,10 +35,10 @@
   }
 
   devtype = DEV_TYPE_GPMDATA;
-  if ( ( msefd = open ( GPMDATADEVICE, O_RDWR | O_NDELAY )) == -1 ) {
+  if ( ( msefd = open ( GPMDATADEVICE, O_RDONLY | O_NDELAY )) == -1 ) {
     devtype = DEV_TYPE_MOUSE;
     fprintf (stderr, "FBmouseopen: Error opening /dev/gpmdata, trying /dev/mouse\n");
-    if ( ( msefd = open ( MOUSEDEVICE, O_RDWR | O_NDELAY )) == -1 ) {
+    if ( ( msefd = open ( MOUSEDEVICE, O_RDONLY | O_NDELAY )) == -1 ) {
       devtype = DEV_TYPE_NONE;
       fprintf (stderr, "FBmouseopen: Error opening /dev/mouse\n");
       return;
diff -Naur ofbis-0.1.1/src/ofbis.h ofbis-0.1.1-patched/src/ofbis.h
--- ofbis-0.1.1/src/ofbis.h	2000-02-17 15:39:36.000000000 +0100
+++ ofbis-0.1.1-patched/src/ofbis.h	2003-04-16 15:52:34.000000000 +0200
@@ -75,6 +75,7 @@
 struct fbinf
 {
   int                      fb;             /* fb file descriptor */
+  int                      tty0;           /* tty0 file desc. */
   int                      tty;            /* tty file desc. */
   int                      ttyno;          /* VT number */
   unsigned short           vtchoice;       /* Current VT or new one? */
diff -Naur ofbis-0.1.1/src/open.c ofbis-0.1.1-patched/src/open.c
--- ofbis-0.1.1/src/open.c	2000-02-17 15:39:36.000000000 +0100
+++ ofbis-0.1.1-patched/src/open.c	2003-01-21 06:06:07.000000000 +0100
@@ -32,7 +32,10 @@
     
     fbname = getenv("FRAMEBUFFER");
     if ( !fbname ) {
-      fbname = "/dev/fb0";
+      if ( access("/dev/.devfsd", F_OK) == 0 )  /* devfs detected */
+	fbname = "/dev/fb/0";
+      else
+	fbname = "/dev/fb0";
     }
   }
 
diff -Naur ofbis-0.1.1/src/vt.c ofbis-0.1.1-patched/src/vt.c
--- ofbis-0.1.1/src/vt.c	2000-02-17 15:39:36.000000000 +0100
+++ ofbis-0.1.1-patched/src/vt.c	2003-04-16 16:32:39.000000000 +0200
@@ -19,10 +19,11 @@
 
 #include "list.h"
 
-static  char            *ttynames[]={"/dev/tty0", "/dev/tty", NULL};
-static  char            *ttyfmts[]={"/dev/tty%d", "/dev/tty%02x", "/dev/tty%x", "/dev/tty%02d", NULL};
+static  char            *ttynames[]={"/dev/vc/0", "/dev/tty0", "/dev/tty", NULL};
+static  char            *ttyfmts[]={"/dev/vc/%d", "/dev/tty%d", "/dev/tty%02x", "/dev/tty%x", "/dev/tty%02d", NULL};
 static  int             cttyname = 0;
 static  int             originaltty;
+static  int             kd_mode;
 static  struct vt_mode  vtm;
 /*static*/      unsigned short  switching;              /* Flag to prevent reentrancy */
 
@@ -40,7 +41,9 @@
 
   /* Open current console */
 
-  while ( ( f->tty = open( ttynames[cttyname], O_WRONLY ) ) == -1 )
+  setsid();
+
+  while ( ( f->tty0 = open( ttynames[cttyname], O_WRONLY ) ) == -1 )
   {
     FBerror( WARNING | SYSERR, "FBVTopen: open failed on %s",
              ttynames[cttyname]);
@@ -55,100 +58,66 @@
     }
   }
 
-  if ( f->vtchoice == FB_KEEP_CURRENT_VC )
+  /* Get current VT number so we can switch back to it later */
+
+  if ( ioctl( f->tty0, VT_GETSTATE, &vts ) == -1 )
   {
-    /* Get current VT number so we can switch back to it later */
+    FBerror( FATAL | SYSERR, "FBVTopen: couldn't get VT state");
+  }
+  originaltty = vts.v_active;
 
-    if ( ioctl( f->tty, VT_GETSTATE, &vts ) == -1 )
-    {
-      FBerror( FATAL | SYSERR, "FBVTopen: couldn't get VT state");
-    }
-    f->ttyno = vts.v_active;
+  if ( f->vtchoice == FB_KEEP_CURRENT_VC )
+  {
+    f->tty = f->tty0;
+    f->ttyno = originaltty;
     f->keeptty = TRUE;
   }
   else if ( f->vtchoice == FB_OPEN_NEW_VC )
   {
     /* Get number of free VT */
 
-    if ( ioctl( f->tty, VT_OPENQRY, &f->ttyno ) == -1 )
+    if ( ioctl( f->tty0, VT_OPENQRY, &f->ttyno ) == -1 )
     {
       FBerror( FATAL | SYSERR, "FBVTopen: no free ttys");
     }
     f->keeptty = FALSE;
+
+    /* Switch to new VT */
+
+    if ( ioctl( f->tty0, VT_ACTIVATE, f->ttyno ) == -1 )
+    {
+      FBerror( FATAL | SYSERR, "FBVTopen: couldn't switch to VT %d", f->ttyno);
+    }
+
+    /* Wait for new VT to become active */
+
+    if ( ioctl( f->tty0, VT_WAITACTIVE, f->ttyno ) == -1 )
+    {
+      FBerror( FATAL | SYSERR, "FBVTopen: VT %d didn't become active", f->ttyno);
+    }
   }
   else
   {
     FBerror( FATAL | SYSERR, "FBVTopen: please pass correct options!" );
   }
 
-  /* Close current console */
-
-  if ( close( f->tty ) == -1 )
-  {
-    FBerror( WARNING | SYSERR, "FBVTopen: failed to close %s",
-             ttynames[cttyname]);
-  }
-
   /* Open new VT */
 
-  do
+  while ( ttyfmts[i] != NULL )
   {
     (void) sprintf( ttynam, ttyfmts[i++], f->ttyno );
-  }
-  while ( ( ttyfmts[i] != NULL ) &&
-          ( f->tty = open( ttynam, O_RDONLY )) == -1 );
-
-  if ( f->tty == -1 )
-  {
-    FBerror( FATAL | SYSERR, "FBVTopen: failed to open %s", ttynam);
-  }
-
-  /* junk from Xserver... clean up later */
-
-  /*if (!f->keeptty)
+    f->tty = open( ttynam, O_RDWR );
+    if ( f->tty )
     {
-    setpgrp();
-    }
-    chown(ttynam,getuid(),getgid());
-    chown("/dev/console",getuid(),getgid());
-    chown("/dev/tty0",getuid(),getgid());*/
-
-  /* This seems necessary for us to do, but I'm still not sure why. */
-#if 0
-  if (f->keeptty)
-#endif
-    {
-      int i;
-      if ((i=open("/dev/tty",O_RDWR))>=0)
-	{
-	  ioctl(i,TIOCNOTTY,0);
-	  close(i);
-	}
-      /*setsid();*/
-      /*ioctl(f->tty,TIOCSCTTY);*/
+      break;
     }
-
-  /* Get current VT number so we can switch back to it later */
-
-  if ( ioctl( f->tty, VT_GETSTATE, &vts ) == -1 )
-  {
-    FBerror( FATAL | SYSERR, "FBVTopen: couldn't get VT state");
   }
-  originaltty = vts.v_active;
 
-  /* Switch to new VT */
-        
-  if ( ioctl( f->tty, VT_ACTIVATE, f->ttyno ) == -1 )
+  if ( f->tty == -1 )
   {
-    FBerror( FATAL | SYSERR, "FBVTopen: couldn't switch to VT %d", f->ttyno);
+    FBerror( FATAL | SYSERR, "FBVTopen: failed to open %s", ttynam);
   }
 
-  /* Wait for new VT to become active */
-
-  if ( ioctl( f->tty, VT_WAITACTIVE, f->ttyno ) == -1 )
-  {
-    FBerror( FATAL | SYSERR, "FBVTopen: VT %d didn't become active", f->ttyno);
-  }
   f->visible=TRUE;
   f->drawing=FALSE;
 
@@ -176,14 +145,28 @@
     FBerror( FATAL | SYSERR, "FBVTopen: Couldn't set mode of VT %d", f->ttyno);
   }
 
+  /* Save current keybard mode */
+
+  if ( ioctl( f->tty, KDGETMODE, &kd_mode ) == -1 )
+  {
+    FBerror( FATAL | SYSERR, "FBVTopen: Couldn't get keyboard mode on VT %d", f->ttyno);
+  }
+
   /* Disable cursor */
 
-        
   if ( ioctl( f->tty, KDSETMODE, KD_GRAPHICS ) == -1 )
   {
     FBerror( FATAL | SYSERR, "FBVTopen: Couldn't set keyboard graphics mode on VT %d", f->ttyno);
   }
 
+  if ( f->vtchoice == FB_OPEN_NEW_VC )
+  {
+    if ( ioctl( f->tty0, TIOCNOTTY, 0) == -1 )
+    {
+      FBerror( FATAL | SYSERR, "FBVTopen: Couldn't set keyboard TIOCNOTTY on VT %d", f->ttyno);
+    }
+  }
+
   /* Initialise tty list if not already done */
 
   if ( listinit == FALSE )
@@ -316,7 +299,7 @@
 
     if ( ioctl(f->tty, VT_RELDISP, 1) == -1 )
     {
-      FBerror( FATAL | SYSERR, "FBVTswitch: switch away from VT %d denied", f->tty);
+      FBerror( FATAL | SYSERR, "FBVTswitch: switch away from VT %d denied", f->ttyno);
     }
   }
   else
@@ -324,7 +307,7 @@
     /* Acknowledge switch back to this VT */
     if ( ioctl(f->tty, VT_RELDISP, VT_ACKACQ) == -1 )
     {
-      FBerror( FATAL | SYSERR, "FBVTswitch: switch to VT %d denied", f->tty);
+      FBerror( FATAL | SYSERR, "FBVTswitch: switch to VT %d denied", f->ttyno);
     }
 
     /* Map framebuffer back into memory */
@@ -387,9 +370,9 @@
 
   /* Enable cursor */
 
-  if ( ioctl( f->tty, KDSETMODE, KD_TEXT ) == -1 )
+  if ( ioctl( f->tty, KDSETMODE, kd_mode ) == -1 )
   {
-    FBerror( FATAL | SYSERR, "FBVTclose: Couldn't set keyboard graphics mode on VT %d", f->ttyno);
+    FBerror( FATAL | SYSERR, "FBVTclose: Couldn't restore keyboard mode on VT %d", f->tty);
   }
 
   /* Restore mode parameters */
@@ -403,33 +386,39 @@
     FBerror( FATAL | SYSERR, "FBVTclose: Couldn't set mode of VT %d", f->ttyno);
   }
 
-  /* Switch back to original VT */
-
-  if ( ioctl( f->tty, VT_ACTIVATE, originaltty ) == -1 )
-  {
-    FBerror( FATAL | SYSERR, "FBVTclose: couldn't switch to VT %d", originaltty);
-  }
-  if ( ioctl( f->tty, VT_WAITACTIVE, originaltty ) == -1 )
+  if ( f->vtchoice == FB_OPEN_NEW_VC )
   {
-    FBerror( FATAL | SYSERR, "FBVTclose: couldn't wait for VT %d", originaltty);
-  }
+    /* Switch back to original VT */
 
-#if 0
-  /* Deallocate VT if we opened a new one */
-  if(f->vtchoice == FB_OPEN_NEW_VC)
-    {  
-      if(ioctl(f->tty, VT_DISALLOCATE, f->ttyno) == -1 )
-	{
-	  FBerror( WARNING | SYSERR, "FBVTclose: couldn't deallocate VT %d", f->ttyno);
-	}
+    if ( ioctl( f->tty0, VT_ACTIVATE, originaltty ) == -1 )
+    {
+      FBerror( FATAL | SYSERR, "FBVTclose: couldn't switch to VT %d", originaltty);
+    }
+    if ( ioctl( f->tty0, VT_WAITACTIVE, originaltty ) == -1 )
+    {
+      FBerror( FATAL | SYSERR, "FBVTclose: couldn't wait for VT %d", originaltty);
+    }
+
+    /* Close VT */
+
+    if ( close( f->tty ) == -1 )
+    {
+      FBerror( FATAL | SYSERR, "FBVTclose: failed to close VT");
+    }
+
+    /* Deallocate VT if we opened a new one */
+
+    if(ioctl(f->tty0, VT_DISALLOCATE, f->ttyno) == -1 )
+    {
+      FBerror( WARNING | SYSERR, "FBVTclose: couldn't deallocate VT %d", f->ttyno);
     }
-#endif
+ }
 
-  /* Close VT */
+  /* Close VT0 */
 
-  if ( close( f->tty ) == -1 )
+  if ( close( f->tty0 ) == -1 )
   {
-    FBerror( FATAL | SYSERR, "FBVTclose: failed to close VT");
+    FBerror( FATAL | SYSERR, "FBVTclose: failed to close VT 0");
   }
 
   /* Remove from ttylist */
