Linux-Development-Sys Digest #324, Volume #8      Tue, 5 Dec 00 09:13:15 EST

Contents:
  c++ in kernel and linker problems ("O.Petzold")
  Re: injecting virtual console keystrokes (Kaz Kylheku)
  Re: Module Compilation Problems (Philip Armstrong)
  Re: c++ in kernel and linker problems (Philip Armstrong)
  Re: c++ in kernel and linker problems (Mathias Waack)
  sys_close & fd's ??? (byteme)
  Re: injecting virtual console keystrokes ([EMAIL PROTECTED])
  Re: sys_close & fd's ??? ([EMAIL PROTECTED])
  kernel header problems ("O.Petzold")
  Re: Please help: NT to Linux port ("Carlos Portela")
  Re: sys_close & fd's ??? (Erik Hensema)
  Re: Global constructors in ELF so libs NOT CALLED! (Erik Westlin)
  Re: kernel header problems (Mathias Waack)
  Unresolved symbols in modules during startup (arnoud)
  plip on thinkpads - broke since 2.2.14 (robert w hall)
  Re: Development Environments ([EMAIL PROTECTED])
  LINUX on PC104 ("Maurizio Stefani")
  Re: LINUX on PC104 ("Slawek Grajewski")

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

From: "O.Petzold" <[EMAIL PROTECTED]>
Subject: c++ in kernel and linker problems
Date: Tue, 05 Dec 2000 08:40:04 +0100

Hello,

I try to write C++ for a linux kernel module, since I use the same code
for the real app und the module. The problem is, I can't use exceptions
and rtti, so I have to emulate this. The first I use a global flag, the
2nd - no
idea. Well, I have now linking problems - I get:

no_xception_test.o: unresolved symbol __vt_9bad_alloc
no_xception_test.o: unresolved symbol _._9bad_alloc
no_xception_test.o: unresolved symbol __9exception
no_xception_test.o: unresolved symbol __vn__FUiRC9nothrow_t
no_xception_test.o: unresolved symbol nothrow

vt stands for virtual table - I guess this all is from name mangeling.
I use THROW(std::bad_alloc) inside the construct

struct XCeption {
    bool here;
    char* what_str;
    const char* what() { return what_str; }
};

#define THROW(e)

expands to

throw e;

in normal use and to

XCeption.here = true;
XCeption.what_str = e.what();

Further more I use in the source
char *p = new(nothrow) char[39]
if(!p) {
    THROW(std::bad_alloc);
}

The new/delete operator is written new for the kernel space (the keyword

nothrow has no meaning there).

The nothrow symbol is defined inside header new with
extern const nothrow_t nothrow;
That's all what I found. How can I write the classes nothrow, exception
and
bad_alloc so that I don't get linker errors ?

// this doesn't compile
#include <memory>

const nothrow_t nothrow() {
    return nothrow_t();
}



Thanks    Olaf


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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: injecting virtual console keystrokes
Reply-To: [EMAIL PROTECTED]
Date: Tue, 05 Dec 2000 07:39:24 GMT

On Tue, 05 Dec 2000 06:47:48 -0000, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>I've looked in the kernel source, and it looks like it should be
>very easy to inject at least a few ASCII input characters into a
>virtual console tty.  There are some escape sequences that cause
>responses to come back, and what they do seems rather easy.  So
>my thought is I could add a new ioctl call where the argument is
>a string of characters to be injected.  It doesn't look like it
>would be very much code, either, since the important stuff seems
>to all be there already.

Here is a research topic for you: how does gpm implement cut
and paste?

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

From: [EMAIL PROTECTED] (Philip Armstrong)
Subject: Re: Module Compilation Problems
Date: 5 Dec 2000 08:45:22 -0000

In article <90hss0$o1j$[EMAIL PROTECTED]>,
Brian <[EMAIL PROTECTED]> wrote:
>Perhaps I'm not doing it the professional way. But it just sounds strange to
>me that I have to delete the system files supplied by the distributor in
>order to restore the link.
>

Just move them to one side:

$ cd /usr/include
$ mv linux linux_system_headers
$ ln -s /usr/src/linux/include/linux .

