Linux-Development-Sys Digest #243, Volume #8     Mon, 30 Oct 00 05:13:13 EST

Contents:
  Re: Kernel API (Tux)
  Re: Linux API (Tux)
  Re: Building a Driver (Tux)
  Re: bind the same address/port pair 2 times in linux (Tux)
  Re: queue_task in 2.2.14 (Tux)
  memory usage realloc() ([EMAIL PROTECTED])
  Re: memory usage realloc() (Paul Kimoto)
  Re: rpm build qt-2.2.1 (Donovan Rebbechi)
  Re: Filesystem development ([EMAIL PROTECTED])
  Re: Linux API ([EMAIL PROTECTED])
  gtk+ ("Bill")
  Re: advice needed on process hierarchies (Nix)
  Re: Kernel API (Nix)
  Re: Linux API (Nix)
  Re: looking for ("Karl Heyes")
  modules in kernel-2.4.0-test9 (Timothy Murphy)
  Re: Device or resource busy (Kasper Dupont)
  Re: advice needed on process hierarchies (Kasper Dupont)
  Re: modules in kernel-2.4.0-test9 (Adam Gorecki)
  Re: memory usage realloc() (Philip Armstrong)
  Re: mount cdrom problem (Kasper Dupont)
  Re: using /linuxrc (Villy Kruse)
  About Embedded Linux and RAM disk (root)
  recvfrom() & sendto() (Maurizio Piana)
  Re: [Q] malloc() in signal handler (Nick Maclaren)

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

From: Tux <[EMAIL PROTECTED]>
Subject: Re: Kernel API
Date: Sun, 29 Oct 2000 20:39:47 +0100

try

gcc -O -D__KERNEL__ ...

Optimization needs to be activated because of some extra features. I'm
compiling my modules with

gcc -O -DMODULE -D__KERNEL__ -c foo.o

note, that kernel code is executed in kernel space. think of
adress-translation and other stuff.

Tux

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

From: Tux <[EMAIL PROTECTED]>
Subject: Re: Linux API
Date: Sun, 29 Oct 2000 20:50:27 +0100

Kernel code is changing really fast. So I trust in basics from
online-documents and "simply" having a look at the kernel code. Once
you've understood the basic structure, it isn't hard to find out what a
system call or driver routine does. Just try.

Tux

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

From: Tux <[EMAIL PROTECTED]>
Subject: Re: Building a Driver
Date: Sun, 29 Oct 2000 20:57:17 +0100

hi,

You could have a look at http://khg.redhat.com/HyperNews/get/khg.html
for basics.
Then you should inspect linux/fs.h and asm/uaccess.h for what has
changed (I had to).

in my view, a good example for simple drivers are mouse-drivers. just
have a look at them, when you know the theory about drivers.

Have a nice day
Tux

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

From: Tux <[EMAIL PROTECTED]>
Subject: Re: bind the same address/port pair 2 times in linux
Date: Sun, 29 Oct 2000 21:01:17 +0100

As I know, adress/port pairs are always unambigous. That's what they're
developed for. So I can't see any way to bind two sockets on one
adress/port pair.

Tux

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

From: Tux <[EMAIL PROTECTED]>
Subject: Re: queue_task in 2.2.14
Date: Sun, 29 Oct 2000 21:07:14 +0100

some more details would be useful - code for example.

compile your modul with gcc -O -DMODULE -D__KERNEL__ -c foo.c

are there unresolved macros? maybe you've forgotten an include?


Have a nice day
Tux

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

From: [EMAIL PROTECTED]
Subject: memory usage realloc()
Date: Sun, 29 Oct 2000 20:09:52 GMT

Has someone experience with ANSI library function realloc()? I have some
problems with this function.

I have something like below:
 int *p, *q;

 p=malloc(sizeof(int)*1024);
 q=realloc(p, sizeof(int)*1024*12);

 if (q!=p) {
    free(p);
 }

I have seg-fault here. Why?



I've seen that p and q point to different location, i.e. if I set

p[0]=3; q[0]=5;

I will get from

printf("p[0]=%d, q[0]=%d\n", p[0], q[0]);

something like "p[0]=3, q[0]=5"

So why I cannot free the memory pointed by p?

