Linux-Development-Sys Digest #372, Volume #8 Sat, 23 Dec 00 17:13:10 EST
Contents:
pivot_root and ramfs (really just pivot_root) ([EMAIL PROTECTED])
libpcap problem (Jen-Chieh Tang)
Compiling glibc 2.2 ("Fruitbat")
Re: Looking for device driver references for Linux 2.2 kernel. (Andrey Valik)
Re: Libraries (Roland Smith)
Re: IEEE standards (HomerWelch)
Re: IEEE standards (Kaz Kylheku)
Re: front ending libraries (even libc) ("Arthur H. Gold")
Re: pivot_root and ramfs (really just pivot_root) ("urp")
Re: Libraries (Andrew Clark)
----------------------------------------------------------------------------
From: [EMAIL PROTECTED]
Subject: pivot_root and ramfs (really just pivot_root)
Date: Sat, 23 Dec 2000 08:09:58 -0000
If I have created a ramfs as /ramfs, with the intent to pivot
that filesystem to become / (previous root will become /old)
and if I had a filesystem mounted as /ramfs/foo, what will
happen to that filesystem when the pivot_root call is done?
The kernel source documentation isn't clear with regard to
how pivot_root affects other existing mounts. Do they move
along with the 2 moving mount points, or do they just keep
their exact original paths?
--
=================================================================
| Phil Howard - KA9WGN | Dallas | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/ |
=================================================================
------------------------------
From: Jen-Chieh Tang <[EMAIL PROTECTED]>
Subject: libpcap problem
Date: 23 Dec 2000 08:48:49 GMT
Hello :
I am posting this message in the forum since I
haven't been getting any luck at the linux.networking
forum. I am running RH 7.0 with gcc version 2.96 and
ld version 2.10.90 with all patches installed.
However, when I run my libpcap code below, it never
comes out of pcap_dispatch, or calls the packet
handler. This code worked on FreeBSD, so I am really
confused. Any help would be greatly appreciated.
Thanks.
/*-------------------------------------------------------------------------------
//
// Filename : sniffer.c
// Date : 12/07/2000
//
// Description :
// -------------
// Grabs sockets of the libpcap/bpf interface.
//
// To Do :
// -------
// - Typecast everything into packets, eval protocol type and
// send off for processing.
//
// - Define system error codes
//
// - Provide for parameter overrides.
//
// - Provide for changing between NICs.
//
//-----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <pcap/pcap.h>
#define SNAPLEN 8192 /* Ethernet segment max is like 1560 */
#define PROMISC 1 /* Set device into promiscuous mode */
#define TIMEOUT 1000 /* Timeout in ms */
#define COUNT 0 /* How many packets to process in a loop */
static void packet_process (u_char *pcap_data, const struct pcap_pkthdr
*packet_header, const u_char *packet)
{
#ifdef _DEBUG_
fprintf (stderr, " In Packet Process\n");
fprintf (stderr, " Protocol : %d\n", packet_header->protocol);
fprintf (stderr, " Packet Length : %d\n", packet_header->len);
#endif
}
int main ()
{
pcap_t *pcap_structure;
char *pcap_device;
char pcap_error[10000];
int return_value;
pcap_device = pcap_lookupdev (pcap_error);
if (!pcap_device)
{
fprintf (stderr, " Error : pcap_lookupdev\n");
fprintf (stderr, " Return String : %s\n", pcap_error);
exit (-1);
}
#ifdef _DEBUG_
fprintf (stderr, " Pcap device is : %s\n", pcap_device);
#endif
pcap_structure = pcap_open_live (pcap_device, SNAPLEN, PROMISC, TIMEOUT,
pcap_error);
if (!pcap_structure)
{
fprintf (stderr, " Error : pcap_open_live\n");
fprintf (stderr, " Return String : %s\n", pcap_error);
exit (-1);
}
return_value = pcap_dispatch (pcap_structure, 1 , packet_process, NULL);
if (!return_value)
{
fprintf (stderr, " Error : pcap_dispatch\n");
fprintf (stderr, " Return Value : %d\n", return_value);
exit (-1);
}
printf ("Exit\n");
exit (0);
}
--
Tom Tang
[EMAIL PROTECTED]
------------------------------
From: "Fruitbat" <[EMAIL PROTECTED]>
Subject: Compiling glibc 2.2
Date: Sat, 23 Dec 2000 11:29:26 GMT
Sorry if this has been asked before, but I have scanned the news groups and
cant seem to find an answer to my questions.
I'm running RedHat 6.2 and a 2.2.18 kernel on my intel box, and wish to
upgrade to glibc 2.2. I have downloaded the source and read the readmes and
have a couple of questions before I start. I am also using PAM and shadow
passwords, and GNOME if it makes a difference to my questions, I'm not sure.
do I really need to down load and use the Berkeley db files, I know its
available from www.sleepycat.com , and if so which version as there are
several.
what is the nss_db-2.2 and nss_lres-0.91 files, and do I need them?
Also is there a later version of glibc-crypt than 2.1?
I apologise, if this has already been answered somewhere but I cant seem to
find the answers I need, and I DON'T want to go to RedHat 7.0 just to use
glibc 2.2. Many thanx!
--
Regards Geoff :)
==================
[EMAIL PROTECTED]
------------------------------
From: Andrey Valik <[EMAIL PROTECTED]>
Subject: Re: Looking for device driver references for Linux 2.2 kernel.
Date: Sat, 23 Dec 2000 19:06:18 +0500
M Boerner wrote:
>
> Hi:
>
> I must be looking in the wrong places, but I am looking for reference
> material on the differences between the 2.0 and 2.2 kernels for device
> drivers.
>
> Thanks in advance.
>
> Michael
I don't know where it placed, but I know next differences:
1.
#ifdef 2.0
#include <linux/bios32.h>
#else 2.2
#include <asm/uaccess.h>
#endif
2.
#ifndef 2.2
static int device_read( struct inode * inode, struct file * file, char * buf, int
count );
static int device_write( struct inode * inode, struct file * file, const char *
buf, int count );
static int device_seek( struct inode * inode, struct file * file, off_t offset,
int whence );
static void device_close( struct inode * inode, struct file * file );
#else
static int device_read( struct file * file, char * buf, size_t count, loff_t*
whence );
static int device_close( struct inode * inode, struct file * file );
static loff_t device_seek( struct file * file, loff_t offset, int whence );
static int device_write( struct file * file, const char * buf, size_t count,
loff_t* offs );
#endif
3.
#ifndef 2.2
static struct file_operations grb_fops =
{
device_seek, /* seek */
device_read, /* read */
device_write, /* write */
NULL, /* readdir */
NULL, /* select */
device_ioctl, /* ioctl */
NULL, /* mmap */
device_open, /* open */
device_close, /* release */
NULL, /* fsync */
NULL, /* fasync */
NULL, /* check_media_change */
NULL /* revalidate */
};
#else
static struct file_operations grb_fops =
{
device_seek, /* seek */
device_read, /* read */
device_write, /* write */
NULL, /* readdir */
NULL, /* select */
device_ioctl, /* ioctl */
NULL, /* mmap */
device_open, /* open */
NULL, /* ????? */
device_close, /* release */
NULL, /* fsync */
NULL, /* fasync */
NULL, /* check_media_change */
NULL /* revalidate */
};
#endif
4.
#ifndef NEW_KERNEL
dev.mem0 = (unsigned long*)vremap( pci_ioaddr, 0x01000000 );
#else
dev.mem0 = (unsigned long*)ioremap( pci_ioaddr, 0x01000000 );
#endif
5.
#ifndef NEW_KERNEL
num = get_user( arg );
#else
get_user( num, arg );
#endif
6.
#ifndef NEW_KERNEL
memcpy_tofs( p, p1, width );
#else
copy_to_user( p, p1, width );
#endif
--
+----------------------+
| Andrey V. Valik |
| Papillon Systems |
|Mailto:[EMAIL PROTECTED]|
+----------------------+
------------------------------
Subject: Re: Libraries
From: Roland Smith <[EMAIL PROTECTED]>
Date: 23 Dec 2000 18:35:54 +0100
Andrew Clark <[EMAIL PROTECTED]> writes:
> Hi, could someone please tell me how to create libraries in Linux. In
> Windows there's DLL's and am needing to do something similar for Linux.
You should use gcc's -shared option. Next to that you also need to set the
library's soname (that's not a typo). I'm not sure what soname means, I
think it means "Shared Object NAME".
Suppose you've got a couple of C files; foo.c and bar.c, and you want to
make a library named gnarf. Then the command to link the library is:
gcc -shared -Wl,-soname,libgnarf.so.1 -o libgnarf.so.1.0.0 foo.o bar.o
if you install libgnarf in (say) /usr/local/lib, you should also also
create some symbolic links: (# means you should do this as root).
# cp libgnarf.so.1.0.0 /usr/local/lib/
# cd /usr/local/lib/
# ln -s libgnarf.so.1.0.0 libgnarf.so.1
# ln -s libgnarf.so.1.0.0 libgnarf.so
I've got a standard makefile for producing libraries. mail me if you want a
copy.
> If there is any sort of way to create libraries/modules could someone
> please tell me, and also how to do runtime linking as like DLL's.
You can link your programs with this shared library in two ways:
1) Just use gcc's -l flag. In this case you need to do "-lgnarf" and _not_
"-llibgnarf" (the "lib" prefix is implied). This is the preferred method
for normal libraries.
2) Open the library with dlopen. Then you can use dlsum to get the address
of a symbol in the library. This method is useful e.g. for loading plugins.
Hope this helps, and happy winter solistice ;-)
Roland
--
Roland Smith "When life hands you a lemon,
r s m i t h @ x s 4 a l l . n l make lemonade."
http://www.xs4all.nl/~rsmith/
------------------------------
From: HomerWelch <[EMAIL PROTECTED]>
Subject: Re: IEEE standards
Date: Sat, 23 Dec 2000 19:32:03 GMT
David Wragg wrote:
>
> HomerWelch <[EMAIL PROTECTED]> writes:
> > I doubt whether it is patentable, but it is copyrighted. I
> > remember reading a magazine article by a guy who was on the
> > committee to standardize the C Programming Language. He
> > wanted a copy of the released standard. IEEE wouldn't give
> > him one. He had to pay for it. So much for volunteering on
> > IEEE committees.
>
> C was standardised under the auspices of ISO and ANSI, not IEEE.
My error. He was a member of the ANSI ISO committees.
>
> Participating in ISO standard committee has traditionally involved
> attending several meetings a year held in various locations around the
> world, and finalizing these kinds of standards tends to take several
> years. So over the course of the process, a participant will usually
> need to come up with many thousands of dollars for travel, hotels,
> etc., not to mention the value of their time. So while not giving a
> participant a copy of the final standard seems a bit mean, I doubt
> that it could be much of a factor for anyone who was serious about
> contributing to a standard.
>
> I suspect that IEEE meetings are usually held in the US. But that
> probably doesn't make much of a difference to the costs involved.
>
> Of course, it is likely that over time the ubiquitous use of the
> Internet will affect how standards get written. But some face-to-face
> meetings will probably always be needed in the development of any
> non-trivial technical standard.
>
> Now why the last draft of IEEE 1003.1g (POSIX sockets) costs 80
> dollars when the development of that standard has been discontinued
> (except as part of the Austin Group activities), I have no idea.
The high cost of copies of standards from organizations has
been a pet peeve of mine. Unless you have deep pockets or
corporate sponsorship, it is difficult to come up with the
cost of these items. The high cost seems to be contrary to
the principle of freely disseminating knowledge.
Recouping costs of standardizing committees is a problem.
The internet RFC's point toward a method of accomplishing
this task. I don't know how they do it, but I can access
any RFC over the internet without additional cost. As a
counter example, I just accessed http://www.ansi.com/ , and
they want $10.00 to download a PDF catalog without prices.
--
Homer J. Welch [EMAIL PROTECTED]
Troy, Michigan
------------------------------
From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: IEEE standards
Reply-To: [EMAIL PROTECTED]
Date: Sat, 23 Dec 2000 19:32:06 GMT
On Sat, 23 Dec 2000 19:32:03 GMT, HomerWelch <[EMAIL PROTECTED]> wrote:
>David Wragg wrote:
>>
>> HomerWelch <[EMAIL PROTECTED]> writes:
>> > I doubt whether it is patentable, but it is copyrighted. I
>> > remember reading a magazine article by a guy who was on the
>> > committee to standardize the C Programming Language. He
[ snip ]
>The high cost of copies of standards from organizations has
>been a pet peeve of mine. Unless you have deep pockets or
>corporate sponsorship, it is difficult to come up with the
>cost of these items. The high cost seems to be contrary to
>the principle of freely disseminating knowledge.
A PDF file of the ANSI C standard can be ordered online for $18 .
------------------------------
Date: Sat, 23 Dec 2000 12:38:38 -0600
From: "Arthur H. Gold" <[EMAIL PROTECTED]>
Subject: Re: front ending libraries (even libc)
[EMAIL PROTECTED] wrote:
>
> On Fri, 22 Dec 2000 05:33:33 GMT Joe Bob <[EMAIL PROTECTED]> wrote:
>
> |> I'm starting to take a look at what might be needed to do library front
> |> ending. What I mean by that term is this. An existing library, such as
> |> libc, will have a complete set of its own functions. The front ending
> |> library will have a subset of the functions (possibly just a few, maybe
> |> even just one). I want to have, AT RUN TIME, for the front end library
> |> to be preferred over the back end library for dynamic linkage. If the
> |> symbol is defined in the first library found, use that. But if it is
> |> found not in the first, but in the second, use that. There needs to be
> |> not conflict with respect to the fact that the second library also has
> |> the same symbols found in the first. I'm thinking of the first library
> |> as a sort of mask layed over the second, hiding some symbols and having
> |> its own versions of them instead.
> |
> | I just had the occaision to do this today. My goal was to override a libc
> | function with my own version.
> | Just write your replacement function (namespace, returns and arg casting the
> | same!). Link it into your own shared
> | library. Set the LD_PRELOAD variable at run time; export
> | LD_PRELOAD=/usr/local/lib/libspecial.so. Then
> | start your app. Its just that easy. You can confirm that your dynamic
> | library is getting used by doing a "ldd" on your
> | binary.
>
> OK, now how can I get my special function to turn around and call the real
> one in libc, without calling itself in a loop? This would be so that I do
> not have to fully re-implement that library function, but just make a front
> end to wrap it's calls. Would I have to dlopen("/lib/libc.so.6",RTLD_NOW)
> and dlsym(dlhandle,"readdir") to make that call (for readdir() in this case)?
> Or is there a way to do it by linking if there is no alternate symbol name
> (some functions do have __alternate names and some do not)? Will dlopen()
> reuse the mapping or the library that was used by ld.so or make a new one?
> The man page for dlopen says 2 calls to dlopen() for the same library will
> return the same handle, so I assume the same mapping will be involved in
> that case, but it doesn't say anything about doing dlopen() for a library
> which is already mapped and linked by ld.so. If ld.so is doing all its work
> via the same dlopen() then I guess this would be OK.
You don't have to dlopen it at all; you should use the
RTLD_NEXT pseudo-handle for dlsym(), as follows:
Consider a fictional function "int some_func( int, void *)":
int some_func( int arg1, void * arg2 ) {
static int (*real_some_func)(int, void *) = NULL;
int rslt;
if ( ! real_some_func ) {
real_some_func = dlsym( RTLD_NEXT, "some_func" );
if ( ! real_some_func ) {
/* die as gracefully as possible */
}
}
/* mess with stuff however you want */
rslt = real_some_func( arg1, arg2 );
/* further mess with stuff however you want */
return rslt;
}
Using RTLD_NEXT as opposed to opening libc directly (BTW,
doing a dlopen on a library already linked to your process
will _not_ instantiate a new copy of the library) has the
further advantage of dealing with the case where other
libraries linked to the process (most notably pthreads) also
interpose on such calls.
I've written before on this, but apparently my messages
haven't gotten through; as I have been working on a project
for a couple of years that uses this stuff extensively (and,
further, has to worry about getting the right semantics for
intra-library calls) I've run into just about every possible
pitfall, so I can most likely address any questions you
might have.
HTH,
--ag
/* mess with stuff however you want */
>
> --
> -----------------------------------------------------------------
> | Phil Howard - KA9WGN | Dallas | http://linuxhomepage.com/ |
> | [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/ |
> -----------------------------------------------------------------
--
Artie Gold, Austin, TX (finger the cs.utexas.edu account
for more info)
mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
--
A: Yes I would. But not enough to put it out.
------------------------------
From: "urp" <[EMAIL PROTECTED]>
Subject: Re: pivot_root and ramfs (really just pivot_root)
Date: Sat, 23 Dec 2000 13:39:02 -0800
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
wrote:
> if I had a
> filesystem mounted as /ramfs/foo, what will happen to that filesystem
> when the pivot_root call is done?
All mount points get pivoted as well. You should have a mounted
filesystem under /foo.
The only thing you have to watch out for is program behavior after a
pivot_root. Make sure to do chroots() on everything. As of today,
pivot_root does that for you, but the man page indicates it could change
and leave the chroots up to the affected programs.
Well, that, and mtab. I haven't figured out a good way to make the mtab
for the original filesystem duplicated after the pivot_root. symbolic
linking doesn't work, neither does copying.
------------------------------
From: Andrew Clark <[EMAIL PROTECTED]>
Subject: Re: Libraries
Date: Sat, 23 Dec 2000 21:57:01 +0000
Hi,
Thanks for both those responses they are very useful and effectively
what I wanted to know!
Although could someone please tell me if there's a full set of
ducumentation in HTML format (or other) that contains information about
everything like this?
Java has some.
Microsoft Platform SDK has them.
BeOS has them.
They are so useful to me, but does Linux have any? What happened to the
Linux Documentation Project? The information for programmers in that
seemed to be so old that i got the impression it had just been
translated off the original cave drawings! :-)
I'm absolutely new to Linux, and just getting used to developing apps
for it but I desperately want to make the system i am writing compatible
with as many OS's as possible and so I need to learn Linux programming.
Any help would be appreciated.
Thanks
Andrew
--
Andrew Clark
------------------------------
** 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
******************************