Linux-Development-Sys Digest #600, Volume #8     Sat, 31 Mar 01 02:13:14 EST

Contents:
  Re: How to handle newline character(s) in a TCP server (Andrew Gierth)
  How to read/write kernel memory in my driver of Linux 2.2/2.4.x ? (Gu Weining)
  Re: What is the size of Linux 2.4.1 Kernel (Chad Everett)
  Re: Linux module install error
  Re: Linux module install error
  Boot problem (ImperatorM)
  Re: setsockopt() return "protcol not available" please help (Kai Stuke)
  Re: Using DMA hardware from user space ("Ken Whaley")
  Re: Using DMA hardware from user space (Grant Edwards)
  Re: 8200 Tape drive problems (Jerry Peters)
  winfast old driver ("mike")
  Compaq NetFlex-3 Driver for Redhat Linux 5.2... ("Christian G Jackson")
  Running Windows/Dos programs in Linux(SuSE) (Timothy)
  how to create a boot disk accoring to the bootsect.S ("hushui")
  Re: Running Windows/Dos programs in Linux(SuSE) (Paul Jackson)
  How to create a shared library in Linux? ("Alan Po")
  Re: How to create a shared library in Linux? (Chronos Tachyon)
  Kernel 2.4.3 reverses assignment order of AHA2940UW and NCR810 disks ("Hal R. Brand")

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

From: Andrew Gierth <[EMAIL PROTECTED]>
Crossposted-To: comp.unix.programmer,comp.os.linux.development.apps
Subject: Re: How to handle newline character(s) in a TCP server
Date: 30 Mar 2001 12:54:40 +0100

>>>>> "InterFan" == InterFan  <[EMAIL PROTECTED]> writes:

 InterFan> I want to design a TCP server. It just receives a line from
 InterFan> client and handles it. Then, it sends the response back to
 InterFan> the client. The problem is that a line of message may end
 InterFan> with ASCII characeter 13, 10 or 13+10. I use blocking I/O
 InterFan> function. How can I handle these conditions smoothly.

the best solution is to define your protocol as using a specific line
terminator (the standard for Internet protocols is CR+LF) and require
all clients to send in that format.

-- 
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>
                           or <URL: http://www.whitefang.com/unix/>

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

From: Gu Weining <[EMAIL PROTECTED]>
Subject: How to read/write kernel memory in my driver of Linux 2.2/2.4.x ?
Date: Fri, 30 Mar 2001 11:32:26 -0600


My driver works perfectly in 2.0 version. However, when I
ported my code to 2.2 version(to 2.4 later after I succeed in 2.2),
I always got wrong info.

Would you please help me ASAP? Thank a lot.

Weining Gu



1. My char driver code works perfectly in 2.0 as follows:
   (I can read/write any kernel symbols /boot/System.map by address)

static int abc_ioctl (struct inode *inode, struct file *filp,
                        unsigned int cmd, unsigned long arg)
{
  unsigned long address;
  unsigned long tmp;
  unsigned long value;
  ...
  switch(cmd) {
  case MEMDS_BAR:
    if (verify_area(VERIFY_WRITE, (void *)arg, sizeof(int *))) {
      return -EINVAL;
    }
    address = get_user((int *)arg);
    tmp = virt_to_phys((void *)address);
    memcpy_tofs( (void *)arg, (void *)tmp, sizeof(int)); /*send to user
space*/
    (value) = (*(int *)tmp)^16;
    (*(int *)tmp) = value;
    printk("<1> 0x%08x -> tmp=0x%08x(modified=0x%08x)\n",
            (int)address, *(int *)tmp, value);
    break;
    default:  /* redundant, as cmd was checked against MAXNR */
    return -EINVAL;
  }

  return 0;
}

2. My char driver code does NOT work in Linux 2.2.12 version as follows:

   (I cannot access any memory from 0 to cxxxxxxx)
   (I got either segmentation fault or copy_to_user(..) return 1)

static int xyz_ioctl (struct inode *inode, struct file *filp,
                       unsigned int cmd, unsigned long arg)
{
  unsigned long address;
  int tmp;
  unsigned long value;
  ...
  switch(cmd) {
    case MEMDS_BAR:
      if( get_user(address, (int *)arg) )  return -1;
      tmp = virt_to_phys((void *)address);
      value = (*(int *)tmp)^16;
      (*(int *)tmp) = value;
      if ( copy_to_user ((void *)arg, (void *)&tmp, sizeof(int)) )
return -1;
      break;
    default:
    return -1;
  }
  return 0;
}




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