Does it mean if I run realloc many times, the memory will be used up?


thanks!



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

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

From: [EMAIL PROTECTED] (Paul Kimoto)
Subject: Re: memory usage realloc()
Date: 29 Oct 2000 16:46:44 -0500
Reply-To: [EMAIL PROTECTED]

The behavior of ANSI library functions in user programs is not a
c.o.l.d.system matter, but anyway ...

In article <8ti06d$ni$[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote:
> Has someone experience with ANSI library function realloc()? I have some
> problems with this function.
>
> I have something like below:
>
> int *p, *q;
>
> p=malloc(sizeof(int)*1024);
> q=realloc(p, sizeof(int)*1024*12);
>
> if (q!=p) {
>    free(p);
> }
>
> I have seg-fault here. Why?

Harbison and Steele (3rd edition) says:

: Whenever realloc returns a pointer that is different from its first
: argument the programmer should assume that the old region of memory was
: deallocated and should not be used.

So presumably realloc() has already free()d the memory pointed at by p.
In the Linux malloc() implementation, you can't free() the same memory more
than once; segfaults are a common result.

-- 
Paul Kimoto
This message was originally posted on Usenet in plain text.  Any images, 
hyperlinks, or the like shown here have been added without my consent,
and may be a violation of international copyright law.

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

From: [EMAIL PROTECTED] (Donovan Rebbechi)
Crossposted-To: comp.os.linux.development.apps,linux.redhat.rpm
Subject: Re: rpm build qt-2.2.1
Date: 29 Oct 2000 22:33:08 GMT

On Fri, 27 Oct 2000 07:46:34 +0200, O.Petzold wrote:
>Hallo,
>
>I have tryd to build the qt-2.2.1 archives from the qt-2.2.1-5.src.rpm.
>After the
>rpm -bb SPECS/qt.spec was finished I didn't found any rpm's inside
>the redhat/RPM dir or elswhere. The build sources are here and the
>/var/tmp/qt-root
>path for rpm-build are here but no rpm's.
>How can I create teh rpm at this stage ??

You should either get the build terminating with an error message, 
or a message that says is wrote an RPM and where it wrote it


-- 
Donovan

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

From: [EMAIL PROTECTED]
Subject: Re: Filesystem development
Date: Sun, 29 Oct 2000 23:17:02 -0000

On 29 Oct 2000 11:24:57 +0000 Elizabeth Clarke <[EMAIL PROTECTED]> wrote:

| I've implemented a (very simple) filesystem that happens to sit over
| a flash block device driver. I can read and write files fine. But I cannot
| execute a file from it directly. ldd reports that it is not a dynamic 
| executable. Ash reports syntax error "("..., bash says cannot execute 
| binary file. However I can copy my file to the initrd ramdisk and execute 
| it fine! So I can conclude that I'm not corrupting the file. It has to be 
| permissions of some description - I'm setting S_IFREG | 0777, which seem 
| plausible. I'm stumped. Any suggestions please...

Is the filesystem mounted to allow execute?  Is memory mapping implemented
in your filesystem?

-- 
| Phil Howard - KA9WGN | My current websites: linuxhomepage.com, ham.org
| phil  (at)  ipal.net +----------------------------------------------------
| Dallas - Texas - USA | [EMAIL PROTECTED]

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

From: [EMAIL PROTECTED]
Subject: Re: Linux API
Date: Sun, 29 Oct 2000 23:24:44 -0000

On Sat, 21 Oct 2000 13:57:45 -0700 Jim Fischer <[EMAIL PROTECTED]> wrote:

|> Hello there
|> Is the any documentation on Linux API just
|> like the M$ win API?
|
| The Linux source code *is* the Linux API. <g>

As soon as we drop the notion that one has to read massive amounts of
uncommented or poorly commented code in order to understand how to make
use of the code (modifying it is a different issue) then many more open
source projects will become more useful to more people.

I'm glad you put the "<g>" on there.  Too many people don't.  And that
tells me there is no design (or reason) to what many people do when they
code.


| Actually, there are some books available on the Linux kernel, but the kernel
| sources change so frequently that some of the content in these books is
| obsolete before the books are even published. IOW, you'll probably never
| walk into a Barns & Nobels bookstore and find a book that discusses the APIs
| of "recent" Linux kernels (e.g., the 2.4 kernels).

I don't know about Barnes & Noble, but I found one in Border's that talked
about the design of 2.4.  I didn't buy it because I don't need it (yet).

-- 
| Phil Howard - KA9WGN | My current websites: linuxhomepage.com, ham.org
| phil  (at)  ipal.net +----------------------------------------------------
| Dallas - Texas - USA | [EMAIL PROTECTED]

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

From: "Bill" <[EMAIL PROTECTED]>
Subject: gtk+
Date: Sun, 29 Oct 2000 17:38:48 -0600

Could anyone tell me how to build a window with GNOME/Gtk+ libraries that
DOES NOT have a border put on by the window manager?

Thanks.





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

From: Nix <$}xinix{[email protected]>
Subject: Re: advice needed on process hierarchies
Date: 29 Oct 2000 23:27:52 +0000

Lew Pitcher <[EMAIL PROTECTED]> writes:

> Nix wrote:
> > It's a bloody useless assignment, too; nobody calls fork() and then
> > keeps going down the same path they left, 
> 
> Not true, but the common use of fork() also includes exec()...
> However, the code to create a daemon uses a fork() _without_ an exec(),
> and does "keep going down the same path they left"

What, without checking for errors in the fork(), or anything?

Remind me not to use such daemons!

-- 
`Normally, we don't do people's homework around here, but Venice 
 is a very beautiful city, so I'll make a small exception.'
        --- Robert Redelmeier compromises his principles

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

From: Nix <$}xinix{[email protected]>
Subject: Re: Kernel API
Date: 29 Oct 2000 23:47:13 +0000

Tux <[EMAIL PROTECTED]> writes:

> try
> 
> gcc -O -D__KERNEL__ ...
> 
> Optimization needs to be activated because of some extra features.

That's a pretty safe statement. :)

You need to have optimization turned on because in all released versions
of GCC (ignoring the `released snapshot' in RedHat 7) function inlining
is only done when optimizing, and the kernel depends upon function
inlining being done (for port I/O, IIRC).

-- 
`Normally, we don't do people's homework around here, but Venice 
 is a very beautiful city, so I'll make a small exception.'
        --- Robert Redelmeier compromises his principles

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

From: Nix <$}xinix{[email protected]>
Subject: Re: Linux API
Date: 29 Oct 2000 23:49:46 +0000

Tux <[EMAIL PROTECTED]> writes:

> Kernel code is changing really fast. So I trust in basics from
> online-documents and "simply" having a look at the kernel code. Once
> you've understood the basic structure, it isn't hard to find out what a
> system call or driver routine does. Just try.

This is not true in all areas; for instance, the filesystems, memory
management, and general SMP concerns can be distinctly, er, unobvious.

Would that this were not true; however, I think that is unlikely; if the
algorithms are complex, the code will be complex. (MM is probably the
best example of this right now.)

-- 
`Normally, we don't do people's homework around here, but Venice 
 is a very beautiful city, so I'll make a small exception.'
        --- Robert Redelmeier compromises his principles

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

From: "Karl Heyes" <[EMAIL PROTECTED]>
Subject: Re: looking for
Date: Mon, 30 Oct 2000 01:13:33 +0000

In article <8sflr0$ktm$[EMAIL PROTECTED]>, "Roee Bachar"
<[EMAIL PROTECTED]> wrote:

> Hello all
> 
> I have Redhat 6.2 Linux and I'm looking for good help material on programming
> in linux my favorite programming language is C.
> 
> I want to know better on :
>     *    all of c libraries (such as stdio.h, graphics.h, bios.h ) for
> linux.

look in /lib /usr/lib /usr/local/lib files ending in .a .so for libraries
look in /usr/include for headers.

>     *    system programming ( how to us the ROM BIOS interrupts for
> example).

limited access, none for non-root user. 

>     *    how to program graphics in linux .

X -- try the toolkits  gtk, qt or the builders like glade.

>     *    multitasking commands for c.

try fork,exec for unix,  clone for linux specific or pthreads.

> 
> I mean all the help I can get :
>     *    files to read.
>     *    names of good books ( not for beginners ).
> 

man pages.  eg man strcpy.  man ncurses

karl.

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

From: [EMAIL PROTECTED] (Timothy Murphy)
Subject: modules in kernel-2.4.0-test9
Date: 30 Oct 2000 04:14:25 -0000

Modules are installed in the latest kernel
by establishing a symbolic link

/lib/modules/2.4.0-test9/build <- /usr/src/linux 

This seems quite dangerous to me --
what if one gets a new kernel version.
and makes /usr/src/linux point to that
(as is normal)?
Or what if one cleans /usr/src/linux?

It also seems contrary to what is said
in /usr/src/linux/Documentation/modules.txt .

-- 
Timothy Murphy  
e-mail: [EMAIL PROTECTED]
tel: 086-233 6090
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland

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

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: Device or resource busy
Date: Mon, 30 Oct 2000 08:29:57 +0100

J Wendel wrote:
> 
> In my limited experience, this error usually means that there is a
> interrupt assignment problem or an interrupt conflict. Sorry I can't
> offer more help.
> 
[...]

Not really, if the modules initialization fails the
kernel will return EBUSY no matter what the error
really was. So when insmod says init_module()
Device
or resource busy the error could be anything.

-- 
Kasper Dupont

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

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: advice needed on process hierarchies
Date: Mon, 30 Oct 2000 08:38:27 +0100

Nix wrote:
> 
[...]
> 
> What, without checking for errors in the fork(), or anything?
> 
> Remind me not to use such daemons!
> 
[...]

It can be done as simple as this:
if (fork()) exit(0);

That will handle errors correctly but
will not repport them, so a nice start
would look like this:

switch(fork()) {
default: exit(0);
case -1: perror("fork()"); exit(1);
case 0:
}

Here the parent process will exit
imediately while the child follows
the original path.

-- 
Kasper Dupont

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

From: Adam Gorecki <[EMAIL PROTECTED]>
Subject: Re: modules in kernel-2.4.0-test9
Date: Mon, 30 Oct 2000 07:35:21 +0100

Timothy Murphy wrote:
> 
> Modules are installed in the latest kernel
> by establishing a symbolic link
> 
> /lib/modules/2.4.0-test9/build <- /usr/src/linux
> 
> This seems quite dangerous to me --
> what if one gets a new kernel version.
> and makes /usr/src/linux point to that
> (as is normal)?
> Or what if one cleans /usr/src/linux?
> 
> It also seems contrary to what is said
> in /usr/src/linux/Documentation/modules.txt .
> 
> --
> Timothy Murphy
> e-mail: [EMAIL PROTECTED]
> tel: 086-233 6090
> s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland

Hi,

please, read the CHANGES file in kernel source directory.

kind regards,

Adam

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

From: [EMAIL PROTECTED] (Philip Armstrong)
Subject: Re: memory usage realloc()
Date: 29 Oct 2000 21:27:33 -0000

In article <8ti06d$ni$[EMAIL PROTECTED]>,  <[EMAIL PROTECTED]> wrote:
>Has someone experience with ANSI library function realloc()? I have some
>problems with this function.
>
>I have something like below:
> int *p, *q;
>
> p=malloc(sizeof(int)*1024);
> q=realloc(p, sizeof(int)*1024*12);
>
> if (q!=p) {
>    free(p);
> }
>
>I have seg-fault here. Why?

Because you're doing something silly :)

If the pointer returned by realloc is different from the one you first
got from malloc, then the original space will have *already* been
freed by the realloc call. Freeing it again will cause heap
corruption.

Phil



-- 
http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt


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

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: mount cdrom problem
Date: Mon, 30 Oct 2000 09:07:27 +0100

CDM wrote:
> 
> Check your kernel configuration (missing ISO9660 filesystem?), switch it on
> and rebuild.
> 
> "Christos Karayiannis" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]...
> > When I try to:
> >
> >  mount  /dev/cdrom
> >
> > I take the message
> >
> > mount: iso 9660 not sypported by kernel
> >
> >  What did I miss. I have to confess that I played with the kernel
> recently.
> > How can I restore things back?
> >
> >                 Thank you
> >

