Linux-Development-Sys Digest #745, Volume #7      Wed, 5 Apr 00 19:13:19 EDT

Contents:
  Re: driver using socket ??? (David Wragg)
  Re: To core or not to core - Part 2 (Logan Shaw)
  Q: Serial Port Programming (Adi Kriegisch)
  Re: To core or not to core - You tell me (John Gluck)
  Resetting PCI Bus (jvirzi)
  Re: PCI configuration space fun. (jvirzi)
  Re: struct passwd * (Florian Heinz)
  Re: porting WIN32 to UNIX (Linux) (Mark Hamstra)
  Flushing Disk Cache (jvirzi)
  Re: Flushing Disk Cache (Michael Kelly)
  Re: System.map location (Michael Kelly)
  Re: PCI configuration space fun. (Grant Edwards)
  Overrunning the stack (Jon Becker)
  Re: block device development ("Fabrizio")
  Re: To core or not to core - Part 2 ("Mark Langsdorf")
  Re: Flushing Disk Cache (Juergen Heinzl)
  Re: struct passwd * (Juergen Heinzl)
  Developers Wanted ("Mark Langsdorf")
  Re: Bootdisks, rdev, and root filesystems...aargh! ([EMAIL PROTECTED])

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

From: David Wragg <[EMAIL PROTECTED]>
Subject: Re: driver using socket ???
Date: 05 Apr 2000 20:19:05 +0000

grant@nowhere. (Grant Edwards) writes:
> In article <[EMAIL PROTECTED]>, philippe Defert wrote:
> >i developpe a character driver using socket
> >and when i compile i have no warning and no error
> >but when i load the module ,
> >the kernel respond :
> >./driv.o : unresolved symbol socket
> >./driv.o : unresolved symbol getservname
> >./driv.o : unresolved symbol getservbyname
> >./driv.o : unresolved symbol connect
> 
> This question has come up in the past, and the asnwer as far as
> I have been able to determine is that you can't use those
> functions from driver code.  You can write/read to/from an
> already open socket (though not using the standard read() and
> write() calls), but I don't think it's possible to open a
> socket from driver code.
> 
> I'd be quite happy if I were wrong, so feel free to correct me
> as long as you show me how it's done. ;)

Use sock_create(). There are a few examples in the kernel source, grep
for it under net/sunrpc.

I'm not sure what getservname and getservbyname are supposed to
be. The C library has a getservbyname, so of course you cannot get to
that from the kernel, but the original poster's code looked like it
wanted some other getservbyname.


David Wragg

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

From: [EMAIL PROTECTED] (Logan Shaw)
Crossposted-To: comp.lang.c,comp.unix.solaris,comp.unix.questions,comp.unix.programmer
Subject: Re: To core or not to core - Part 2
Date: 5 Apr 2000 15:45:44 -0500

In article <8cfm88$jrp$[EMAIL PROTECTED]>,
Harish K Chandraia <[EMAIL PROTECTED]> wrote:
>       While we are at it.....I wanted to mention another thing which
>is beyond me....hope somebody can shed some light on it.
>
>       Have any of you experienced this.....you have a program which
>core dumps....and you put in additional printf's and compile with
>DEBUG defined in your Makefile and all of a sudden it stops core
>dumping on you. What could be the reason for something like this to 
>happen. 

Others have speculated about reasons.  The important thing to remember
is that the behavior of dereferencing a NULL pointer is undefined.  So,
sometimes it might do nothing, and sometimes it might crash your whole
program.

>       Using adb, I know the exact point of failure and I even know that
>a NULL is being passed in as an argument to the function but with a printf
>/sprintf just before the function call(to which NULL is being passed) it 
>just doesn't happen anymore. Any thoughts.....

If you're trying to debug it, you could use the debugger to set a
conditional break point so that when the function is called, the
debugger will check to see if its argument is NULL.  Then, you can
issue printf() statements and things like that.

