Subject: Linux-Admin Digest #146
From: Digestifier <[email-masked]>
To: [email-masked]
Date: Wed, 5 Oct 94 05:13:36 EDT

Linux-Admin Digest #146, Volume #2                Wed, 5 Oct 94 05:13:36 EDT

Contents:
  Re: LINUX mouse problem (Andrew Haylett)
  How to let normal users run SVGALIB programs (SOLN) (Andrew Berkley)
  /etc/issue (CVL staff member Nate Sammons)
  Re: inetd seems to lock-up (Matt Midboe)
  Ugidd (Jay Ongg)
  Re: floppy problems on Linux 1.1.51 (Uwe Bonnes)
  Re: Xfig (Uwe Bonnes)
  Re: Hard Drive "sleep" program?? (Uwe Bonnes)
  Re: LINUX mouse problem (Van Zandt)

----------------------------------------------------------------------------

From: [email-masked] (Andrew Haylett)
Subject: Re: LINUX mouse problem
Date: 4 Oct 94 12:47:11 GMT

Stephen Benson ([email-masked]) wrote:
: In article <[email-masked]>, S. O'Connor ([email-masked]) writes:
: >[email-masked] (Ruz) writes:
: >
: >>Howdy, I am setting up a Linux network for a system administration class
: >>and have run into a problem.  The mouse gives me an error saying device or
: >>resource busy!!!!  This means I cannot run X and finish the system.
: >
: >       Do you get this message when you try to start X? You will if 
: >Selection is running. Selection makes the mouse work in Linux, but you 
: >have to kill it to run X. 
: This is not true. I run Selection all the time; in or out of X. And it doesn't
: "make the mouse work"; it provides 'cut and paste' style copying between VTs. 