It might not be necesarry to rebuild the
kernel, if iso9660 is present in a module
you could just do an insmod iso9660. With
a properly setup /etc/conf.modules that
could be done automatically.

-- 
Kasper Dupont

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

From: [EMAIL PROTECTED] (Villy Kruse)
Subject: Re: using /linuxrc
Date: 30 Oct 2000 08:25:29 GMT

On 28 Oct 2000 10:05:21 +0200, Peter Pointner <[EMAIL PROTECTED]> wrote:

>
>My /linuxrc does not execute init. init never gets started, I simply don't
>need it for this embedded system. 
>


I wonder what the system in this case would do with orphaned processes,
you know, processes whose parent has exited and which are supposed
to be adopted by the init process.



Villy

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

From: root <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: About Embedded Linux and RAM disk
Date: Mon, 30 Oct 2000 16:41:41 +0800

Dear sir

I have tried to develop an Embedded Linux by using Red Hat EDK. However,
this tool have a lot of problem. The most important thing is how to
build a floppy which put a tiny linux into it. As studying the other
small linux, they usually a RAM disk. Where can I get some information
about creating a floppy with a small linux (not a distribution, by
manual)? How to create a RAM disk on my machine?

Please give me some advices and thanks a lot.

Alan Po
[EMAIL PROTECTED]


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