is what I tend to do, with an extra symlink in /usr/src pointing to
the right set of kernel sources.

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


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

From: [EMAIL PROTECTED] (Philip Armstrong)
Subject: Re: c++ in kernel and linker problems
Date: 5 Dec 2000 08:49:41 -0000

In article <[EMAIL PROTECTED]>,
O.Petzold <[EMAIL PROTECTED]> wrote:
>Hello,
>
>I try to write C++ for a linux kernel module, since I use the same code
>for the real app und the module. The problem is, I can't use exceptions
>and rtti, so I have to emulate this. The first I use a global flag, the
>2nd - no
>idea. Well, I have now linking problems - I get:
>

I think that you're going to find that there isn't the runtime
support code in the kernel to allow c++ code to work.

However, one thing that occurs to me is to ask if you're adding the
flags "-fno-rtti -fno-exceptions" to g++ when you compile the module;
otherwise it'll try and look for the exception handling symbols
whether you're using them in your code or not, as exceptions get
thrown by STL objects etc.

I still think it's unlikely to work however...

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


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

From: Mathias Waack <[EMAIL PROTECTED]>
Subject: Re: c++ in kernel and linker problems
Date: 05 Dec 2000 10:33:56 +0100

"O.Petzold" <[EMAIL PROTECTED]> writes:

> I try to write C++ for a linux kernel module, since I use the same
> code for the real app und the module. The problem is, I can't use
> exceptions and rtti, so I have to emulate this. The first I use a
> global flag, the 2nd - no idea. Well, I have now linking problems - I

The 2nd was solved (before the "invention" of rtti) by a virtual method 
int type() in each class. This method must be overloaded in each subclass 
and you should use uniq type-ids in your application. 

> Further more I use in the source char *p = new(nothrow) char[39]
> if(!p) {
>     THROW(std::bad_alloc); }

Hmm, if you use std::bad_alloc in kernel code, you must IMHO link 
your module statically with the libstdc++. Bad idea I think...

> The nothrow symbol is defined inside header new with extern const
> nothrow_t nothrow; 

Thats a declaration, not a definition. Are you sure that nothrow is 
defined somewhere?

> That's all what I found. How can I write the
> classes nothrow, exception and bad_alloc so that I don't get linker
> errors ?

Try to declare your own bad_alloc class first. 

Mathias

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

From: [EMAIL PROTECTED] (byteme)
Subject: sys_close & fd's ???
Date: Tue, 05 Dec 2000 09:37:31 GMT

Does anyone know how to assoc. a fd to a file name  ??

In other words , when a file descriptor is passed to sys_close, I need
to find out what file is beiing closed by name. I need to assoc FD to
the actual filename.  I'm keep going around in circles chassing this
down


                thanx 
                        kevin

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

From: [EMAIL PROTECTED]
Subject: Re: injecting virtual console keystrokes
Date: Tue, 05 Dec 2000 09:53:33 -0000

On Tue, 05 Dec 2000 07:39:24 GMT Kaz Kylheku <[EMAIL PROTECTED]> wrote:
| On Tue, 05 Dec 2000 06:47:48 -0000, [EMAIL PROTECTED]
| <[EMAIL PROTECTED]> wrote:
|>I've looked in the kernel source, and it looks like it should be
|>very easy to inject at least a few ASCII input characters into a
|>virtual console tty.  There are some escape sequences that cause
|>responses to come back, and what they do seems rather easy.  So
|>my thought is I could add a new ioctl call where the argument is
|>a string of characters to be injected.  It doesn't look like it
|>would be very much code, either, since the important stuff seems
|>to all be there already.
|
| Here is a research topic for you: how does gpm implement cut
| and paste?

It does an ioctl to instruct the kernel to copy the data to a buffer.
That's for copy (not cut).  For paste, it then does another ioctl to
instruct the kernel to insert the buffer into the input stream.  But,
there is no ioctl for taking data from process space.  Although you
could fake this by writing data to a screen, doing the copy ioctl,
then doing the past ioctl, this is limited to character codes which
can be displayed on the screen.  Control codes apparently cannot be
handled.