If you're trying to understand why it works sometimes and doesn't other
times, take a computer architecture class.  Actually, they might not
even cover it there.  The point of having undefined behavior is that it
makes design and implementation of a system easier.  It's like having
"don't cares" in a truth table or Karnaugh map in digital circuit
design (which I'm guessing might be familiar to you since you wrote
"-ve" and "+ve" in your message).

   - Logan

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

From: Adi Kriegisch <[EMAIL PROTECTED]>
Subject: Q: Serial Port Programming
Date: Wed, 05 Apr 2000 22:46:26 +0200

Hi!

I need to read out a device which sends data over serial line from my
linux box. Unfortunately it does not use any RS-232 Protokoll but only
has a data-channel, a clock and a ground connected to the PC. 

The Data I may recieve: (only if clock=high)
2 times 16 bit containing 
1. nibble: 1110 or 1111
2. - 4. nibble: just numbers.

Please help,
        Adi
-- 
Adi Kriegisch                           Systemadministrator
Institut fuer Computergraphik    http://www.cg.tuwien.ac.at
Tel. +43-1/58801-18677     mailto:[EMAIL PROTECTED]

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

From: John Gluck <[EMAIL PROTECTED]>
Crossposted-To: comp.lang.c,comp.unix.solaris,comp.lang.c++,comp.unix.programmer
Subject: Re: To core or not to core - You tell me
Date: Wed, 05 Apr 2000 16:32:54 -0400

Barry Margolin wrote:
> 
> >The pointer that is passed to printf will be NULL.
> 
> But no pointer is being passed to printf!  The dereferencing happens before
> the call.  The integer that the pointer points to is being passed.  The
> result depends on what the system does when you try to dererence a null
> pointer, and has nothing to do with what printf() does.
> 
On second look, I misinterpreted the printf() statement. 
You are, of course correct.
Apologies.
-- 
John Gluck  (Passport Kernel Design Group)

(613) 765-8392  ESN 395-8392

Unless otherwise stated, any opinions expressed here are strictly my own
and do not reflect any official position of Nortel Networks.

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

From: jvirzi <[EMAIL PROTECTED]>
Subject: Resetting PCI Bus
Date: Wed, 05 Apr 2000 13:46:59 -0700

I understand this may be an ill-posed question, due to differences in
manufacturer implementations of the PCI bus. I will still ask the
question:

Is there a way to either/both perform a physical reset of the PCI bus
within Linux, and/or reconfigure all devices including resource
allocation?

There are only a limited number of PCI bridge chips, and most that I
have encountered have a way of resetting the secondary PCI bus.

These functionalities would take us a long way towards hot-swappability
under Linux.


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

From: jvirzi <[EMAIL PROTECTED]>
Subject: Re: PCI configuration space fun.
Date: Wed, 05 Apr 2000 13:56:23 -0700

Most devices map their configuration space to I/O as well as memory.
There is nothing special about the memory, with one possible exception.
Some devices will require 32-bit wide transactions to some parts of the
configuration space.

Therefore, I believe mmap() will work just fine.

"Daniel J. Feren" wrote:

> Has anyone written a user-level (not kernel-level)
> device driver that can write to a PCI bus card's
> configuration space?  I'm refering to the unused
> configuration space above 64 bytes.
> I've tried to use some functions similar to those
> in usr/include/linux/pci.  Specifically, I've tried
> using pci_write_block, but I when I check the
> pci bus with another application that dumps
> all the configuration space of all devices the
> changes aren't there.  Its seems pci_write_block
> only writes to the structure and not to the actual
> pci device's configuration space.  Rigtht?
> Is there a way to lock the contents of
> the structure pci_device to the device?
> If anyone has done something like above,
> how, with what function, and are there any links
> to source code that you know of?
> This is for research and not for a school assignment.
> Any ideas or suggestions would be appreciated.
>
> --
> Daniel James Feren
> [EMAIL PROTECTED]
> Georgia Institute of Technology, Computer Engineering


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