From: [EMAIL PROTECTED] (Chad Everett)
Crossposted-To: 
comp.os.linux.advocacy,comp.os.linux.development.apps,comp.os.linux.help,comp.os.linux.misc
Subject: Re: What is the size of Linux 2.4.1 Kernel
Reply-To: [EMAIL PROTECTED]
Date: Fri, 30 Mar 2001 18:19:22 GMT

On Fri, 30 Mar 2001 04:08:20 GMT, J Sloan <[EMAIL PROTECTED]> wrote:
>Alan Po wrote:
>
>> Dear all
>>
>> Would you tell me the size of Linux 2.4.1 kernel? Is it very large?
>>
>
>The compressed image is just over 600k -
>
>-rw-r--r--    1 root     root       661329 Mar 26 12:57 vmlinuz
>

My compressed 2.4.3pre6 kernel is about 1Meg (as is 2.4.2):

-rw-r--r--    1 root     root      1016180 Mar 21 17:26 vmlinuz-2.4.3pre6

You obviously have a lot more code farmed out to modules than I do.
I use modules for sound, etc. but I like to keep my network card,
scsi drivers in the kernel itself.



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

From: [EMAIL PROTECTED] ()
Subject: Re: Linux module install error
Date: Fri, 30 Mar 2001 19:25:08 -0000

In article <[EMAIL PROTECTED]>,
Jason K. Leong <[EMAIL PROTECTED]> wrote:
>I have ported a device driver from SCO to Linux and was able to compile
>it.  However when I was trying to install it into the kernel using the
>command, "insmod driver.o", I get
>the following three errors:
>
>unable to resolve symbol register_chrdev()
>unable to resolve symbol printk()
>unable to resolve symbol do_exit()
>
>Now I thought these three functions are standard Linux kernel functions
>that are supposed to link correctly.  What am I doing wrong?  I did
>include the compile flags in my makefile of "-D__KERNEL__" and "
>-DMODULE".  Am I missing a path, forgetting to include something?

<sigh>

Does anybody have some canned text for this?  

--
http://www.spinics.net/linux

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

From: [EMAIL PROTECTED] ()
Subject: Re: Linux module install error
Date: Fri, 30 Mar 2001 19:27:01 -0000

In article <[EMAIL PROTECTED]>,
Kasper Dupont  <[EMAIL PROTECTED]> wrote:

>Did you remember the optimization flag "-O2" ?

It's a CONFIG_MODVERSIONS problem.  Someone asks about the same
problem here every few days.

--
http://www.spinics.net/linux

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

From: [EMAIL PROTECTED] (ImperatorM)
Date: 30 Mar 2001 20:08:58 GMT
Subject: Boot problem

I have recompiled my kernel and tried to make a LILO boot disk but I keep
getting this message on boot.

request_module[block-major-3] : Root fs not mounted
VFS: Cannot open root device "hda7" or 03:07
Please append a correct "root=" boot option
Kernel panic: VFS: Unabel to mount root fs on 03:07

The problem is I did append a correct "root=" option and both I and the new
kernel know it!!  It is looking for 03:07 which is hda7 so what the heck!!  Is
the problem in my boot disk, or my recompiled kernel?  Whats a newbie to do...

Thanks for any help anyone can offer.
-Ted

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

From: Kai Stuke <[EMAIL PROTECTED]>
Subject: Re: setsockopt() return "protcol not available" please help
Reply-To: [EMAIL PROTECTED]
Date: Fri, 30 Mar 2001 18:44:19 +0200

FREDRIK LINDSTR�M wrote:

> When I try to set the SO_RCVTIMEO and SO_SNDTIMEO setsockopt() return
> "protocol not available". When
> setting SO_REUSEADDR with setsockopt() the return is 0 = okey.

see socket(7):

SO_RCVTIMEO and SO_SNDTIMEO Specify the sending or receiving timeouts until 
reporting an error. They are fixed to a protocol specific setting in Linux 
and cannot be read or written. Their functionality can be emulated using 
alarm(2) or setitimer(2). 

Kai

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

From: "Ken Whaley" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Using DMA hardware from user space
Date: Fri, 30 Mar 2001 13:38:38 -0800