-- 
=================================================================
| Phil Howard - KA9WGN |   Dallas   | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/     |
=================================================================

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

From: [EMAIL PROTECTED]
Subject: Re: sys_close & fd's ???
Date: Tue, 05 Dec 2000 10:37:10 -0000

On Tue, 05 Dec 2000 09:37:31 GMT byteme <[EMAIL PROTECTED]> wrote:

| Does anyone know how to assoc. a fd to a file name  ??
|
| In other words , when a file descriptor is passed to sys_close, I need
| to find out what file is beiing closed by name. I need to assoc FD to
| the actual filename.  I'm keep going around in circles chassing this
| down

When open does its thing, it builds appropriate data structures
which make references to the actual data objects, namely the inode.
The file NAME is irrelevant once open is complete.  The name can
be unlinked or renamed.  There may be more than one name.

To better understand this, think of the filesystem as a flat linear
space of files with numbers on them.  Now add on top of that a means
to have names which point to those numbers.  That's what a filesystem
is, at least in UNIX.

That said, you might want to grab the source code to the "lsof"
program and see what it does.

-- 
=================================================================
| Phil Howard - KA9WGN |   Dallas   | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/     |
=================================================================

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

From: "O.Petzold" <[EMAIL PROTECTED]>
Subject: kernel header problems
Date: Tue, 05 Dec 2000 12:30:21 +0100

Hello,

I wan't to include this:
#include <linux/config.h>
#include <linux/types.h>  // size_t
#include <stddef.h>           // size_t

#include <linux/mm.h>    // GFP_KERNEL
#include <linux/slab.h>   // kmalloc
#include <linux/vmalloc.h> // vmalloc

but I get a lot of errors.

# g++ -I/usr/include/linux -W -Wall -D__KERNEL__ -c t.cc
In file included from /usr/include/linux/sched.h:13,
                 from /usr/include/linux/mm.h:4,
                 from kernel_new.h:31,
                 from cpp_interface.cc:11:
/usr/include/linux/times.h:5: syntax error before `;'
/usr/include/linux/times.h:6: syntax error before `;'
/usr/include/linux/times.h:7: syntax error before `;'
/usr/include/linux/times.h:8: syntax error before `;'
In file included from /usr/include/linux/timex.h:142,
                 from /usr/include/linux/sched.h:14,
                 from /usr/include/linux/mm.h:4,
                 from kernel_new.h:31,
                 from cpp_interface.cc:11:
/usr/include/linux/time.h:10: syntax error before `;'
/usr/include/linux/time.h: In function `long unsigned int
timespec_to_jiffies(timespec *)':
....

What does I have to include, so that I don't get these bunch of errors ?

Thanks    Olaf



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

From: "Carlos Portela" <[EMAIL PROTECTED]>
Subject: Re: Please help: NT to Linux port
Date: Tue, 5 Dec 2000 06:16:41 -0500

Thanks to all who replied to my post.

As someone indicated in his/her response the protection violations that I am
trying to catch are generated by bad programming and the proposed solution
is to fix the code that generates them.  In a perfect world I would agree
100% with that proposal but when you have hundreds of thousands of lines of
code written by several programmers over years of work it is nearly
impossible to cover all the possibilities and in this particular case
recovering from the violation, freeing resources, etc is very easy.

Although catching exceptions for this purpose is not pretty nor perfect it
does allow the product to continue to operate reliably 24 x 7 and the client
side is informed of the situation immediately. The truth is we very seldom
see one of these exceptions but it surely is nice to catch them and
gracefully recover when they occur.

Once again I thank all who replied to my post.  If you have any further
ideas about how I can implement something like this please let me know.

Carlos

