Linux-Development-Sys Digest #294, Volume #8 Wed, 22 Nov 00 13:13:17 EST
Contents:
Re: Shared Object Libraries (DLLs) (Andreas Jaeger)
Re: query: Controlling SCSI disks under Linux (Alain-Pierre CHERTIER)
Re: Interprocess Communication ... (network_noadle)
Can not open a file within a kernel module (Rui Antunes)
Re: System call socketcall - recv() called by Linux continuously ?!? (Rui Antunes)
ifnet ([EMAIL PROTECTED][remove-this])
Re: ifnet ([EMAIL PROTECTED])
Re: modify syscall readdir read ("jimmy")
saving/restoring a process (Michael Pujos)
Re: Can not open a file within a kernel module ([EMAIL PROTECTED])
Re: modify syscall readdir read ([EMAIL PROTECTED])
problem with depmod ([EMAIL PROTECTED])
Re: Shared Object Libraries (DLLs) (John Reiser)
ftp sometime slow to connect sometime ok (Jerome Corre)
Re: injecting keystrokes into virtual console (Mike McDonald)
Re: Software RAID (moonie;))
----------------------------------------------------------------------------
From: Andreas Jaeger <[EMAIL PROTECTED]>
Subject: Re: Shared Object Libraries (DLLs)
Date: 22 Nov 2000 11:59:19 +0100
>>>>> Marc SCHAEFER writes:
[...]
> test: all
> env LD_PRELOAD=`pwd`/libopen.so some_software
> libopen.so: open.o
> ld -shared open.o -o libopen.so
> open.o: open.c
> gcc -c open.c -o open.o
Always use gcc -fPIC for shared libs!
Andreas
--
Andreas Jaeger
SuSE Labs [EMAIL PROTECTED]
private [EMAIL PROTECTED]
http://www.suse.de/~aj
------------------------------
From: Alain-Pierre CHERTIER <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps,comp.periphs.scsi
Subject: Re: query: Controlling SCSI disks under Linux
Date: Wed, 22 Nov 2000 11:17:37 GMT
Hello Kevin !
On all my Linux systems since Dec.1994 (Plug&Play Yggdrasil fall 1994
and 1995, Slackware 2, 3, 4, Kheops 1995, MNIS 1997 & 1998,
Mandrake 6, RedHat 5.1, 5.2, 6.0, 6.1, 6.2), the /dev/sgx special
device filenames don't seem to react as you presented things
in your msg.
Example :
if I have only one scanner with SCSI ID-4 active on the scsi bus,
the linux sg scsi stuff will let me see the scanner by the /dev/sga
device filename and the minor number of /dev/sga has no sense
compared to SCSI ID-4...
/dev/sgx filenames are "allocated" in the order each scsi active
device responded to the scsi detect queries from the scsi controller
(or scsi controller device driver embedded in Linux kernel image
or separated loadable module)
"Allocated" /dev/sgx are always contiguous & ascending, but although
SCSI ids are detected in ascending order, there's a chance they are
not contiguous (even not beginning at SCSI ID-0...)
The situtation is even more complicated if you have more than one
scsi controller with separated scsi buses with identical SCSI IDs
on each of them... In such a case, /dev/sgx will be allocated
in ascending order beginning at /dev/sga for the devices controlled
thru the scsi controller declared as "scsi host 0" by the Linux kernel.
Then, the following devices controlled by following "scsi host N" hosts
will be accessed beginning as /dev/sgd as an example.
CONCLUSION : /dev/sgx minor numbers don't have ANYTHING to do, to see,
or to be compared or associated with physical SCSI IDs
And about SCSI ID-7 : the ID-7 is taken by the scsi controller
by default and no /dev/sgx access is permitted
to a scsi controller
My today's config :
scsi host 0 (2940-AU)
ID-0 scsi disk => /dev/sga (/dev/sda for true block mode disk access)
ID-4 scanner => /dev/sgb
scsi host 1 (Adaptec 6360 chip on my SB16-SCSI2 soundcard)
ID-2 tape backup => /dev/sgc (/dev/st0 for true access by backup tools)
ID-5 cdrom => /dev/sgd (/dev/sr0 for true standard access)
ID-6 cd-writer => /dev/sge (/dev/sr1 for true standard access)
hu ?
;-)
Alain-Pierre CHERTIER <[EMAIL PROTECTED]>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
From: network_noadle <[EMAIL PROTECTED]>
Subject: Re: Interprocess Communication ...
Date: Wed, 22 Nov 2000 11:33:02 +0000
[EMAIL PROTECTED] wrote:
<snip>
> RedHat Linux 6.2 is Kernel 2.2 or 2.4 ?
<snip>
RedHat 6.2 was originally shipped with kernel 2.2.14.
When a security bug was found in the 2.2.x and 2.0.x series, they issued
a kernel update to 2.2.16.
network_noadle
------------------------------
From: [EMAIL PROTECTED] (Rui Antunes)
Subject: Can not open a file within a kernel module
Date: Wed, 22 Nov 2000 02:40:20 GMT
I'm developping a kernel module for RedHat 7.0.
I'm having problems opening files.
I use something like this:
#include <asm/uaccess.h>
extern long sys_call_table[];
int (*open)(const char* filename, int flags);
int init_module() {
/* .... */
opencall = sys_call_table[_NR_open];
/* .... */
}
int tryopen() {
int fd;
mm_segment_t oldfs;
/* "switch" to user space */
oldfs = get_fs();
setfs(get_ds());
/* open file */
fd = opencall("file.txt",O_RDONLY);
/* "switch" back */
set_fs(oldfs);
if(fd<0) printk("\nopen failed");
}
I alway get the "open failed" message...
I even tried to use the errno variable but... I COULDN'T
(when I insmod the module it returns unresolved symbol errno
even after I included /usr/src/linux/include/linux/errno.h)
What am I doing wrong?
Thanks in advance,
Rui Antunes
------------------------------
From: [EMAIL PROTECTED] (Rui Antunes)
Crossposted-To: alt.os.linux,comp.os.linux.help,comp.os.linux.questions
Subject: Re: System call socketcall - recv() called by Linux continuously ?!?
Date: Wed, 22 Nov 2000 02:46:09 GMT
On Fri, 03 Nov 2000 00:34:58 GMT, [EMAIL PROTECTED] (Kaz
Kylheku) wrote:
>On Thu, 02 Nov 2000 18:39:30 GMT, Rui Antunes <[EMAIL PROTECTED]> wrote:
>> I'm developping a module that intercepts the socket API. It's
>>working fine, except for one little detail - the module is detecting
>>that the int recv(int sockfd,...) is being called continuosly
>>(the module sends a message to the console using printk indicating
>>it); it seems like Linux is always trying to check for some incoming
>>packet on some socket (with sockfd == 0 !!!!) with a O_NONBLOCK
>>work-alike flag (and the sys call keeps on returnin 0 bytes
>>received...) - is it possible?
>
>Why don't you print the current->pid? That way you can see which process
>is doing it.
The process is the syslogd!
Why does syslogd keep on trying to recv on socket 0?!?
THANKS,
Rui Antunes
------------------------------
From: [EMAIL PROTECTED][remove-this]
Subject: ifnet
Date: Wed, 22 Nov 2000 13:37:45 +0100
Hi all,
I try to get informations from my ethernet card (numbers of collisions,
data send...),
so I use the struct ifnet .
So I first declare a struct ifnet that's ok but how can I get the
informations ? What's the ioctl for that ?
I use Linux or Solaris as OS
Thanks
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <net/if.h>
#include <netinet/if_ether.h>
#include <sys/errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/ioctl.h>
int main(int argc, char **argv)
{
struct ifnet *ifp;
//here... what's the initialisation of the ifnet struct ???
}
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: ifnet
Date: Wed, 22 Nov 2000 12:56:28 GMT
[EMAIL PROTECTED][remove-this] wrote:
I would just take a look at the source code of ifconfig to see
how it is done there..
Taavo.
> Hi all,
> I try to get informations from my ethernet card (numbers of collisions,
> data send...),
> so I use the struct ifnet .
> So I first declare a struct ifnet that's ok but how can I get the
> informations ? What's the ioctl for that ?
> I use Linux or Solaris as OS
> Thanks
> #include <stdlib.h>
> #include <stdio.h>
> #include <unistd.h>
> #include <ctype.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <netinet/in.h>
> #include <arpa/inet.h>
> #include <sys/time.h>
> #include <net/if.h>
> #include <netinet/if_ether.h>
> #include <sys/errno.h>
> #include <fcntl.h>
> #include <time.h>
> #include <sys/ioctl.h>
> int main(int argc, char **argv)
> {
> struct ifnet *ifp;
> //here... what's the initialisation of the ifnet struct ???
> }
------------------------------
From: "jimmy" <[EMAIL PROTECTED]>
Crossposted-To:
de.comp.os.unix.linux.misc,linux.dev.kernel,linux.sources.kernel,redhat.kernel.general
Subject: Re: modify syscall readdir read
Date: Wed, 22 Nov 2000 15:39:10 +0100
Hi there,
I would like to modify the readdir read syscall, because I need to hide some
files from some users in some special cases (the files in /proc has to be
unvisible if the user don't owns the proccess).
readdir/read seems to be the way what every programm uses (ls, ps, top,
etc..).
I would be pleased to get some hints how to solve this and where to find the
readdir/read source in the kernelsource to change it at this place.
Any recommendation is welcome !!!!
regards
jimmy
------------------------------
From: Michael Pujos <[EMAIL PROTECTED]>
Subject: saving/restoring a process
Date: 22 Nov 2000 16:28:49 +0100
I have the following problem:
i have a simple process that does no disk or other I/O and mainly
heavy computations. i want to stop it and save its context and memory
to a file and to be able to restart it in the same state later.
Is it possible without too much hassle and does a library exist for
this purpose ?
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: Can not open a file within a kernel module
Date: Wed, 22 Nov 2000 15:21:59 GMT
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Rui Antunes) wrote:
> I'm developping a kernel module for RedHat 7.0.
> I'm having problems opening files.
> I use something like this:
>
> #include <asm/uaccess.h>
>
> extern long sys_call_table[];
> int (*open)(const char* filename, int flags);
>
> int init_module() {
>
> /* .... */
> opencall = sys_call_table[_NR_open];
> /* .... */
> }
>
> int tryopen() {
>
> int fd;
> mm_segment_t oldfs;
>
> /* "switch" to user space */
> oldfs = get_fs();
> setfs(get_ds());
>
> /* open file */
> fd = opencall("file.txt",O_RDONLY);
>
> /* "switch" back */
> set_fs(oldfs);
>
> if(fd<0) printk("\nopen failed");
> }
>
> I alway get the "open failed" message...
> I even tried to use the errno variable but... I COULDN'T
> (when I insmod the module it returns unresolved symbol errno
> even after I included /usr/src/linux/include/linux/errno.h)
>
> What am I doing wrong?
>
> Thanks in advance,
> Rui Antunes
>
set_fs() ? get_fs() ? get_ds() ?
YOu should use copy_from_user and copy_to_user . I didnt know what
were the 3 kernel fonctions, so i looked at the kernel source .
>From fs/exec.c :
/*
* 'copy_string()' copies argument/envelope strings from user
* memory to free pages in kernel mem. These are in a format ready
* to be put directly into the top of new user memory.
*
* Modified by TYT, 11/24/91 to add the from_kmem argument, which
specifies
* whether the string and the string array are from user or kernel
segments:
*
* from_kmem argv * argv **
* 0 user space user space
* 1 kernel space user space
* 2 kernel space kernel space
*
* We do this by playing games with the fs segment register. Since it
* is expensive to load a segment register, we try to avoid calling
* set_fs() unless we absolutely have to.
*/
Maybe someone experienced in kernel coding can explain the differences
between all these kernel functions .
----
Julien
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
From: [EMAIL PROTECTED]
Crossposted-To: de.comp.os.unix.linux.misc,linux.dev.kernel,linux.sources.kernel
Subject: Re: modify syscall readdir read
Date: Wed, 22 Nov 2000 15:26:02 GMT
In article <8vglv5$2so$02$[EMAIL PROTECTED]>,
"jimmy" <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I would like to modify the readdir read syscall, because I need to
hide some
> files from some users in some special cases (the files in /proc has
to be
> unvisible if the user don't owns the proccess).
>
> readdir/read seems to be the way what every programm uses (ls, ps,
top,
> etc..).
>
> I would be pleased to get some hints how to solve this and where to
find the
> readdir/read source in the kernelsource to change it at this place.
>
> Any recommendation is welcome !!!!
>
> regards
>
> jimmy
>
>
You dont have to change the code, you can just handle the syscalls like
read(2), readdir(2), getdents(2), test for special conditions, and
relaunch the real syscall .
----
Julien
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
From: [EMAIL PROTECTED]
Subject: problem with depmod
Date: Wed, 22 Nov 2000 15:32:37 GMT
For some reason, depmod from modutils 2.3.20 generates an empty
modules.dep:
/lib/modules/2.4.0-test11 $ ls -l
total 5
lrwxrwxrwx 1 root root 27 Nov 22 00:08 build ->
/usr/src/linux-2.4.0-test11
drwxr-xr-x 5 root root 1024 Nov 22 00:09 kernel
-rw-r--r-- 1 root root 0 Nov 22 13:06 modules.dep
-rw-r--r-- 1 root root 81 Nov 22 13:06
modules.isapnpmap
-rw-r--r-- 1 root root 99 Nov 22 13:06 modules.pcimap
-rw-r--r-- 1 root root 177 Nov 22 13:06 modules.usbmap
drwxr-xr-x 2 root root 1024 Nov 22 00:09 pcmcia
This dosen't happen with depmod from 2.3.19.
/lib/modules/2.4.0-test11 $ ls -l
total 12
lrwxrwxrwx 1 root root 27 Nov 22 13:05 build ->
/usr/src/linux-2.4.0-test11
drwxr-xr-x 5 root root 1024 Nov 22 00:09 kernel
-rw-r--r-- 1 root root 2992 Nov 22 00:09 modules.dep
-rw-r--r-- 1 root root 81 Nov 22 00:09
modules.isapnpmap
-rw-r--r-- 1 root root 5097 Nov 22 00:09 modules.pcimap
-rw-r--r-- 1 root root 177 Nov 22 00:09 modules.usbmap
drwxr-xr-x 2 root root 1024 Nov 22 00:09 pcmcia
Am I the only one to have this problem ?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
From: John Reiser <[EMAIL PROTECTED]>
Subject: Re: Shared Object Libraries (DLLs)
Date: Wed, 22 Nov 2000 08:18:58 -0800
> > libopen.so: open.o
> > ld -shared open.o -o libopen.so
>
> > open.o: open.c
> > gcc -c open.c -o open.o
> Always use gcc -fPIC for shared libs!
It would be helpful to explain _why_ to use -fPIC.
Implementations vary (especially according to the underlying
hardware and operating system), but generally a shared library
may be instantiated (loaded) at different addresses at runtime.
Thus any address "constants" in the library must be relocated
at runtime. Depending on the implementation, such relocating
may be impossible, significantly slower on every dynamic access,
significantly longer once at the beginning, and/or discard the
benefits of sharing space between processes. Using -fPIC
tells the compiler and static linker to produce "Position
Independent Code" which significantly reduces most of the
costs of runtime relocation.
In the specific case of Linux on x86 and recent versions of gcc,
address constants arise from using data that is not a parameter
and not an automatic local, or from taking the address of any
function using operator '&' (explicit or implicit; anything other
than a literal lexical call). Therefore: 'extern' data, global
data, 'static' data, string constants, and function names without
calls all get different code with -fPIC. If your code has none
of these (uses only parameters, automatic locals, and literal
lexical calls), then -fPIC has no benefits and can be omitted.
--
John Reiser, [EMAIL PROTECTED]
------------------------------
From: Jerome Corre <[EMAIL PROTECTED]>
Subject: ftp sometime slow to connect sometime ok
Date: Wed, 22 Nov 2000 17:18:36 GMT
hi,
I've observed some really strange behavior using ftp. I have two linux
box (Red hat 6.2), one ftp server with two network interface a wired and
a wireless and a client just with a wireless adapter. What i want to do
is to download file from the server to the client over the wireless lan.
I have added entries in the /etc/hosts.conf on both machine, telnet for
example works fine but ftp sometime take up to 2 minute to connect and
sometime connect straifght away? What could cause that?
note that beacause my server is also part of a wireless lan their are
entry in /etc/resolv.conf for a nameserver. I cannot remove those entry.
what coulb be going wrong? and what can i do to fix it?
thanks for any help
regards
--
Jerome Corre
--
Jerome Corre
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Reply-To: [EMAIL PROTECTED]
From: [EMAIL PROTECTED] (Mike McDonald)
Subject: Re: injecting keystrokes into virtual console
Date: Wed, 22 Nov 2000 17:30:16 GMT
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] writes:
> On Tue, 21 Nov 2000 18:52:26 GMT Mike McDonald <[EMAIL PROTECTED]> wrote:
>
>| If you're using bash as your shell (I'm not), you could have your special
>| getty program gather up the init commands into a temp file and then exec bash
>| as 'bash -rcfile /tmp/fooy -i'. That'll cause bash to execute the init
>| commands first and then continue on as an interactive shell. You might be able
>| to do a similar thing with other shells too.
>
> That could be really messy with more than one going at the same time.
Huh? /tmp/fooy was an example temp file name. You'd actually want to use
mktemp() and have the script remove its self as its last action. I don't see
how it's "messy" at all. Please explain what you mean.
Mike McDonald
[EMAIL PROTECTED]
------------------------------
From: moonie;) <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.hardware,alt.linux,comp.os.linux.misc
Subject: Re: Software RAID
Date: Wed, 22 Nov 2000 13:00:09 -0500
On Wed, 22 Nov 2000, [EMAIL PROTECTED] wrote:
>First let me say I know NOTHING about software RAID in Linux.
>
>That said, I have a server with Software RAID on a SUN running Solaris,
>and I would never inflict Software RAID on another machine as long as I
>live. Hardware RAID can hide a lot of things from the user, and be just
>about as 'fast' as an individual disk. Software RAID is going to slow
>your disk writes, well REALLY BAD.
>
>My advice would be spend the bucks for the Hardware, or DONT DO IT.
>
>--
> Reg.Clemens
> [EMAIL PROTECTED]
I have found that Software RAID on Linux to be MUCH faster than non RAID. I
get almost the same speeds as Hardware RAID. Don't know much about Solaris but
it sounds like a problem with the drivers. The Software RAID drivers for linux
work very well. I have 2 IDE drives with transfer rates of 19.5mb/s and
24mb/s. In my RAID array I get 38mb/s. I do agree that a hardware solution is
a better/faster option, however Software RAID is FREE! If I can almost double
my disk I/O for free I will! I have never had a problem with Software RAID, it
has been rock solid and reliable on my home server. BTW my disk writes are
a good bit faster than a single drive, reads are MUCH faster! With RAID 1 yes
your disk writes will be a little slower, but reads should be just less than
double single drive speeds.
--
moonie ;)
Registered Linux User #175104
http://counter.li.org
KDE2
Kernel 2.4.0-test5
XFree86 4.0 Nvidia .94 drivers
RAID 0 Striped
Test-Pilots-R-Us ;)
------------------------------
** 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
******************************