> > My first idea was to use a driver that initially gets this memory, and
> > then allows user process to map it into its address space. The driver
> > should provide some way to translate logical into physical address
> > (maybe through ioctl that calls virt_to_phys()? ).
> >
> - Your driver should allocate the memory blocks you need. This blocks
>   should be choosen according to the needs of your DMA hardware
>  (physical continous in memory).

Yes.  Extra info: if you want guaranteed successful allocation of
large chunks of physically contiguous memory, you may have to patch
your kernel (not sure what 2.4.x kernels do about this, but this is
true with 2.2.x) with something like the bigphysarea patch.
>
> - You map this memory via mmap() into the user space. Independend
>   of the memory layout of the physical blocks this can be done
>   in a way that the application always sees this buffer as continous
>   in its address space.

Right again.

>
> - Your application should _not_ program the ASIC itsef. It should
>   call your driver telling it what DMA transfer has to be done.
>   The driver gets (by virt_to_bus()) the bus address of the buffer
>   and can program the ASIC.
>
> -Arne

Not necessarily so. User-level drivers can be just fine, especially if
you need no kernel support beyond that of allocating and mapping the DMA
region, and mapping the device resources (registers/memory/etc) to
user-space.  It's especially easy if the DMA region is physically
contiguous, since calculating physical and bus addresses from the virtual
address is trivial on most platforms.  If your target system is a
"mainstream" one (e.g., that can
memory map PCI devices "sanely"), and you need no kernel support beyond
those
few things mentioned above, and your driver is for your use as opposed to
for general public consumption, then go right ahead and write the driver in
user-space.   Debugging in user space is *much* more pleasant than kernel
space
(warning: gdb [via ptrace] can't directly access pointers that point to
non-RAM addresses [i.e., your device on the PCI bus].  The simple
work-around
is to have a read/write function in your program that you can call
interactively from gdb).  You also have many more tools and helping
functions
at your disposal (libc, threads, etc.) in user-space.

This is what I've done and it works very well.






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

From: [EMAIL PROTECTED] (Grant Edwards)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Using DMA hardware from user space
Date: Fri, 30 Mar 2001 22:05:44 GMT

In article <O_6x6.49$[EMAIL PROTECTED]>, Ken Whaley wrote:

>> - Your application should _not_ program the ASIC itsef. It should
>>   call your driver telling it what DMA transfer has to be done.
>>   The driver gets (by virt_to_bus()) the bus address of the buffer
>>   and can program the ASIC.
>
>Not necessarily so. User-level drivers can be just fine,
>especially if you need no kernel support beyond that of
>allocating and mapping the DMA region, and mapping the device
>resources (registers/memory/etc) to user-space.  It's
>especially easy if the DMA region is physically contiguous,
>since calculating physical and bus addresses from the virtual
>address is trivial on most platforms.  If your target system is
>a "mainstream" one (e.g., that can memory map PCI devices
>"sanely"), and you need no kernel support beyond those few
>things mentioned above, and your driver is for your use as
>opposed to for general public consumption, then go right ahead
>and write the driver in user-space.

I agree wholeheartedly with Ken.  Debugging in user-space is
*so* much easier.  Do everything you can in user-space at first
-- especially if you're doing something like testing prototype
hardware.  Debugging a new ASIC design is bad enough without
having to do it using kernel code.

One thing that's extremely handy during deubgging is to have a
/proc entry point that dumps out a snapshot of whatever state
information you can suck out of the thing.

Once you've got the hardware debugged, and figured out exactly
what you want and how to do it[*], _then_ you can move the
needed functionaly into a kernel module and put a nice wrapper
around it for general consumption.

[*] IOW, you've got usable work-arounds for the things in the
    ASIC that don't work.  ;)

-- 
Grant Edwards                   grante             Yow!  Uh-oh!! I forgot
                                  at               to submit to COMPULSORY
                               visi.com            URINALYSIS!

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

From: Jerry Peters <[EMAIL PROTECTED]>
Subject: Re: 8200 Tape drive problems
Date: Fri, 30 Mar 2001 23:08:49 GMT

Manoj Patil <[EMAIL PROTECTED]> wrote:
> Hi !
> I have IBM PC with Red Hat 6.2 (kernel 2.2.14)
> I have connected two SCSI tape drives to this machine
> I am not able to change the density and block size for one of the tape
> drive