Karl Heyes wrote in message <90h910$6ti$[EMAIL PROTECTED]>...
>In article <90gah5$1ab0$[EMAIL PROTECTED]>, "Carlos Portela"
><[EMAIL PROTECTED]> wrote:
>
>>
>>
>> This code is not being used to catch normal exceptions thrown by the
>> code underneath but instead it is being used to catch memory
>> protection violations and other exceptions generated by Windows.
>>
>> My question is:
>>
>> Is this behaviour of the try-catch pair available in Linux?  If not
>> then, can you suggest an alternate implementation?  In other words,
>> how can I obtain control if the code I called (in this case
>> CallSomeFunction) screws up?
>>
>
>The code follows the C++ standard so yes it will work as long as you
>have an uptodate G++, most distros usually will have at least egcs
>1.1.2 which seems to be fine for exceptions that I've used.  There
>may be cases where it may have problems though, haven't seen any!.
>The recent versions are 2.95.2.  and some class that as out of date,
>but I suspect that you will be ok.
>
>karl.



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

From: [EMAIL PROTECTED] (Erik Hensema)
Subject: Re: sys_close & fd's ???
Date: Tue, 5 Dec 2000 11:04:05 +0100
Reply-To: [EMAIL PROTECTED]

byteme ([EMAIL PROTECTED]) wrote:
>Does anyone know how to assoc. a fd to a file name ??

Can't be done.

>In other words , when a file descriptor is passed to sys_close, I need
>to find out what file is beiing closed by name. I need to assoc FD to
>the actual filename.  I'm keep going around in circles chassing this
>down

Ever heard of hard links? Any number of filenames may point to a single
inode. fd's also point to inodes. So, when you open a file, you lookup the
inode number in the directory, open the file and assign a fd to the open
inode.

Worse: a file can be deleted when you close it. Then it doesn't even have a
name!

So, what ugly kind of thing are you trying to do?

-- 
Erik Hensema ([EMAIL PROTECTED])
"In short, _N is Richardian if, and only if, _N is not Richardian."

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

From: Erik Westlin <[EMAIL PROTECTED]>
Subject: Re: Global constructors in ELF so libs NOT CALLED!
Date: Tue, 05 Dec 2000 13:02:31 +0100
Reply-To: [EMAIL PROTECTED]

John C. Griggs wrote:
> 
> 
> Well, what was your intention?  Surely you weren't expecting someone who
> needed your little tutorial to be of any help?  BTW, what OO language
> were you programming in "nearly 20 years" ago?
> 
Simula http://www.cetus-links.org/oo_simula.html
> 

