Linux-Development-Sys Digest #176, Volume #8     Wed, 27 Sep 00 08:13:12 EDT

Contents:
  Re: Q: network driver interface changes between 2.2.x and 2.4.x ("Morton, Andrew 
[WOLL:4009-M:EXCH]")
  Re: Linux Stack Sizes? (0/1) (David Wragg)
  Re: Linux Stack Sizes? (0/1) (David Wragg)
  Re: Linux Stack Sizes? (0/1) ("Paul D. Smith")
  Linux Network Driver Help ("Jim Slade")
  Re: RS232 / Mitutoyo Counter and Basic example (Lew Pitcher)
  Re: How to determine IP address in C program? (Cliff Lardin)
  Re: ioremap not in namespce...? (Sean Patrick McNamee)
  what is the max size of a shm? ("gdm")
  segmentation foult. ([EMAIL PROTECTED])
  Re: segmentation foult. ("St. Otto")
  Re: nocachable memory on non-PC? (F. Heitkamp)
  Re: ioremap not in namespce...? (Arne Driescher)

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

From: "Morton, Andrew [WOLL:4009-M:EXCH]" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.networking,comp.os.linux.development
Subject: Re: Q: network driver interface changes between 2.2.x and 2.4.x
Date: Wed, 27 Sep 2000 01:15:14 +0000

ftp://ftp.sunet.se/pub/network/ip-routing/README.softnet
http://boudicca.tux.org/hypermail/linux-kernel/2000week07/0667.html

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

From: David Wragg <[EMAIL PROTECTED]>
Subject: Re: Linux Stack Sizes? (0/1)
Date: 26 Sep 2000 14:08:51 +0000

"Paul D. Smith" <[EMAIL PROTECTED]> writes:
> This is not a problem with the maximum size of the stack.

Indeed.

> First, you are assuming that the stack lives in high memory and grows
> towards low memory.  You cannot assume that.  There is absolutely no
> reason the stack couldn't live in low memory, and grow upwards.  Many
> implementations of UNIX and other OSs do exactly this.

If he's writing (or porting or maintaining) a threading package I
expect he knows about the system dependent aspects involved, such as
which way the stack grows.  Since he said he is porting code that
works on Solaris and NT, I think we can assume he is concentrating on
x86.

> Second, you are assuming that any memory below your stack can
> arbitrarily be written on.  That's totally broken.  The stack could
> well be allocated only as needed by function calls, and memory beyond
> what's been used is simply not available (hence traps if you try to
> access it).

This is what's causing the problem.  Stack pages are only allocated as
needed, though not explicitly by function calls.

The kernel adds pages to the stack segment of a process on demand,
growing it downwards (on x86) in response to page faults.  But how can
it tell if a memory access resulting in a page fault refers to the
stack segment?  It can't, so it guesses: If the faulting address is
below the bottom of the stack segment, and is above the stack pointer
or slightly below it, then the stack segment should be grown.
"Slightly below" here means "no more than 32 bytes below".

So when the OP's program runs off the bottom of the stack segment, the
kernel probably won't know that the memory accesses relate to the
stack segment and so sends a segfault.

Try running so it touches memory with a stride of 32 bytes, and it
should merrily grow the stack segment until it hits the stack resource
limit.

> [snip]
>
> If you _must_ have it in the stack, you're going to have to actually
> _allocate_ that much stack!  You can't simply use it without previously
> telling the compiler and/or runtime system you will need it.

... or the kernel.

> For example, you could use alloca().  This smells like malloc(), but it
> allocates memory from the stack instead of the heap (no free()
> necessary).  While this isn't a standard C function, it's supported by
> GCC which runs on almost any UNIX system.  Also, most other UNIX
> compilers and OS's support it (certainly Solaris does, even if you use
> SPARCWorks instead of GCC).  There _are_ platforms that don't (can't)
> support alloca(), however.

An approach based on alloca() won't work reliably without knowing
whether the stack grows up or down, and you were railing against mking
such an assumtion.  It would need something like:

void grow_stack(size_t stack_size)
{
#ifdef STACK_GROWS_DOWN
        /* touch the stack at the bottom */
        ((char *)alloca(stack_size))[0] = 42;
#else
        /* touch the stack at the top */
        ((char *)alloca(stack_size))[stack_size-1] = 42;
#endif
}

This approach isn't too bad.  You need to define STACK_GROWS_DOWN or
not as appropriate for each platform, but every approach will need at
least that much.

> If you can't do that, and your compiler supports the 1999 ISO C
> standard, you can use variable size arrays (even though this is standard
> and alloca() isn't, I still list alloca() as more portable because not
> too many compilers support 1999 ISO C yet, while almost all support
> alloca()).  GCC supports these, although I'm not sure if they are 100%
> standard yet.  They're standard enough for you; there just may be some
> weird corner cases that are non-standard.