> $ cat /proc/scsi/scsi     shows me following
> Attached devices
> Host: scsi0    Channel:    00    ID:   02    Lun:00
> Vendor:    EXABYTE    Model: IBM-8505    Rev: 7J0A
> Type:    Sequential-Access                            ANSI SCSI
> revision: 02
> Host:  scsi0    Channel:   00    ID:   03    LUN:00
> Vendor:    EXABYTE    Model: EXB-8200    Rev:2680
> Type:    Sequential-Access                            ANSI SCSI
> revision: 01 CCS

> $mt -f /dev/nst1 status
> SCSI 1  tape drive
> File number =-1,  block number=-1
> Tape block size 0 bytes. Density code 0x0 (default)
> Soft error count since last status=0
> General status bits on (1010000):
> ONLINE IM_REP_EN

> On this tape if i try to change the blksize or the density, I get
> following error
> ( mt -f /dev/nst1 setblk  1024   and setdensity 0x14)

> st1: Error with sense data: [valid=0] Infofld=0x0 , EOM current
> st09:01:sense key Illiegal request
> /dev/nst1:  Input/Output Error

> However, I am able to do  a  tar cvf and tar tvf on this tape using a
> 112M cartridge.

> Can some one please help me in how to go about changing the blk size .

> (I am able to change block size and density on the other tape i.e
> /dev/nst0)

It looks like you don't have a tape in the drive. My 4mm dat rejects
certain commands, including setblksize when there's no tape present.
This appears to be dependent on the drive itself, I've used other 4mm
drives that will accept setblksize even without a tape.

        Jerry




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

From: "mike" <[EMAIL PROTECTED]>
Subject: winfast old driver
Date: Sat, 31 Mar 2001 09:49:06 +0800

where can i download winfast s200?
i am  a new user for linux
where can i ask about downloading driver of newsgroup ?

thx for my responsers first



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

From: "Christian G Jackson" <[EMAIL PROTECTED]>
Subject: Compaq NetFlex-3 Driver for Redhat Linux 5.2...
Date: Fri, 30 Mar 2001 21:17:36 -0500

I can't find a Compaq NetFlex-3 NIC Driver for my Compaq 6000 5166 Tower PC
and install won't let me continue.  Does anyone know where I can download
this driver?
I do not know how to write a device driver so I am stuck.
Thanks,
email [EMAIL PROTECTED]




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

From: Timothy <[EMAIL PROTECTED]>
Subject: Running Windows/Dos programs in Linux(SuSE)
Date: Sat, 31 Mar 2001 02:30:09 -0000

 My question is: Can Windows95/DOS programs be executed in Linux? If 
so,how? If not, why not?

 When I try it, it gives me a message "cannot execute binaries". Duh!?

--
Posted via CNET Help.com
http://www.help.com/

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

From: "hushui" <[EMAIL PROTECTED]>
Subject: how to create a boot disk accoring to the bootsect.S
Date: Sat, 31 Mar 2001 11:34:34 +0800

I have seen the boot disk of bootsect.S does not have a file system . When
load the kernel, the bootcode read the floppy by read each sector of the
disk. Does it??
When we create a boot disk in the install time ,it is a disk with ext2 file
system .
How can I create a raw boot disk ???



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

From: [EMAIL PROTECTED] (Paul Jackson)
Subject: Re: Running Windows/Dos programs in Linux(SuSE)
Date: 31 Mar 2001 05:00:34 GMT


No, windows binaries don't run on Linux.  An entirely
different set of system calls (and supporting libraries).

Try looking up "Wine" or "VMware" (the latter is commercial),
for emulation environments that allow executing Windows
apps on a Linux system.
-- 
                          I won't rest till it's the best ...
                          Manager, Linux System Software
                          Paul Jackson <[EMAIL PROTECTED]> 1.650.933.1373

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

From: "Alan Po" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps,comp.os.linux.help
Subject: How to create a shared library in Linux?
Date: Sat, 31 Mar 2001 13:07:22 +0800

Dear sir

As I know, there have some shared libraries in the directories /lib. Can I
also create my personal share library so that my code can share to my
application? Please tell me the metod, thanks a lot.

Alan Po

[EMAIL PROTECTED]



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

From: Chronos Tachyon <[EMAIL PROTECTED]>
Subject: Re: How to create a shared library in Linux?
Crossposted-To: comp.os.linux.development.apps,comp.os.linux.help
Date: Sat, 31 Mar 2001 05:48:53 GMT