I too have had my share of BIG (void)s (i'm not refering to you John)
who instead of answering questions like to comment on the way the 
question was put.

Well i thought it would be an easy answer for whoever knew it.
I don't think i'm doing anything out of the ordinary so
there ought to be others who have walked into the same trap.
Anyway global objects/variables has allways been considered bad 
and i might as well not us them if i could.

Maybe i do something non-ordinary, i'm porting a program
from NT to linux. This make use of DCOM which has been ported
to linux and is available for non-commercial use.
See http://www.softwareag.com/entirex/download/free_download.htm
DCOM makes heavy use of so-libs or dll's as they are called in
windows.
Anyway along the EntireX distribution comes several examples
and they have another build command. I didn't use it for my
own libs at first but now i tried it and now everything works!

LIBRARY_LINKER_NAME = g++

LIBRARY_LD_FLAGS = \
          -g \
          -shared \
          -Wl,-Bsymbolic,-t

LIBRARY_LINKLIBS = \
          -L$(DCOLIB) \
          -lmutantstubs \
          -L$(DCOLIB) \
          -lole32 \
          -lrpcrt4 \
          -lntrtl \
          -lmutant \
          -lcoolmisc \
          $(TRACELIB) \
          -lpthread \
          -lc \
          -ldl \
          `gcc --print-libgcc-file`

$(OUTFILE): $(SOBJS)
  $(LIBRARY_LINKER_NAME) -o$(OUTFILE) $(LIBRARY_LD_FLAGS) \
       $(SOBJS) $(LIBRARY_LINKLIBS) $(LIBS)

I don't know what makes the difference but i will ask the EntireX
people.

Regards,
         Erik

=========================================================================

       Erik Westlin                   Manne Siegbahn Laboratory
       email: [EMAIL PROTECTED]

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

From: Mathias Waack <[EMAIL PROTECTED]>
Subject: Re: kernel header problems
Date: 05 Dec 2000 13:15:38 +0100

"O.Petzold" <[EMAIL PROTECTED]> writes:

> What does I have to include, so that I don't get these bunch of errors
> ?

Looks like missing type declaration for time_t and clock_t. Try to 
include time.h

Mathias

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

From: arnoud <[EMAIL PROTECTED]>
Subject: Unresolved symbols in modules during startup
Date: Tue, 05 Dec 2000 13:17:39 +0100

Hi,

After compiling the kernel and copy it to /boot
and running lilo, the kernel will boot but get
a lot of Unresolved Symbols on all the modules in
/lib/modules/<kernel>

Yes I did a make modules and make modules_install
after the make.

E.g. if I want to load the module ide-scsi, jiffies and
printk are unresolved.

Does anyone know how to correct this?

Arnoud.


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

From: robert w hall <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.portable
Subject: plip on thinkpads - broke since 2.2.14
Date: Tue, 5 Dec 2000 12:18:22 +0000

plip, which I use extensively to network my old laptop and desktop
together, got broke in kernel 2.2.14 (due to a FIFO error I recollect).
It was ostensibly fixed in 2.2.15 and beyond, and these later versions
work fine on my 686 desktop; but plip in all these later versions  fails
to run on my laptop (a 755ce stinkpad). When pinged from the desktop, I
only get back a series of plip transmit timeout errors.

I've also tried plip in the successive slack network-install boot-disks
as they've been produced, and these have also failed to network after
2.2.13.

Anyone know the possible root cause of this problem? (It can't just be
finger trouble, I claim - the setup & config files are unchanged between
working and non-working builds).

(I posted the problem/anomaly some time back, when it first arose with
2.2.15, to comp.os.linux.portable, with zilch response.) 
-- 
robert w hall

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

From: [EMAIL PROTECTED]
Subject: Re: Development Environments
Date: Tue, 05 Dec 2000 13:40:00 GMT

"Guy Dillen" <[EMAIL PROTECTED]> writes:
> With development environmet i mean in fact an IDE. Where you have
> high productivity when developing applications. These application
> needs to run in character-based mode as well GUI mode.

The Unix shell _is_ interactive, and intelligent use of Make, tags,
and such does provide pretty high interactivity, working both in
console mode as well as in Xterms atop X.
-- 
(concatenate 'string "cbbrowne" "@hex.net") <http://www.ntlug.org/~cbbrowne/>
Non-determinism means never having to say you're wrong.

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

From: "Maurizio Stefani" <[EMAIL PROTECTED]>
Subject: LINUX on PC104
Date: Tue, 5 Dec 2000 14:33:52 +0100

Hi,
I would like to use Linux on a PC104 system without hard-disk.

Is there someone able to help saying if is it possibile?
If yes could I have the ref.

Thank you in advance

--
========================================================================
** Maurizio Stefani
**
**
** ELE.SI.A. S.r.l.
** ISO 9001 CERTIFIED
** Tel. 39.06.8813320 (int 221) / Fax 39.06.8813352
** http://www.elesia.it
========================================================================



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

From: "Slawek Grajewski" <[EMAIL PROTECTED]>
Subject: Re: LINUX on PC104
Date: Tue, 5 Dec 2000 15:01:49 +0100

Yes, it is possible. Embedded Linux-es I know use DiskOnChip techonology.
References:
www.diskonchip.com
www.mvista.com
www.lineo.com
embedded.linuxjournal.com

Slawek


Maurizio Stefani wrote in message <90ir1n$s82$[EMAIL PROTECTED]>...
>Hi,
>I would like to use Linux on a PC104 system without hard-disk.
>
>Is there someone able to help saying if is it possibile?
>If yes could I have the ref.
>
>Thank you in advance
>
>--
>------------------------------------------------------------------------
>** Maurizio Stefani
>**
>**
>** ELE.SI.A. S.r.l.
>** ISO 9001 CERTIFIED
>** Tel. 39.06.8813320 (int 221) / Fax 39.06.8813352
>** http://www.elesia.it
>------------------------------------------------------------------------
>
>



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


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