From: Maurizio Piana <[EMAIL PROTECTED]>
Subject: recvfrom() & sendto()
Date: 30 Oct 2000 09:38:23 GMT

Hi all, I'm searching for the source code of recvfrom() and sendto()
functions but all that I can find is the prototypes of these two
functions. Does any of you know where to find the source code?

I'm trying to understand how these functions work to produce an udp 
packet from an input [using functions in udp.c file] and reverse
(from packet --> original data).

Thanx

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

From: [EMAIL PROTECTED] (Nick Maclaren)
Subject: Re: [Q] malloc() in signal handler
Date: 30 Oct 2000 09:59:12 GMT

In article <8tgr27$199$[EMAIL PROTECTED]>,
Philip Armstrong <[EMAIL PROTECTED]> wrote:
>In article <8tgof7$9td$[EMAIL PROTECTED]>,
>Nick Maclaren <[EMAIL PROTECTED]> wrote:
>>If anyone reckons they could tackle this problem, I should be VERY
>>glad to help!  But it is a horrendous task, and flies in the face
>>of a lot of current practice.
>
>And historically, the libc has been authored by the FSF, whilst the
>kernel has very definately been a seperate project entirely, so the
>co-operation between hasn't been as tight as it might be in, say, the
>FreeBSD project.

Which doesn't help, even though I would sooner start tackling this
in Linux/GLIBC than in FreeBSD - and I have looked at both!