From: Florian Heinz <[EMAIL PROTECTED]>
Subject: Re: struct passwd *
Date: Wed, 05 Apr 2000 21:07:07 +0000

bill davidsen wrote:
> 
> In article <8cdkj5$pb0$[EMAIL PROTECTED]>,  <[EMAIL PROTECTED]> wrote:
> 
> | ok why does this program result in a SEGV? On solaris the exact code
> | does not. Am I missing something, like the result is protected memory
> | and when you try to free it, it will not let you? Any assistance would
> | be appreciated!
> 
>   I'm suspicious that even though the man page under ERRORS says "ENOMEM
> Insufficient memory to allocate passwd structure," I am suspicious that
> the pointer may be to a static buffer rather than a malloced object. You
> might malloc a small buffer and print the address (%p), then the pointer
> returned before you try to free that. You might want fflush() in there.
> 
>   The Linux man page doesn't really say the buffer is dynamically
> allocated, the error certainly implies that, and you are right in
> free()ing it.
> 
>   Someone have the source for glibc handy? I don't, and I'm not going to
> go grab it.
> 
>   You might also look at the code very hard to be sure that you don't
> change the pointer, assuming that there is more code than you showed.
> Pardon if there's not.

Another way to find out is:

struct passwd *one, *two;

one = getpwuid(0);
two = getpwuid(1);

printf("%p - %p\n", one, two);

on my system the values were identical, so this should be a static
buffer... right?

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

From: Mark Hamstra <[EMAIL PROTECTED]>
Crossposted-To: 
comp.os.linux.development.apps,comp.os.linux.development,comp.os.ms-windows.programmer.win32,comp.os.ms-windows.programmer.misc,comp.unix.programmer,comp.programming
Subject: Re: porting WIN32 to UNIX (Linux)
Date: 05 Apr 2000 16:34:56 -0400

[EMAIL PROTECTED] (Kaz Kylheku) writes:

> On Wed, 05 Apr 2000 19:27:47 +1000, Jussi Jumppanen <[EMAIL PROTECTED]> wrote:
> >Johannes Hacker wrote:
> >
> >> I am currently working on a project where I have to port a WinNT
> >> Application to Linux. I am mainly focused on threads, processes,
> >> synchronization and messaging between processes. 
> >
> >I would suggest taking a look at Wine web page:
> >
> >  www.winehq.com
> >
> >This is an Open Source project that is attempting to have windows 
> >programs (and the Win32 API) running on linux and so far they have
> >done a wonderful job. 
> 
> Forget it; if you are going to develop for Linux, do a real port.  Wine is for
> running binary windows EXE's.  It's undesirable compared to having a ``native''
> Linux app.


Kaz!  I expected better from you.

Wine is not just about running Windows EXE's on Linux, it is also
very much about compiling existing Win32 code into Linux native
executables.  Corel has already proven that using Winelib in this
capacity is certainly well worth a potential porter's time to look
at closely.

--
Mark Hamstra
Bentley Systems, Inc.

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

From: jvirzi <[EMAIL PROTECTED]>
Subject: Flushing Disk Cache
Date: Wed, 05 Apr 2000 14:07:10 -0700

I'm developing some device drivers under Linux for custom hardware I've
built. In doing so, I inevitably crash the system, or at least wreak
havoc on some of the internals. I've noticed that when I have restarted
the machine, some of the files I saved under a previous session were
never actually written out to the disk. I'm assuming there is a disk
cache or similar function that gets updated to the physical device upon
unmounting.

Is there a way to cause the update to occur without un/remounting the
disk? This way I'm one step closer to preserving my work in the event of
a system crash.

Please don't respond with lectures on device driver development. I'm
familiar with the accepted practices thereof and the consequences
associated with their abandonment. Some times one must bend the rules.


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

From: [EMAIL PROTECTED] (Michael Kelly)
Subject: Re: Flushing Disk Cache
Date: 5 Apr 2000 21:34:37 GMT

In article <[EMAIL PROTECTED]>,
        jvirzi <[EMAIL PROTECTED]> writes:
> I'm developing some device drivers under Linux for custom hardware I've
> built. In doing so, I inevitably crash the system, or at least wreak
> havoc on some of the internals. I've noticed that when I have restarted
> the machine, some of the files I saved under a previous session were
> never actually written out to the disk. I'm assuming there is a disk
> cache or similar function that gets updated to the physical device upon
> unmounting.

man update

also see 'sync' command.
also you can check your hd caching using hdparm.
If you have write-back caching enabled on your
hd you want to turn it off.  Less trashing of
your file system when it hangs.

-- 

Mike
--
"I don't want to belong to any club that would have *me* as a member!"
             -- Groucho Marx


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

From: [EMAIL PROTECTED] (Michael Kelly)
Subject: Re: System.map location
Date: 5 Apr 2000 21:29:10 GMT

In article <[EMAIL PROTECTED]>,
        [EMAIL PROTECTED] (Marc D. Williams) writes:
> On Fri, 31 Mar 2000 19:55:04 -0700, D. Stimits <[EMAIL PROTECTED]> wrote:
>>> 
>>> You can call the file System.map-`uname -r` (e.g. System.map-2.2.14).
>>> 
>>
[snip]

> According to procps' INSTALL file you could also use the PS_SYSTEM_MAP
> variable to point to a map file (wherever it might be I suppose).
> Apparently ps and top will use that first and then use the
> compiled-in(?) search path of /boot/System.map-V, /boot/System.map,
> /lib/modules/V/System.map (where V is the `uname -r` thing).
> 
> It doesn't seem as though klogd uses that variable or even the same
> locations.

I have similar and/or related questions.  I compiled 2.3.4 kernel
and I guess the install has put links in /boot for System.map and
module-info and also vmlinuz.  Anyway, I'm using lilo to choose the
kernel to boot and I'm wondering how to handle the soft links.  Also
I built modules for 2.3.4 but got no corresponding modules-info-xxxx
like I do for the install kernel.  How much does the system depend
on these links and is there an easy way to set them all to correspond
to correct versions etc..  (and also if anyone knows the switch for
make modules to create module-info)

TIA


-- 

Mike
--
"I don't want to belong to any club that would have *me* as a member!"
             -- Groucho Marx


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

From: grant@nowhere. (Grant Edwards)
Subject: Re: PCI configuration space fun.
Date: Wed, 05 Apr 2000 22:17:20 GMT

In article <[EMAIL PROTECTED]>, jvirzi wrote:

>Most devices map their configuration space to I/O as well as
>memory.

To what are you referring as "configuration space"?

PCI boards have a set of configuration registers which do _not_
appear in normal PCI bus memory or I/O space.  That is the PCI
"configuration space".  The PCI spec defines a set of these
registers at addresses 0x00 through 0x3f.  Each PCI board has
set of these configuration registers. Vendors can use registers
above 0x40 for their own purposes.  Since these registers are
not visible in normal I/O or Memory space, you have to go
through various contortions with the PCI bus controller ASIC to
read/write them.  Motherboards usually provide BIOS routines
for this purpose.

>There is nothing special about the memory, with one possible
>exception. Some devices will require 32-bit wide transactions
>to some parts of the configuration space.

I think you're talking about the boards memory and I/O
segments, whose addresses are determined by writing values to
registers in the board's configuration space.

-- 
Grant Edwards                   grante             Yow!  Will this
                                  at               never-ending series of
                               visi.com            PLEASURABLE EVENTS never
                                                   cease?

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

From: [EMAIL PROTECTED] (Jon Becker)
Subject: Overrunning the stack
Date: 5 Apr 2000 22:37:16 GMT


Apologies if this is a FAQ.

Does the kernel do anything to prevent a process's stack from
overrunning other mapped memory?  If the region of memory just below
the stack is mapped read/write, can't the stack just grow into it and
silently blow away whatever's there?

