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. Pseudo-working.

diff -Naur ofbis-0.1.1/fbtst.c ofbis-0.1.1-pseudoworking/fbtst.c
--- ofbis-0.1.1/fbtst.c	2000-02-17 15:39:34.000000000 +0100
+++ ofbis-0.1.1-pseudoworking/fbtst.c	2003-04-16 21:17:58.000000000 +0200
@@ -65,7 +65,7 @@
 #define FB_OPT FB_OPEN_NEW_VC | FB_NO_KBD
 #endif
 
-  if ((f=FBopen(NULL,FB_OPT /*FB_KEEP_CURRENT_VC*/))==NULL) {
+  if ((f=FBopen(NULL,/*FB_OPT*/ FB_KEEP_CURRENT_VC))==NULL) {
     printf("FBinit f failed");
   }
 
diff -Naur ofbis-0.1.1/src/mouse.c ofbis-0.1.1-pseudoworking/src/mouse.c
--- ofbis-0.1.1/src/mouse.c	2000-02-17 15:39:36.000000000 +0100
+++ ofbis-0.1.1-pseudoworking/src/mouse.c	2003-04-16 21:17:58.000000000 +0200
@@ -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/open.c ofbis-0.1.1-pseudoworking/src/open.c
--- ofbis-0.1.1/src/open.c	2000-02-17 15:39:36.000000000 +0100
+++ ofbis-0.1.1-pseudoworking/src/open.c	2003-04-16 21:17:58.000000000 +0200
@@ -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-pseudoworking/src/vt.c
--- ofbis-0.1.1/src/vt.c	2000-02-17 15:39:36.000000000 +0100
+++ ofbis-0.1.1-pseudoworking/src/vt.c	2003-04-16 22:39:14.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 */
 
@@ -94,29 +95,37 @@
   do
   {
     (void) sprintf( ttynam, ttyfmts[i++], f->ttyno );
+    chown( ttynam, getuid(), getgid() );
   }
   while ( ( ttyfmts[i] != NULL ) &&
-          ( f->tty = open( ttynam, O_RDONLY )) == -1 );
+           access( ttynam, R_OK | W_OK ) == -1 );
 
-  if ( f->tty == -1 )
+/*  if ( f->tty == -1 )
   {
     FBerror( FATAL | SYSERR, "FBVTopen: failed to open %s", ttynam);
-  }
+  }*/
 
   /* junk from Xserver... clean up later */
 
-  /*if (!f->keeptty)
+  /*  if (!f->keeptty)
     {
     setpgrp();
     }
-    chown(ttynam,getuid(),getgid());
+    chown( ttynam, getuid(), getgid() );
     chown("/dev/console",getuid(),getgid());
     chown("/dev/tty0",getuid(),getgid());*/
 
+  close( 0 );
+  close( 1 );
+  close( 2 );
+  setsid();
+  f->tty = open( ttynam, O_RDWR );
+  dup( 0 );
+  dup( 0 );
+
   /* 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)
@@ -127,6 +136,7 @@
       /*setsid();*/
       /*ioctl(f->tty,TIOCSCTTY);*/
     }
+#endif
 
   /* Get current VT number so we can switch back to it later */
 
@@ -176,9 +186,15 @@
     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);
@@ -316,7 +332,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 +340,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,10 +403,10 @@
 
   /* 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 */
 