On Fri 30 Mar 2001 11:07, Alan Po wrote:

> Dear sir
> 
> As I know, there have some shared libraries in the directories /lib. Can I
> also create my personal share library so that my code can share to my
> application? Please tell me the metod, thanks a lot.
> 

[Note: c.o.l.d.system is offtopic, it's more for kernel-level questions.]

I find the phrasing of the question rather disturbing... but the answer is 
a very strong "yes".  Basically, it's just a matter of providing the 
"-fPIC" option to gcc when compiling your .c files, and using the "-shared" 
option when linking your .o files together into a library.  Here's a quick 
example:

--- begin foo.c ---
#include <stdio.h>
void hello(void) {
        printf("Hello, World!\n");
}
--- end ---

--- begin bar.c ---
void hello(void);
int main(void) {
        hello();
        return 0;
}
--- end ---

To compile and link the library:
        gcc -O2 -fPIC -o foo.o -c foo.c
        gcc -shared -o libfoo.so foo.o

To compile and link the program:
        gcc -O2 -o bar.o -c bar.c
        gcc -o testprog bar.o -L. -lfoo

-- 
Chronos Tachyon
Guardian of Eristic Paraphernalia
Gatekeeper of the Region of Thud
[Reply instructions:  My real domain is "echo <address> | cut -d. -f6,7"]


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

From: "Hal R. Brand" <[EMAIL PROTECTED]>
Subject: Kernel 2.4.3 reverses assignment order of AHA2940UW and NCR810 disks
Date: Sat, 31 Mar 2001 06:10:47 GMT

Executive Summary: Kernel 2.4.3 assigns disks on the NCR810 controller
        before the Adaptec 2940UW controller. This is the opposite
        behavior of previous kernels and can lead to all kinds of "fun".

Just tried kernel 2.4.3 and ran into the following "difference" in
2.4.3 vs its predecessors. I have both an Adaptec 2940UW and
NCR810 SCSI controllers. Up till 2.4.3, the 2940UW was initialized
(and the disks assigned) before the NCR810. With 2.4.3, the NCR810
is initialized first. In my case, with one disk on each controller,
this reversed disks sda and sdb.

This reversal lead to some initial confusion as both disks were bootable
and the /etc/fstab files had them under their old designation. When booted
with a boot floppy specifying /dev/sda1, the NCR810 (formerly sdb1) partition
booted. To add to the confusion, the /etc/fstab file specified that "/"
was to be mounted on sdb1. Linux merrily took this, not noticing the
inconsistency! (Its worth considering whether a consistency check ought
to be made?)

When booted with a boot floppy specifying /dev/sdb1, the 2940UW disk
(formerly sda1, now sdb1) booted, and mounted "/" (again wrongly) as sda1.
Shortly thereafter, things went down hill fast as the swap file
specified in /etc/fstab as sda2 failed (thank God) to mount on the
NCR drive (formerly sdb, but now sda). Interestingly enough, Linux
was operable enough with partition sdb1 mounted as "/" on sda1 to
allow copying /etc/fstab to /etc/fstab.old and then usage of xemacs
to edit /etc/fstab to change all occurances of sda to sdb and vice
versa. Following this editing and a reboot, I'm running fine.

I hope this helps others who might run into this "issue".


//*****************
// Hal Brand
// [EMAIL PROTECTED] - be sure to remove the ".nospam."
//*****************

Selected portions of .config

# CONFIG_SCSI_AHA1740 is not set
CONFIG_SCSI_AIC7XXX=y
CONFIG_AIC7XXX_CMDS_PER_DEVICE=8
CONFIG_AIC7XXX_RESET_DELAY=5
# CONFIG_SCSI_ADVANSYS is not set
...
# CONFIG_SCSI_NCR53C406A is not set
# CONFIG_SCSI_NCR53C7xx is not set
CONFIG_SCSI_NCR53C8XX=y
# CONFIG_SCSI_SYM53C8XX is not set
CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=4
CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32
CONFIG_SCSI_NCR53C8XX_SYNC=20
# CONFIG_SCSI_NCR53C8XX_PROFILE is not set
# CONFIG_SCSI_NCR53C8XX_IOMAPPED is not set
# CONFIG_SCSI_PAS16 is not set

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


** 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 PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.system newsgroup.

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

End of Linux-Development-System Digest
******************************

Reply via email to