From alsa-devel-owner@alsa.jcu.cz  Sat Jun 27 14:48:10 1998
Received: from altrade.nijmegen.inter.nl.net (altrade.nijmegen.inter.nl.net [193.67.237.6])
	by marvin.jcu.cz (8.8.8/8.8.8) with ESMTP id OAA29328
	for <alsa-devel@jcu.cz>; Sat, 27 Jun 1998 14:47:40 +0200
Received: from obelix.fvdpol.inter.nl.net by altrade.nijmegen.inter.nl.net
	via bd99-0.Breda.NL.net [193.79.246.225] with ESMTP for <alsa-devel@jcu.cz>
	id OAA09076 (8.8.8/3.28); Sat, 27 Jun 1998 14:47:37 +0200 (MET DST)
Received: (from frank@localhost) by obelix.fvdpol.inter.nl.net (8.8.7/8.7.3) id NAA12598 for alsa-devel@jcu.cz; Sat, 27 Jun 1998 13:19:08 +0200
From: Frank van de Pol <F.K.W.van.de.Pol@inter.nl.net>
Message-Id: <199806271119.NAA12598@obelix.fvdpol.inter.nl.net>
Subject: displaying alsa proc entries
To: alsa-devel@jcu.cz (alsa)
Date: Sat, 27 Jun 1998 13:19:07 +0200 (MET DST)
Content-Type: text
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list


I found some peculiar behaviour when displaying the proc entries from alsa
(/proc/sound/...) using the more utility. 

With cat /proc/sound/meminfo I get:

obelix:~/projects/alsa/test$ cat /proc/sound/meminfo 
Driver using 19 pages (77824 bytes) of kernel memory for data.

But with more I get:

obelix:~/projects/alsa/test$ more /proc/sound/meminfo 
es) of kernel memory for data.

Other files (and linux proc entries) do not show this behaviour (eg.
/proc/interrupts)

I used strace to see what difference there is in the calls used by cat vs.
more, and found that the more utility performs a lseek(fd, 0, SEEK_SET) on
the proc file. Strace show that the ALSA proc entries return -1 ENXIO (No
such device or address) on this lseek.

Is there a reason for not supporting lseek on proc entries of type
SND_INFO_ENTRY_TEXT? Otherwise next patch might solve the problem:



--- kernel/info.c.0.1.3	Sat Jun 13 17:19:38 1998
+++ kernel/info.c	Sat Jun 27 13:13:10 1998
@@ -23,6 +23,7 @@
 #include "minors.h"
 #include "info.h"
 #include "sndpersist.h"
+#include <stdio.h>
 #include <stdarg.h>
 
 #ifndef CONFIG_PROC_FS
@@ -363,9 +364,23 @@
   data = (struct snd_info_private_data *)file -> private_data;
   if ( !data ) return -EIO;
   entry = data -> entry;
-  if ( entry -> type == SND_INFO_ENTRY_DATA ) {
-    if ( entry -> t.data.lseek )
-      return entry -> t.data.lseek( entry -> private_data, data -> file_private_data, offset, orig );
+  switch ( entry -> type) {
+    case SND_INFO_ENTRY_DATA:
+      if ( entry -> t.data.lseek )
+        return entry -> t.data.lseek( entry -> private_data, data -> file_private_data, offset, orig );
+      break;
+    case SND_INFO_ENTRY_TEXT:
+      switch (orig) {
+        case SEEK_SET:
+          file->f_pos = offset;
+          return file->f_pos;
+        case SEEK_CUR:
+          file->f_pos += offset;
+          return file->f_pos;
+        case SEEK_END:
+        default:
+          return -EINVAL;
+      }
   }
   return -ENXIO;
 }



Regards,
Frank.


+---- --- -- -  -   -    - 
|Frank van de Pol                  -o)
|F.K.W.van.de.Pol@inter.NL.net     /\\
|                                 _\_v
|Linux - Why use Windows, since there is a door?