There is nothing in that standard that says that VLAs have to be
allocated off the same stack as other automatic variables.  You are
suggesting ways to stay inside the C standard when accomplishing
something (messing with stacks in a threading package) that is
inherently outside the scope of the C standard.  You will inevitably
have to go outside th guarantees of the C standard somewhere along the
line, so why bother?

> [snip]
> 
> If you can't do any of those things, AFAICT you're SOL and you can't
> port your program to UNIX, or probably most any other platform.  Sorry.

I'm not sure why the OP wants to allocate all of the stacks within the
initial stack, but it can be done perfectly well on Linux.


David Wragg

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

From: David Wragg <[EMAIL PROTECTED]>
Subject: Re: Linux Stack Sizes? (0/1)
Date: 26 Sep 2000 14:14:48 +0000

MeekGeek <[EMAIL PROTECTED]> writes:
> Is there a linker option, compiler directive, executable editor, or
> something similar, that will allow me to specify a larger stack?
> There must be some way for me to get more than 6K of usable stack
> space!  :-)

You're problem isn't with the size of the stack.  See my other post.

> 
> Does Linux support the "guard pages" concept implemented by NT on
> Intel processors?

Does it implement it for you?  No, but it supports everything you need
to implement it yourself.  mprotect lets you protect a page so that
any access will result in a SIGSEGV (LinuxThreads uses this to
implement guard pages for thread stacks).


David Wragg

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

From: "Paul D. Smith" <[EMAIL PROTECTED]>
Subject: Re: Linux Stack Sizes? (0/1)
Date: 27 Sep 2000 01:19:23 -0400
Reply-To: [EMAIL PROTECTED]

%% David Wragg <[EMAIL PROTECTED]> writes:

  dw> You are suggesting ways to stay inside the C standard when
  dw> accomplishing something (messing with stacks in a threading
  dw> package) that is inherently outside the scope of the C standard.
  dw> You will inevitably have to go outside th guarantees of the C
  dw> standard somewhere along the line, so why bother?

Indeed.  I didn't read the post carefully enough: I read the code but
didn't really grasp the user's reasons for wanting to play these games.
If I had fully realized what he wanted to do I wouldn't have pushed for
a standard solution, since there obviously isn't one.

My bad.

-- 
===============================================================================
 Paul D. Smith <[EMAIL PROTECTED]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
===============================================================================
   These are my opinions---Nortel Networks takes no responsibility for them.

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

From: "Jim Slade" <[EMAIL PROTECTED]>
Subject: Linux Network Driver Help
Date: Wed, 27 Sep 2000 05:53:31 GMT

I have RedHat 6.1 and I am looking to install a RealTek RTL8029 PCI Ethernet
Card.  How would I install the drivers for this card?

Any help would be appreciated.

Thanks



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

From: Lew Pitcher <[EMAIL PROTECTED]>
Subject: Re: RS232 / Mitutoyo Counter and Basic example
Date: Tue, 26 Sep 2000 18:21:40 -0400

"O.Petzold" wrote:
> 
> Hallo,
> 
> I have here a Mitutoyo linear gauge with a counter. I want to connect
> this
> counter to my linux box using the RS323. In the manual there is an
> example
> in basic:
> 
> 50    open "com:e72" as#1
> 60    print #1, "CS00"
> 70    input "ef-11pr ? Y or N", CS
> 80    print #1, "GA00"
> 90    print "GA00"
> 100    if LOC(1) = 0 then goto 100
> 110    line input #1, as
> 120    print " ", as;
> 130    if CS="Y" then 160
> 140    line input #1, AS
> 150    print " ", AS;
> 160    print
> 170    for i=0 to 100. next
> 180    goto 80
> 
> please don't stone me 8).
> 
> This should put the counter value to the display. My knowledge about
> BASIC
> is less than poor and I have to write a program for reading theses. The
> program
> has to be in C/C++, runinning in a linux box.
> Now my questions:
> - What happend above - translated to C

Sorry, I'm not going to rewrite _that_ BASIC into C.

However, here's what it does...

Open /dev/ttyS0 for I/O
write the string "CS00" to /dev/ttyS0
write the string "ef-11pr ? Y or N" to /dev/tty, and input a response
loop forever
  write the string "GA00" to /dev/ttyS0
  wait for some input on /dev/ttyS0
  read a line of input from /dev/ttyS0
  if the response to the /dev/tty prompt was not 'Y'
    read a line of input from /dev/ttyS0
    write the input to /dev/tty
  end-if
  print a blank line on /dev/tty
  idle loop for a while
end-of-forever-loop