>Have you had any success in emailing the glibc authors? Or posted
>anything to linux-kernel? Given the current large thread on
>replacing poll() altogether with something slightly more sane, I get
>the impression that the kernel hackers are open to at least discussing
>this kind of stuff. 

No, because I rapidly came to the conclusion that little useful could
be done without a complete redesign, top to bottom, starting from
scratch.  Yes, unfortunately :-(

This isn't because GLIBC is a mess (though it is), but because the
basic Unix design (i.e. atomic system calls etc.) is thread-safe
but not signal safe.  Therefore fixing the libraries to be thread-
safe was a feasible proposition, but hacking it to be signal-
safe is another matter entirely.

Some systems have attempted to introduce the concept of restartable
system calls, but I can't think of a way that they could be
added to Linux and made usably reliable without a massive change
to the specification and code like GLIBC.  The problem isn't the
simple one of returning and restarting the call, but ensuring that
the handler hasn't changed some active data.

I have spent some time in the past decade in attempting to get
the official standards (mainly C, but also POSIX) improved, and 
have failed.  Spectacularly.  Assuming that this latest request
for interpretation gets through, I shall have FINALLY have got it
admitted that this is a real problem.  As I retire in 15 years,
I am not going to attempt to get it actually fixed in them.

My main point in posting this sort of thing is in case anyone
has the energy and time to tackle it, when a prod at the right
time can start them thinking about the issue.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  [EMAIL PROTECTED]
Tel.:  +44 1223 334761    Fax:  +44 1223 334679

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


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