Just to clear things up; selection will yield the mouse to X when
necessary with serial mice *only*. With bus mice, the device cannot be
shared in the same way, and selection must be terminated before X is
started. The only good news is that you can now do this easily using the
`-k' option in version 1.7.

--
Andrew Haylett <[email-masked]>              Tel: +44 1245 473331 x.3283
PGP2.6 public key available on request

------------------------------

From: [email-masked] (Andrew Berkley)
Subject: How to let normal users run SVGALIB programs (SOLN)
Date: 3 Oct 1994 10:37:49 -0400

Obviously, the only users that you would want to run SVGALIB programs
are logged in at the console -- and that is nicely handled by SVGALIB
(try running sasteroids from a telnet :).  But, since SVGALIB needs access
to /dev/console (new versions) which is a link to a tty0-6, you need
someway of letting it access them.  One solution is to make tty? world
readable/writeable/etc, but that's just wrong...  The real solution, which
most SVGALIB install programs do (witness zgv) is to install the program
with owner _root_, and set the 'Run this program as owner' bit on the
program.
chmod a+s FileName

------------------------------

From: [email-masked] (CVL staff member Nate Sammons)
Subject: /etc/issue
Date: 3 Oct 1994 14:20:17 GMT

I see there's and /etc/issue file in linux, but it doesn't seem to
do what /etc/issue is supposed to do (get splatted up on screen
BEFORE the login prompt on (at least) remote connections)

Is there a flag for this or something?

-nate

--
                   Nate Sammons <[email-masked]>
        System Administrator - CSU Computer Visualization Laboratory

------------------------------

From: [email-masked] (Matt Midboe)
Subject: Re: inetd seems to lock-up
Date: 4 Oct 1994 12:47:54 -0500

In article <[email-masked]>,
Steve Kneizys <[email-masked]> wrote:
>olav woelfelschneider ([email-masked]) wrote:
[stuff about inetd not running processes anymore, but net connects on
non-inetd ports still work]

We have the exact same problem here. A 1.1.51 kernel (but it did it
with earlier kernels). The sum on my inetd is 63545    18. Is that
same as everyone elses? Two IDE hard drives, 500M and 330M, with a
486DX2-66 processor. They usually seem to come along with a whole
bunch of named: connection refused or tcpd: application returned 0xe
errors. (Or errors to that effect) 

Any solutions to this are desperately wanted!

Matt
[email-masked]

------------------------------

From: [email-masked] (Jay Ongg)
Subject: Ugidd
Date: 5 Oct 1994 08:45:35 GMT

Where can i find information on how to use ugidd, or the binaries to 
unfsd, and/or man pages!?

I've looked everywhere, can't find it, not even on the man pages of
machines of other platforms.
Can someone help me out here?
Thanks!

------------------------------

From: [email-masked] (Uwe Bonnes)
Subject: Re: floppy problems on Linux 1.1.51
Date: Wed, 5 Oct 1994 06:10:59 GMT

Shaune Beattie ([email-masked]) wrote:
> Kees Lemmens ([email-masked]) wrote:
> : Hi,

> : Recently installed Linux 1.1.51. However, when I mount a DOS floppy
> : and try to unmount it when finished, in about 50 % of the cases the
> : unmount command crashes with a Segmentation Fault and exits.
> : This leaves an /etc/mtab~ hanging around and corrupts the filesystem
> : information:

> : 'df' then yields an entry for /fd0 (my floppydrive) with the statistics
> : of my Linux partition.

> : A second mount and unmount (after removing the /etc/mtab~) often fixes 
> : the problem.

> : Anyone who experienced the same or anyone who knows how to avoid this ?

> Same for me..
> Though not 50%
> Basically the *first* time you try to umount it produces a segmentation 
> fault in _release_floppy. after that it works fine :-/ more a nuisance 
> than anything else.

Look at the patches om
ftp.imag.fr:pub/Linux/ZLIBC.

 The newest (floppy related) files are:
 pub/Linux/ZLIBC/floppy/ALPHA/fdp1.1.51-0410.diff.gz (alpha fixes with new
features)
 pub/Linux/ZLIBC/floppy/QDF/fdp1.1.51-0410.diff.gz (quick&dirty fixes with
lower probability of new bugs)
 pub/Linux/ZLIBC/floppy/misc/dma0410.diff.gz (newest dma patches)
 pub/Linux/ZLIBC/fdutils/ALPHA/fdu0110.taz (utilities) 
-- 
Uwe Bonnes  [email-masked]

------------------------------

From: [email-masked] (Uwe Bonnes)
Subject: Re: Xfig
Date: Wed, 5 Oct 1994 06:11:05 GMT

dietmar mueller ([email-masked]) wrote:
> A friend of mine has installed Linux V.1.0.9. 
> His problem appears while starting Xfig. On loading the program the whole
> Main Memory is allocated for the needs of swapping until the lower bound of
> 80 K is reached, without starting Xfig. The Failure Message : "Font Type
> ... not found" is being displayed and because of the lack of memory space
> the Xserver shuts down with error message.

> Does anyone have an idea why this can happen and how this phenomen can be
> prevented?
Look at the messages of the last time. This has been answered many times
before:
There's a cyclic reference in the application-defaults

-- 
Uwe Bonnes  [email-masked]

------------------------------

From: [email-masked] (Uwe Bonnes)
Subject: Re: Hard Drive "sleep" program??
Date: Wed, 5 Oct 1994 06:11:14 GMT

Tom Czarnik ([email-masked]) wrote:
> In article <[email-masked]>,
> >     [email-masked] (Emarit Ranu) says:
> >
> >
> >        I have a linux box that can be idle up to 12 hours at a time.
> >        I figure since the hard drive is not doing much, is there
> >        a program that will shut off the hard drive until it is needed
> >        again?

> A HD "starts" as soon as you turn on the computer or the actaul HD (if it's
> an external). There is no way to turn off the power unless you unplug the
> HD.
Not true for SCSI-HD's:
From a posting in comp.os.linux.development:

Newsgroups: comp.os.linux.development
Lines: 380
Sender: [email-masked]
Subject: Power down idle SCSI disks [w/ kernel patches]
Date: Wed, 14 Sep 1994 23:04:41 GMT
Status: RO

I recently asked if anybody had written any code for turning off SCSI or 
IDE drives under linux. Since it seems as if nobody had done it, I
gave it a shot myself. And here it is, the result of a few nights 
hacking of the SCSI drivers.

Hopefully the kernel patches will turn off a drive after a certain amount
of time, and if I am really lucky, it might even turn it on when some
program needs it.

The patch should be applied from the /usr/src/linux/drivers directory, 
and it patches sd.c, sd.h and sd_ioctl.c to power down idle disks.
Idling is disabled by default and has to be turned on by an ioctl call.
I'm quite new to kernel hacking, so if I've made any horrible misstakes
I would like to hear about them.

Attached is also a small utility which sets the idle timeout on a SCSI device. 
It ain't beautiful but it seems to work. The BLKIDLE define is hardcoded 
to 4747 both here and in the kernel (sd_ioctl.c). It really belongs in 
one of the include files in /usr/include/linux, but I don't know which 
one, so I haven't fixed it yet.

Please try it out and tell me how it works.

  /Christer ([email-masked])

#include <stdio.h>
#include <stdlib.h>

#include <fcntl.h>
#include <sys/ioctl.h>

#define BLKIDLE 4747

void main(int argc, char *argv[])
{
  int fd;
  int timeout;

  if (argc != 3)
  {
    fprintf(stderr, "usage: setidle device timeout\n"
                   "  where timeout is the time until motor off in seconds\n"
                   "  a value of zero disables this function\n");
    exit(1);
  }

  if ((fd = open(argv[1], O_RDWR)) < 0)
  {
    perror(argv[1]);
    exit(1);
  }

  timeout = atoi(argv[2]);
  printf("Setting idle timeout of %s to %d seconds\n", argv[1], timeout);
  ioctl(fd, BLKIDLE, &timeout);

  close(fd);

  exit(0);
}
diff -u5 -r scsi.orig/sd.c scsi/sd.c
--- scsi.orig/sd.c      Tue Sep 13 21:20:15 1994
+++ scsi/sd.c   Wed Sep 14 20:46:02 1994
@@ -14,10 +14,11 @@
 #include <linux/fs.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/errno.h>
+#include <linux/timer.h>
 #include <asm/system.h>
 
 #define MAJOR_NR SCSI_DISK_MAJOR
 #include "../block/blk.h"
 #include "scsi.h"
@@ -45,10 +46,13 @@
                            SC->device->type != TYPE_MOD)
 
 struct hd_struct * sd;
 
 Scsi_Disk * rscsi_disks;
+
+struct timer_list *sd_idle_timer;         /* timer for idling disks */
+
 static int * sd_sizes;
 static int * sd_blocksizes;
 
 extern int sd_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
 
@@ -137,10 +141,111 @@
        0,              /* number */
        NULL,   /* internal */
        NULL            /* next */
 };
 
+static void sd_start_done (Scsi_Cmnd * SCpnt)
+{
+  struct request * req;
+
+  req = &SCpnt->request;
+  req->dev = 0xfffe; /* Busy, but indicate request done */
+
+  if (req->sem != NULL) {
+    up(req->sem);
+  }
+}
+
+static int sd_start (Scsi_Cmnd * SCpnt, int dev)
+{
+  char cmd[12];
+  int old_dev = SCpnt->request.dev;
+
+#ifdef DEBUG
+  printk("sd%c : sd_start entered\n", 'a' + dev);
+#endif
+
+  cmd[0] = START_STOP;
+  cmd[1] = (rscsi_disks[dev].device->lun << 5);
+  cmd[2] = cmd[3] = cmd[5] = 0;
+  cmd[4] = 1;
+
+  SCpnt->request.dev = 0xffff;  /* Mark as really busy again */
+
+  scsi_do_cmd(SCpnt,  cmd, NULL,  0,
+              sd_start_done,  10 * 100, /* give it some time to start */
+              MAX_RETRIES);
+
+  while(SCpnt->request.dev != 0xfffe)
+    schedule();
+
+  SCpnt->request.dev = old_dev;
+
+  return SCpnt->result;
+}
+
+static void sd_stop_done (Scsi_Cmnd * SCpnt)
+{
+  struct request * req;
+
+  req = &SCpnt->request;
+  req->dev = 0xfffe; /* Busy, but indicate request done */
+
+  if (req->sem != NULL) {
+    up(req->sem);
+  }
+
+  SCpnt->request.dev = -1; /* Deallocate */
+  wake_up(&SCpnt->device->device_wait);
+}
+
+static void sd_stop (unsigned long nr)
+{
+  int dev = nr;
+  Scsi_Cmnd * SCpnt = NULL;
+  char cmd[12];
+
+#ifdef DEBUG
+  printk("sd%c: sd_stop entered\n", 'a' + dev);
+#endif
+
+  cli();
+
+  del_timer(&sd_idle_timer[dev]);              /* remove timer from list */
+
+  SCpnt = allocate_device(NULL, rscsi_disks[dev].device, 1);
+  if (SCpnt == NULL)
+  {
+    /* Could not allocate device so try again in a little while */
+    sd_idle_timer[dev].expires = HZ * 5; 
+    add_timer(&sd_idle_timer[dev]);
+    sti();
+#ifdef DEBUG
+    printk("sd%c : sd_stop could not allocate device\n", 'a' + dev);
+#endif
+    return;
+  }
+
+  sti();
+
+  cmd[0] = START_STOP;
+  cmd[1] = (rscsi_disks[dev].device->lun << 5) | 1;
+  cmd[2] = cmd[3] = cmd[5] = 0;
+  cmd[4] = 0;
+
+  SCpnt->request.dev = 0xffff;  /* Mark as really busy again */
+
+  scsi_do_cmd(SCpnt,  cmd, NULL,  0,
+              sd_stop_done,  SD_TIMEOUT,
+              MAX_RETRIES);
+
+#ifdef DEBUG
+  printk("sd%c : drive has been stopped\n", 'a' + dev);
+#endif
+  rscsi_disks[dev].stopped = 1;
+}
+
 static void sd_geninit (void)
 {
        int i;
 
        for (i = 0; i < sd_template.dev_max; ++i)
@@ -438,10 +543,41 @@
                /* printk("SCSI disk has been changed.  Prohibiting further I/O.\n");   */
                end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
                goto repeat;
                }
 
+        /*
+         * Attempt to restart drive
+         */
+        if (rscsi_disks[dev].stopped)
+        {
+          int status;
+
+#ifdef DEBUG
+          printk("sd%c : starting drive\n", 'a' + dev);
+#endif
+          if ((status = sd_start(SCpnt, dev)) != 0)
+          {
+            printk("sd%c : restart failed, status = %x.\n", 'a' + dev, status);
+
+            end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
+            goto repeat;
+          }
+
+          rscsi_disks[dev].stopped = 0;
+        }
+
+       /* restart the idle timer */
+       cli();
+       del_timer(&sd_idle_timer[dev]);
+        if (rscsi_disks[dev].idle_timeout != 0)
+        {
+         sd_idle_timer[dev].expires = rscsi_disks[dev].idle_timeout;
+         add_timer(&sd_idle_timer[dev]);
+        }
+       sti();
+
 #ifdef DEBUG
        printk("sd%c : real dev = /dev/sd%c, block = %d\n", 'a' + MINOR(SCpnt->request.dev), dev, block);
 #endif
 
        switch (SCpnt->request.cmd)
@@ -980,10 +1116,15 @@
     }
 
   rscsi_disks[i].ten = 1;
   rscsi_disks[i].remap = 1;
   scsi_free(buffer, 512);
+
+  /* Set up flags and timeout for turning off idle drives - Wingel */
+  rscsi_disks[i].stopped = 0;
+  rscsi_disks[i].idle_timeout = 0;                     /* disabled */
+
   return i;
 }
 
 /*
        The sd_init() function looks at all SCSI drives present, determines
@@ -1012,10 +1153,21 @@
        sd_template.dev_max = sd_template.dev_noticed;
 
        rscsi_disks = (Scsi_Disk *) 
          scsi_init_malloc(sd_template.dev_max * sizeof(Scsi_Disk));
        memset(rscsi_disks, 0, sd_template.dev_max * sizeof(Scsi_Disk));
+
+       /* Allocate and initialize idle timers, do not activate them - Wingel */
+       sd_idle_timer = (struct timer_list *) 
+         scsi_init_malloc(sd_template.dev_max * sizeof(struct timer_list));
+       for (i = 0; i < sd_template.dev_max; i++)
+       {
+         init_timer(&sd_idle_timer[i]);
+         sd_idle_timer[i].expires = 0;
+         sd_idle_timer[i].data = i;
+         sd_idle_timer[i].function = sd_stop;
+       }
 
        sd_sizes = (int *) scsi_init_malloc((sd_template.dev_max << 4) * 
                                            sizeof(int));
        memset(sd_sizes, 0, (sd_template.dev_max << 4) * sizeof(int));
 
diff -u5 -r scsi.orig/sd.h scsi/sd.h
--- scsi.orig/sd.h      Tue Sep 13 21:26:10 1994
+++ scsi/sd.h   Wed Sep 14 16:38:26 1994
@@ -37,10 +37,14 @@
                Scsi_Device  *device;           
                unsigned char sector_bit_size;  /* sector_size = 2 to the  bit size power */
                unsigned char sector_bit_shift; /* power of 2 sectors per FS block */
                unsigned ten:1;                 /* support ten byte read / write */
                unsigned remap:1;               /* support remapping  */
+               unsigned stopped:1;
+               unsigned long idle_timeout;     /* idle time before turning off drive */
                } Scsi_Disk;
        
 extern Scsi_Disk * rscsi_disks;
+
+extern struct timer_list *sd_idle_timer;               /* timer for idling disks */
 
 #endif
diff -u5 -r scsi.orig/sd_ioctl.c scsi/sd_ioctl.c
--- scsi.orig/sd_ioctl.c        Tue Sep 13 21:20:15 1994
+++ scsi/sd_ioctl.c     Wed Sep 14 19:47:15 1994
@@ -1,10 +1,11 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/fs.h>
 #include <linux/hdreg.h>
 #include <linux/errno.h>
+#include <linux/timer.h>
 
 #include <asm/segment.h>
 
 #include "../block/blk.h"
 #include "scsi.h"
@@ -19,10 +20,11 @@
        int dev = inode->i_rdev;
        int error;
        struct Scsi_Host * host;
        int diskinfo[4];
        struct hd_geometry *loc = (struct hd_geometry *) arg;
+       unsigned long timeout;
 
        switch (cmd) {
                case HDIO_REQ:   /* Return BIOS disk parameters */
                        if (!loc)  return -EINVAL;
                        error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
@@ -66,9 +68,52 @@
                        invalidate_buffers(inode->i_rdev);
                        return 0;
 
                case BLKRRPART: /* Re-read partition tables */
                        return revalidate_scsidisk(dev, 1);
+
+#define BLKIDLE 4747
+               case BLKIDLE: /* Idle disks after timeout */
+                       if (!arg)  return -EINVAL;
+                       error = verify_area(VERIFY_READ, (long *) arg, sizeof(long));
+                       if (error)
+                               return error;
+
+                       cli(); /* is this really neccesary? */
+                       del_timer(&sd_idle_timer[MINOR(dev) >> 4]);
+                       sti();
+
+                       timeout = get_fs_long((long *) arg);
+
+                       if (timeout != 0 && timeout < 15)
+                       {
+                         /* Be a bit over-protective */
+                         printk("sd%c : warning, idle timeout of %ld seconds is WAY to small\n", 
+                                'a' + (MINOR(dev) >> 4),
+                                timeout);
+                         timeout = 15;
+                       }
+
+                       rscsi_disks[MINOR(dev) >> 4].idle_timeout = timeout * HZ;
+                       if (rscsi_disks[MINOR(dev) >> 4].idle_timeout != 0)
+                       {
+#ifdef DEBUG
+                         printk("sd%c : idle timeout set to %ld jiffies\n", 
+                                'a' + (MINOR(dev) >> 4), 
+                                rscsi_disks[MINOR(dev) >> 4].idle_timeout);
+#endif
+                         sd_idle_timer[MINOR(dev) >> 4].expires = rscsi_disks[MINOR(dev) >> 4].idle_timeout;
+                         cli();
+                         add_timer(&sd_idle_timer[MINOR(dev) >> 4]);
+                         sti();
+                       }
+#ifdef DEBUG
+                       else
+                         printk("sd%c : idle timeout disabled\n", 
+                                'a' + (MINOR(dev) >> 4));
+#endif
+                       return 0;
+
                default:
                        return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
        }
 }

-- 
Uwe Bonnes  [email-masked]

------------------------------

From: [email-masked] (Van Zandt)
Subject: Re: LINUX mouse problem
Date: 4 Oct 1994 16:45:44 GMT

[email-masked] (Stephen Benson) writes:
> 
>In article <[email-masked]>, S. O'Connor ([email-masked]) writes:
>
>This is not true. I run Selection all the time; in or out of X. 

If you have a busmouse, you have to kill selection before starting X.
If you have a serial mouse, they don't conflict.  It's in the X386 FAQ.

                             - Jim Van Zandt

------------------------------

** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [email-masked]

You can send mail to the entire list (and comp.os.linux.admin) via:

    Internet: [email-masked]

Linux may be obtained via one of these FTP sites:
    nic.funet.fi				pub/OS/Linux
    tsx-11.mit.edu				pub/linux
    sunsite.unc.edu				pub/Linux

End of Linux-Admin Digest
******************************