> - How can I read/write to the serial port, what does it mean line 50 ?
> (com:e72 and as #1 ?)

  FILE *file;

  file = fopen("/dev/ttyS0","r+");
  fprintf(file,"%s\n",data); or fwrite(data,sizeof(char),sizeof
data,file);
  fscanf(); or fgets(); or fread(); /* you get the picture */

> - line 60: print #1, "CS00": does it mean put cs00 into stream???? #1,
> is it hex, ascii ???

It seems to be a string (i.e. "CS00" ).

> - Is there allready source for the Mitotoyo Counter EF -11 series ?

Don't know
 
> Thanks    Olaf

-- 
Lew Pitcher

Master Codewright and JOAT-in-training

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

Crossposted-To: 
comp.os.linux.questions,comp.os.linux.development.apps,comp.os.linux.development
From: Cliff Lardin <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: Re: How to determine IP address in C program?
Date: Wed, 27 Sep 2000 07:26:47 GMT

Taavo, 

Thank you for your help.  Below is the program that does the trick
in case anyone is interested.

==========CUT HERE=============

#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>


int main(void)
{
    struct ifreq ifr;
    struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
    int sockfd, i;

    bzero(&ifr, sizeof(ifr));

    if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    {
        perror("socket()");
        return(-1);
    }

    strcpy(ifr.ifr_name, "eth0");
    sin->sin_family = AF_INET;

    if(ioctl(sockfd, SIOCGIFADDR, &ifr) == 0)
    {
        printf("\n%s : [%s]\n", ifr.ifr_name, inet_ntoa(sin->sin_addr));

    }

    return(0);
}
        

==========CUT HERE=============


-- 

Cliff Lardin
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://cliff.lardin.net

On Mon, 25 Sep 2000, Taavo Raykoff wrote:

>  
> Cliff, you basically do this with ioctl().  Check out the following
> sample code snipped from interface.c from net-tools distribution kit
> (e.g. the ifconfig command).  __It is all in man netdevice. ___    Hope
> this helps.
> 
> Taavo.
> 
> int if_fetch(struct interface *ife)
> {
>     struct ifreq ifr;
>     int fd;
>     char *ifname = ife->name;
> 
> ...
> 
> 
>     /* IPv4 address? */
>     fd = get_socket_for_af(AF_INET);
>     if (fd >= 0) {
>  strcpy(ifr.ifr_name, ifname);
>  ifr.ifr_addr.sa_family = AF_INET;
>  if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
> 
> ...
> 
>     return 0;
> }
> 
> 
> 
> [EMAIL PROTECTED] wrote:
> 
> > I am trying to write a C program that can determine the IP address
> > assigned to /dev/eth0.  The program needs to be able to figure this
> > out without knowing the hostname of the machine that it's running on.
> > Also, it can't be certain that the IP address will exist in a file
> > (such as /etc/dhcpc/dhcpcd-eth0.info) because the IP address may or
> > may not be dynamically allocated.
> >
> > Thus, using gethostbyname(3) isn't useful.
> >
> > Is there any system call that will simply return the IP address
> > assigned to a particular network device?  Or a way to enumerate the
> > network devices from a user-mode program?
> >
> > Thanks in advance.
> >
> > --
> >
> > Cliff Lardin
> > [EMAIL PROTECTED]
> > [EMAIL PROTECTED]
> > http://cliff.lardin.net
> 


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

From: Sean Patrick McNamee <[EMAIL PROTECTED]>
Subject: Re: ioremap not in namespce...?
Date: Wed, 27 Sep 2000 07:39:23 GMT

Arne Driescher wrote:

> >
> > Hmmm... I DO see the same __ioremap in my System.map file - I don't see it when I
> > run ksyms however.
> > I must admit, I'm confused. Where exactly does the module look for it? I thought
> > that in order for a module to access it, it would
> > have to be listed in ksyms' output...but Why would it be in my System.map and not 
>in
> > ksyms' output?
> >
> Don't qoute me on this but as far as I know the module loader
> uses System.map to resolve references to kernel functions.
> Running ksyms on my system:
> pc45:[~]> ksyms -a | grep ioremap
> c010ee54  __ioremap
> shows the reference to ioremap.
> From System.map:
> c010ee54 T __ioremap
>
> Both are the same. Perhaps you should start to build new
> kernel until you have the same result in both cases.
>
> -Arne

OK>  I added the -a option to my ksyms, and now I'm seeing a symbol
__ioremap_R9eac042a

This looks almost like mangling to me. I am still having the problem with the 
unresolved
symbol when I try to load the driver, so I'm wondering if something weird is up with my
kernel or what???



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

From: "gdm" <[EMAIL PROTECTED]>
Subject: what is the max size of a shm?
Date: Wed, 27 Sep 2000 10:38:33 +0200

who knows the max size of a shm in Linux? somebody told me that the max size
could be 1Gb ? is this true?
gdm




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

From: [EMAIL PROTECTED]
Subject: segmentation foult.
Date: Wed, 27 Sep 2000 08:45:01 GMT

Hi!!
I am suffering from a great problem. After compiling my amy c program,
i got a.out file. but while executing this file the message i receive
is "core dump" "segmentation foult". Please give me solution for this
as if i am new prograamer in linux.
Thanks in advance.
Bharat.


Sent via Deja.com http://www.deja.com/
Before you buy.

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

From: "St. Otto" <[EMAIL PROTECTED]>
Subject: Re: segmentation foult.
Date: Wed, 27 Sep 2000 11:10:16 +0200

[EMAIL PROTECTED] wrote:
> 
> Hi!!
> I am suffering from a great problem. After compiling my amy c program,
> i got a.out file. but while executing this file the message i receive
> is "core dump" "segmentation foult". Please give me solution for this
> as if i am new prograamer in linux.
> Thanks in advance.
> Bharat.
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

That's not a linux problem. In this case the problem is sitting
before the keyboard (Don't be angry, I meant it as a joke).

"Segmentation fault" points to a range error by writing to a string,
field, pointer etc.
Check your code for unallocated pointers, unchecked field dimensions
etc. The compiler doesn't know, how much data you will put into a
string, field ..., that's why it compiles successfully, but .... I got
an idea: check the compilers "-W options".

Regards
Steffen

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

Crossposted-To: linux.dev.kernel
From: [EMAIL PROTECTED] (F. Heitkamp)
Date: Wed, 27 Sep 2000 07:11:52
Subject: Re: nocachable memory on non-PC?
Reply-To: [EMAIL PROTECTED]

In message <[EMAIL PROTECTED]> - Arne Driescher
<[EMAIL PROTECTED]>Mon, 25 Sep 2000 13:13:58 +0200 writes:
>
>"F. Heitkamp" wrote:
>
>Hmm, what does non PC Linux mean? Basically there is old style 
>port pased i/o on the PC and mostly memory maped i/o on
>systems like alpha, sparc ....

It is a PowerPC based System.

>Your "(noncachable) memory
>> range associated with the particular device."
>is surly some kind of memory maped i/o range, right?
>Therefore, have a look at any PCI driver to see how
>i/o-memory is maped into your device driver.

It is not a PCI card, but a SCSI chip attached to
the processor.  It occupies a 16 bit address range.
The way the driver is supposed to work on this architecture
is memory mapped.

>I guess you look for something like
>(u_long) ioremap_nocache(BaseAddr, SizeOfYourMemArea );

Hmm.  I found that.  In the driver there is also a 
section that uses check_region/request_region.  I guess
that is used if the drivers is running in I/O Mapped 
"mode".

Fred


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

From: Arne Driescher <[EMAIL PROTECTED]>
Subject: Re: ioremap not in namespce...?
Date: Wed, 27 Sep 2000 14:09:32 +0200

> OK>  I added the -a option to my ksyms, and now I'm seeing a symbol
> __ioremap_R9eac042a
> 
> This looks almost like mangling to me. I am still having the problem with the 
>unresolved
> symbol when I try to load the driver, so I'm wondering if something weird is up with 
>my
> kernel or what???
I wouldn't say weird. Depending on which options you have used
to compile your kernel, some symbols are exported and others
are not. Lets a look at the Makefile:
vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs
        $(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \
                --start-group \
                $(CORE_FILES) \
                $(FILESYSTEMS) \
                $(NETWORKS) \
                $(DRIVERS) \
                $(LIBS) \
                --end-group \
                -o vmlinux
        $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aU]
\)\|\(\.\.ng$$
\)\|\(LASH[RL]DI\)' | sort > System.map       

As u can see, the target vmlinux is build by linking all
object files into the kernel. In the next step nm (see man nm)
gets all the symbols from the object file and put the result in
System.map.
Exported symbols defined in you kernel should be in System.map.

Ok, u have the symbol in you kernel but not in System.map. This means
that your System.map is not from the same build as your kernel.
Have you simply forgotten to copy your System.map to you boot
partition? If u built your own kernel: Have you used make install?
(From the Makefile:)
install: $(CONFIGURE) $(BOOTIMAGE)
        sh -x ./install.sh $(KERNELRELEASE) $(BOOTIMAGE)
"$(INSTALL_PATH)"
        sh -x ./install.sh $(TOPDIR)/System.map
"$(INSTALL_PATH)"/System.map-$(KERNELRELEASE)  

-Arne

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


** 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 (and comp.os.linux.development.system) via:

    Internet: [EMAIL PROTECTED]

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