Obviously I can just avoid explicitly mmap'ing the region just below
the stack; however it looks like even if I let the kernel choose an
address for me when I call mmap, then the call to get_unmapped_area
can give me just such a region (if there's nothing available lower in
memory).

So is this true?  Is there really no protection?  It doesn't seem that
difficult to maintain a one-page hole below the stack which will make
sure that the kernel gets involved every time the stack overflows its
region.  Then I could get a SEGV right away instead of having my data
get corrupted.

If such a thing actually does exist in Linux, can you point out where
in the kernel code this is maintained?  I have been unable to find
anything like that.  I confess I haven't actually tried just testing
this myself (I don't have access to a Linux system at the moment), but
I was suprised to find that there was no such protection on Solaris
2.5.1.

TIA.

-Jon

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

From: "Fabrizio" <[EMAIL PROTECTED]>
Subject: Re: block device development
Date: Wed, 05 Apr 2000 22:28:29 GMT

I'm reading the "Linux kernel module programming guide" that you can find
for *free* on the net. To tell the truth, although the Ori Pomerantz's book
is at its second release (1.1.0), I still have problems with the examples.
But I think it is worth to read it!

Now a question: I'm trying the chardev.c module from the book. No problem
with the compilation, but when I try to insmod the module I've some
unresolved symbols related to printk_xxxxxx and sprintf_xxxxxx, where xxxxx
are sume hex numbers.

Hints ? Suggestions ?

Ciao!

    Fabrizio Carrai
e-mail: [EMAIL PROTECTED]


"Master of the system" <[EMAIL PROTECTED]> ha scritto nel messaggio
news:[EMAIL PROTECTED]...
> Hi everybody,
>
> I'm looking for manuals, books, links, tutorials about how to write a
> block device.
> "Linux Device Drivers" from O'Reilly seems not to be very up to date
> (The book is centered on version 2.0, but also covers 1.2.13 and
> experimental versions up to 2.1.43.)
> I wanna program for the next kernel 2.4 so work with 2.39.
>
> Can anybody help?
>
> Thanks in advance
>
>         Andreas Fleuti
>
>
> e_mail: afleutiATiiic.ethz.ch (simply replace AT by @ [to prevent spam])



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

From: "Mark Langsdorf" <[EMAIL PROTECTED]>
Crossposted-To: comp.lang.c,comp.unix.solaris,comp.unix.questions,comp.unix.programmer
Subject: Re: To core or not to core - Part 2
Date: Wed, 5 Apr 2000 17:45:56 -0500


Harish K Chandraia wrote in message <8cfm88$jrp$[EMAIL PROTECTED]>...
>Hi All,
>
> While we are at it.....I wanted to mention another thing which
>is beyond me....hope somebody can shed some light on it.
>
> Have any of you experienced this.....you have a program which
>core dumps....and you put in additional printf's and compile with
>DEBUG defined in your Makefile and all of a sudden it stops core
>dumping on you. What could be the reason for something like this to
>happen.

    This is usually a good sign that you have a memory overrun
somewhere.  Check the boundaries of all arrays and pointers.
    The printfs distance critical code from the overrun, so that
the opcodes that get executed in the new program are different
from the opcodes in the core-dumped program.

> Using adb, I know the exact point of failure and I even know that
>a NULL is being passed in as an argument to the function but with a
printf
>/sprintf just before the function call(to which NULL is being passed) it
>just doesn't happen anymore. Any thoughts.....

    Why aren't you checking pointer values that are being passed to
you?  Bad coding practice.

-Mark Langsdorf





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

From: [EMAIL PROTECTED] (Juergen Heinzl)
Subject: Re: Flushing Disk Cache
Date: Wed, 05 Apr 2000 22:49:14 GMT

In article <[EMAIL PROTECTED]>, jvirzi wrote:
>I'm developing some device drivers under Linux for custom hardware I've
>built. In doing so, I inevitably crash the system, or at least wreak
>havoc on some of the internals. I've noticed that when I have restarted
>the machine, some of the files I saved under a previous session were
>never actually written out to the disk. I'm assuming there is a disk
>cache or similar function that gets updated to the physical device upon
>unmounting.
[...]

Yes, you're right.

>Is there a way to cause the update to occur without un/remounting the
>disk? This way I'm one step closer to preserving my work in the event of
>a system crash.

You may give the mount option "sync" a try. See mount(8) for more.
[...]

Hope it helps,
Juergen

-- 
\ Real name     : J�rgen Heinzl                 \       no flames      /
 \ EMail Private : [EMAIL PROTECTED] \ send money instead /

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

From: [EMAIL PROTECTED] (Juergen Heinzl)
Subject: Re: struct passwd *
Date: Wed, 05 Apr 2000 22:49:20 GMT

In article <[EMAIL PROTECTED]>, Florian Heinz wrote:
>bill davidsen wrote:
>> 
>> In article <8cdkj5$pb0$[EMAIL PROTECTED]>,  <[EMAIL PROTECTED]> wrote:
>> 
>> | ok why does this program result in a SEGV? On solaris the exact code
>> | does not. Am I missing something, like the result is protected memory
>> | and when you try to free it, it will not let you? Any assistance would
>> | be appreciated!
>> 
>>   I'm suspicious that even though the man page under ERRORS says "ENOMEM
>> Insufficient memory to allocate passwd structure," I am suspicious that
>> the pointer may be to a static buffer rather than a malloced object. You
>> might malloc a small buffer and print the address (%p), then the pointer
>> returned before you try to free that. You might want fflush() in there.
>> 
>>   The Linux man page doesn't really say the buffer is dynamically
>> allocated, the error certainly implies that, and you are right in
>> free()ing it.
[...]

Yes .. no. If it would stay "the application must call free()" okay,
but it does not, so everything beyond "a pointer to a struct XXX is
being returned" is an assumption.

>>   Someone have the source for glibc handy? I don't, and I'm not going to
>> go grab it.
>> 
>>   You might also look at the code very hard to be sure that you don't
>> change the pointer, assuming that there is more code than you showed.
>> Pardon if there's not.
>
>Another way to find out is:
>
>struct passwd *one, *two;
>
>one = getpwuid(0);
>two = getpwuid(1);
>
>printf("%p - %p\n", one, two);
>
>on my system the values were identical, so this should be a static
>buffer... right?

I can be but it does not have too. It even can be a buffer
allocated on the first time the function is being called. You
are right so not to presume the returned pointers would address
different memory areas.

Cheers,
Juergen

-- 
\ Real name     : J�rgen Heinzl                 \       no flames      /
 \ EMail Private : [EMAIL PROTECTED] \ send money instead /

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

From: "Mark Langsdorf" <[EMAIL PROTECTED]>
Subject: Developers Wanted
Date: Wed, 5 Apr 2000 17:51:24 -0500

The Embedded Processor Division of Advanced Micro
Devices is looking for driver evelopers interested in
providing support for an ADSL on PCI solution.  We
are willing to provide technical support and hardware
for developers interested in this technology.  Our long
term goal is a driver, under the GPL, as part of the
standard kernel distribution, though we would prefer
a working solution in the short term.

If you are interested, please email Mark Langsdorf at
[EMAIL PROTECTED] for details.

-Mark Langsdorf




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

From: [EMAIL PROTECTED]
Crossposted-To: alt.os.linux,comp.os.linux.misc
Subject: Re: Bootdisks, rdev, and root filesystems...aargh!
Date: Wed, 05 Apr 2000 22:47:05 GMT

What i have done is used mkinitrd to make my
compressed image file, populated the image
filesystem and used lilo instead of dd'ing the
kernel straight to disk. The disadvantages of
this is that its a ext2 fs (dont accidently
format it in windows) you need at least /dev/fd0
and /dev/ram in the root of the floppy and your
nessecary /boot/boot.p /boot/map files. Im sure
the same thing can be accompilished with loadlin
on a msdos fs floppy and at least that way you
are less likely to format it in windows.

rhost


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

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


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