Linux-Development-Sys Digest #185, Volume #8 Mon, 2 Oct 00 11:13:18 EDT
Contents:
Re: disabling update of last-access and modification timestamps on files (Nix)
ptrace question (Integral)
Re: question about memory leaks in linux ("Arthur H. Gold")
behavior of read() w.r.t. memory protection ("Arthur H. Gold")
Re: disabling update of last-access and modification timestamps on files (Bob Hauck)
Re: new project for linux in idea..... (Bill Touchstone)
How to load shared libs at runtime? ("Peter Koch")
Re: How to load shared libs at runtime? (Mikko Rauhala)
Re: How to load shared libs at runtime? ("Peter Koch")
Re: mmap problem in pci driver (Arne Driescher)
Re: RS232 / Mitutoyo Counter and Basic example ("O.Petzold")
interrup from the keyboard (Stefano Totaro)
Re: new windowing system (Rasputin)
Re: Linux partition access KERNEL BUG? (Iwo Mergler)
Re: new windowing system (Christopher Browne)
----------------------------------------------------------------------------
From: Nix <$}xinix{[email protected]>
Subject: Re: disabling update of last-access and modification timestamps on files
Date: 02 Oct 2000 00:35:48 +0100
[EMAIL PROTECTED] (Bob Hauck) writes:
> The "noatime" option to mount can do this on a per-filesystem basis. I
> don't know of any finer-grained method.
ext2fs has the noatime file (and directory) attribute, as well.
--
`Ergotism is what you get if you overuse the word "therefore". Egotism
on the other hand is a form of "I" strain.' --- Paul Martin
------------------------------
From: Integral <[EMAIL PROTECTED]>
Subject: ptrace question
Date: Sun, 1 Oct 2000 22:00:05 -0500
Does anyone know of the proper way to configure a tty before calling ptrace()
on an ncurses program? When I try to use ptrace(PT_CONTINUE) on an ncurses
program, catch a ^C (SIGINT), and then try to singlestep the next instruction
after the signal is caught, the wait() after the ptrace(PT_STEP) does not
return until you hit a keystroke.
Since this behaviour does not occur with non-ncurses programs, I can only
assume that the bug has something to do with the way I am setting up the
tty prior to the ptrace() call. I have tried putting the terminal in raw mode,
cooked mode, and even tried saving the terminal attributes before the ptrace()
and restoring them directly afterwards, but the wait() call still does not
return properly after the second call to ptrace() with the PT_STEP argument.
Below, I have attached a sample program to demonstrate the error
(under *BSD) - it attempts to run /usr/local/bin/ncftp2 (NcFTP v2 is
ncurses-based) through ptrace() - if anyone can shed light on what is going on
here, I would greatly appreciate it. Thank you in advance.
---- Cut here ----
/*
* The goal of this program is to run an ncurses program normally
* until a signal is caught, and then try to singlestep one
* instruction. It should demonstrate that the wait() call after
* the ptrace() singlestep call does not return as it should -
* you need to hit the ENTER key for the wait() call to return.
*
* Compile: gcc -o ptest ptest.c
*
* Run: ./ptest, hit ^C and you will see that you must hit
* a keystroke to get it to continue past the singlestep.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/ptrace.h>
#include <errno.h>
#include <sys/wait.h>
#include <signal.h>
#include <termios.h>
#include <unistd.h>
/*
* Location of an ncurses program (NcFTP v2.x.x)
*/
char filename[] = "/usr/local/bin/ncftp2";
int
main()
{
int pid; /* child pid */
int waitval;
int sig;
struct termios SavedIn, Temp;
signal(SIGINT, SIG_IGN);
pid = fork();
switch (pid)
{
case -1:
{
perror("fork");
break;
}
/*
* Child
*/
case 0:
{
/*
* Allow parent to trace this child process
*/
ptrace(PT_TRACE_ME, 0, 0, 0);
/*
* Execute program to be debugged and cause child to
* send a signal to parent, so the parent can switch
* to PT_STEP
*/
execl(filename, filename, NULL);
break;
}
/*
* Parent
*/
default:
{
/*
* Wait for child to stop (execl)
*/
wait(&waitval);
/* save attributes */
tcgetattr(STDIN_FILENO, &SavedIn);
Temp = SavedIn;
/* put in raw mode */
Temp.c_lflag &= ~(ICANON|ISIG);
Temp.c_iflag &= ~(IXON|BRKINT|PARMRK);
Temp.c_cc[VMIN] = 1;
Temp.c_cc[VTIME] = 0;
tcsetattr(STDIN_FILENO, TCSANOW, &Temp);
if (ptrace(PT_CONTINUE, pid, (caddr_t) 1, 0) != 0)
perror("ptrace");
wait(&waitval);
/* restore attributes */
tcsetattr(STDIN_FILENO, TCSANOW, &SavedIn);
fprintf(stderr, "\nwaitval1 = %d\n", waitval);
if (WIFSTOPPED(waitval))
{
sig = WSTOPSIG(waitval);
fprintf(stderr, "signal = %d\n", sig);
/*
* OK, they did the CONTROL-C, now try singlestepping the
* next instruction.
*/
fprintf(stderr, "SINGLESTEPPING - here is where you have to hit ENTER but
shouldn't need to\n");
Temp.c_lflag &= ~(ICANON|ISIG);
Temp.c_iflag &= ~(IXON|BRKINT|PARMRK);
Temp.c_cc[VMIN] = 1;
Temp.c_cc[VTIME] = 0;
tcsetattr(STDIN_FILENO, TCSANOW, &Temp);
if (ptrace(PT_STEP, pid, (caddr_t) 1, 0) != 0)
perror("ptrace");
/*
* Here is where you have to hit a key to get wait() to
* return???
*/
wait(&waitval);
tcsetattr(STDIN_FILENO, TCSANOW, &SavedIn);
fprintf(stderr, "DONE SINGLESTEP, waitval2 = %d\n", waitval);
}
}
}
return 0;
}
------------------------------
Date: Sun, 01 Oct 2000 21:04:06 -0500
From: "Arthur H. Gold" <[EMAIL PROTECTED]>
Subject: Re: question about memory leaks in linux
Matthew Gatto wrote:
>
> If I write a C program with memory leaks, after execution of the
> program is over, will all that leaked memory be automatically
> de-allocated by the linux kernel?
Yes. Otherwise none of us could _ever_ use Netscape
products(!).
> I was wondering what kind of
> protections towards this type of thing the linux kernel has built in
> to it so that I can comfortably develop in C with gcc, while not
> having to worry about exhausting my system resources.
As long as you don't fill up all your swap space (which
tends to make things interesting) it's awfully hard to do
mess things up too badly.
HTH,
--ag
>
> --
> 5:16pm up 88 days, 12:43, 4 users, load average: 0.00, 0.02, 0.00
Nice up time. Now let's do some work! ;-)
--
Artie Gold, Austin, TX (finger the cs.utexas.edu account
for more info)
mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
--
"I'd sooner fly another combat mission than ride the Cyclone
again" -- Joseph Heller
------------------------------
Date: Sun, 01 Oct 2000 21:05:57 -0500
From: "Arthur H. Gold" <[EMAIL PROTECTED]>
Subject: behavior of read() w.r.t. memory protection
/*
Hey all:
In researching interactions between system calls and memory
protection
(part of a larger project), I came up with the following
test case,
which doesn't seem to behave as I'd imagine it would.
The idea is this: we mmap two pages, mark the second one
inaccessible
using mprotect, open a file, and try read that go into
protected
space.
The results were surprising.
It seems that as long as there's one word of accessible
memory
at the front of the buffer, it'll happily read into that
word,
giving no indication that there may be more to read.
address of protected area is 0x40016000
page size is 4096
buffer is 0x40016000 (offset = 4096), read failed: Bad
address
buffer is 0x40015fff (offset = 4095), read failed: Bad
address
buffer is 0x40015ffe (offset = 4094), read failed: Bad
address
buffer is 0x40015ffd (offset = 4093), read failed: Bad
address
buffer is 0x40015ffc (offset = 4092), read 4 characters
buffer is 0x40015ffb (offset = 4091), read 4 characters
buffer is 0x40015ffa (offset = 4090), read 4 characters
buffer is 0x40015ff9 (offset = 4089), read 4 characters
buffer is 0x40015ff8 (offset = 4088), read 8 characters
buffer is 0x40015ff7 (offset = 4087), read 8 characters
buffer is 0x40015ff6 (offset = 4086), read 8 characters
buffer is 0x40015ff5 (offset = 4085), read 8 characters
buffer is 0x40015ff4 (offset = 4084), read 12 characters
buffer is 0x40015ff3 (offset = 4083), read 12 characters
buffer is 0x40015ff2 (offset = 4082), read 12 characters
buffer is 0x40015ff1 (offset = 4081), read 12 characters
buffer is 0x40015ff0 (offset = 4080), read 16 characters
buffer is 0x40015fef (offset = 4079), read 16 characters
buffer is 0x40015fee (offset = 4078), read 16 characters
buffer is 0x40015fed (offset = 4077), read 16 characters
buffer is 0x40015fec (offset = 4076), read 20 characters
As you can see, it will read into whatever it can, as long
as an additional full word would not run into protected
space.
Is this right?
Any ideas?
Thanks.
--ag
=============================================================
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
int
main(void)
{
int fd;
int devzero;
int offset;
int pagesize = getpagesize();
void *p;
void *address_of_protected_area;
/*
* open /dev/zero (for use in the mmap)
*/
devzero = open("/dev/zero", O_RDWR);
if (devzero == -1) {
perror("opening /dev/zero");
return 1;
}
/*
* map some space
*/
p =
mmap(NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
MAP_PRIVATE, devzero,
0);
if (p == (void *)-1) {
perror("mmap");
return 1;
}
address_of_protected_area = (char *)p + pagesize;
/*
* memory protect the second page of that space
(PROT_NONE)
*/
if (mprotect(address_of_protected_area, pagesize,
PROT_NONE) == -1) {
perror("mprotect");
return 1;
}
printf("address of protected area is %p\n",
address_of_protected_area);
/* open a file (in this case, this source file itself) */
fd = open("tstread.c", O_RDONLY);
if (fd == -1) {
printf("opening tstread.c");
return 1;
}
printf("page size is %d\n", pagesize);
/*
* try the reads
* We know the first attempt will fail, but the others?
*/
for (offset = pagesize; offset > pagesize - 21; offset--)
{
void *q = (char *)p + offset;
ssize_t rslt = read(fd, q, 5000);
printf("buffer is %p (offset = %d), ", q, offset);
if (rslt == -1) {
/* the read failed */
printf("read failed: %s\n", strerror(errno));
}
else {
/* the read succeeded */
printf("read %d characters\n", rslt);
}
/* `rewind' the file */
lseek(fd, 0, SEEK_SET);
}
return 0;
}
--
Artie Gold, Austin, TX (finger the cs.utexas.edu account
for more info)
mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
--
"I'd sooner fly another combat mission than ride the Cyclone
again" -- Joseph Heller
------------------------------
From: [EMAIL PROTECTED] (Bob Hauck)
Subject: Re: disabling update of last-access and modification timestamps on files
Reply-To: bobh{at}haucks{dot}org
Date: Mon, 02 Oct 2000 00:04:39 GMT
On 02 Oct 2000 00:35:48 +0100, Nix <$}xinix{[email protected]> wrote:
>[EMAIL PROTECTED] (Bob Hauck) writes:
>
>> The "noatime" option to mount can do this on a per-filesystem basis. I
>> don't know of any finer-grained method.
>
>ext2fs has the noatime file (and directory) attribute, as well.
Well, so it does (according to "man chattr"). I did not know that.
Thanks!
--
-| Bob Hauck
-| To Whom You Are Speaking
-| http://www.haucks.org/
------------------------------
Subject: Re: new project for linux in idea.....
From: [EMAIL PROTECTED] (Bill Touchstone)
Date: Mon, 02 Oct 2000 05:28:31 GMT
I'm not really interested directly in this. But for my .02 worth:
1) I think it would be judicious to wait to see if there will be a Napster
Server in a month. There is a very good chance they will be shutdown before you
even get to code.
2) Waiting will have another advantage. If the courts decide against Napster,
there are likely to be major fines passed out. That may give pause (or should)
to those who would erect their own Napster-like server.
3) Finally, I would say that if you ever created something to which you
attached some value, and got to watch it proliferated from computer to computer
without any showing of expected monetary renumeration, you will understand why
so many are so upset about this type of technology use.
Bill
In article <1N2B5.550549$Kw2.4770658@flipper>, [EMAIL PROTECTED] says...
>
>Hello everybody.
>
>I just came back home from work and suddenly an idea came up in my mind.
>Well an idea is not bad but i know that my idea can't be realized without
>knowledge and help.
>
>Well my idea is to develop a brand new program for linux that will be free
>to download.so no cost to get it when it's finished.
>
>My idea is a sort of program (called "Laovs"=Linux Audio Or Video Share)
>like napster for linux. BUT!!!! Not only to share Audio like Mp3 or Wav
>files but much more like: DivX and Mpeg and avi and MPG and so on.
>so finaly it must be a program so that everybody who has linux and want to
>download an Mp3 or a movie that we finally all use "Laovs"
>
>my question to you all is
>1:-Were to start??
>2:-Is it possible to share also video over the Napster server?( If not can
>we as linux users setting up a server like napster?)
>3:-Are there any peoples in the world who would like to develop this program
>in C C++ Perl?
>4:- are there peoples who are interested in this project????
>
>
>Please send a reply or whatever if somebody finds this a good idea and would
>like to help develop this "Laovs"
>
>Greets
>Javewolf
>
>
>
------------------------------
From: "Peter Koch" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: How to load shared libs at runtime?
Date: Mon, 2 Oct 2000 07:56:29 +0200
I'm quite a rookie concerning linux programming, so this question may sound
stupid.
I am considering to port an application from win32 to linus. I need the
ability to load a shared library at runtime and find the address of a
function within it. Can somebody point me out what functions I need for
this?
Peter Koch
------------------------------
From: [EMAIL PROTECTED] (Mikko Rauhala)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: How to load shared libs at runtime?
Date: 2 Oct 2000 06:45:23 GMT
Reply-To: [EMAIL PROTECTED]
On Mon, 2 Oct 2000 07:56:29 +0200, Peter Koch <[EMAIL PROTECTED]> wrote:
>I am considering to port an application from win32 to linus. I need the
>ability to load a shared library at runtime and find the address of a
>function within it. Can somebody point me out what functions I need for
>this?
You can open an ELF shared library by calling dlopen() and find
functions within it with dlsym().
--
Mikko Rauhala - [EMAIL PROTECTED] - http://www.iki.fi/mjr/
------------------------------
From: "Peter Koch" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: How to load shared libs at runtime?
Date: Mon, 2 Oct 2000 09:29:26 +0200
"Mikko Rauhala" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]...
> On Mon, 2 Oct 2000 07:56:29 +0200, Peter Koch <[EMAIL PROTECTED]> wrote:
> >I am considering to port an application from win32 to linus. I need the
> >ability to load a shared library at runtime and find the address of a
> >function within it. Can somebody point me out what functions I need for
> >this?
>
> You can open an ELF shared library by calling dlopen() and find
> functions within it with dlsym().
>
> --
> Mikko Rauhala - [EMAIL PROTECTED] - http://www.iki.fi/mjr/
Thanks, i will try that.
Peter Koch
------------------------------
From: Arne Driescher <[EMAIL PROTECTED]>
Subject: Re: mmap problem in pci driver
Date: Mon, 02 Oct 2000 10:11:23 +0200
>
> /*test.c*/
> /*a sample user space program to test the phantom driver*/
>
> #include <stdio.h>
> #include <fcntl.h>
> #include <sys/mman.h>
>
> int *int_addr; /* int *int_addr; should be 4 bytes long*/
>
> main(int argc, char *argv[])
> {
> int fd;
> int *encoder_base;
> char *encoder_base_char;
>
> fd = open("phantom", O_RDONLY);
> encoder_base = (int *) mmap(NULL,256,PROT_READ,MAP_PRIVATE,fd,0);
Hi,
man mmap
MAP_PRIVATE
Create a private copy-on-write mapping.
Perhaps copy on write is not exactly what you want :-)
I use this code for mapping.
image = mmap(NULL,
size,
PROT_READ,
MAP_SHARED,
fd,
0l);
Perhaps it helps.
-Arne
------------------------------
From: "O.Petzold" <[EMAIL PROTECTED]>
Subject: Re: RS232 / Mitutoyo Counter and Basic example
Date: Mon, 02 Oct 2000 11:00:48 +0200
Lew Pitcher wrote:
[...]
Thanks a lot.
Olaf
------------------------------
From: Stefano Totaro <[EMAIL PROTECTED]>
Subject: interrup from the keyboard
Date: Mon, 02 Oct 2000 13:04:24 +0200
Hi,
how can I catch the interrupt from the keyboard?
I want my process wakes up when someone presses a key
but the interrupt from the keyboard seems
to be caught by the shell. I tried to set the raw mode
for the termios but it does not look to work.
Thanks,
Stefano
--
Stefano Totaro, Software Manager
EsseGi s.r.l.
Tel (+39) 02 6601 7241
Fax (+39) 02 618 5492
------------------------------
From: [EMAIL PROTECTED] (Rasputin)
Crossposted-To: comp.os.linux.x,comp.windows.x
Subject: Re: new windowing system
Reply-To: [EMAIL PROTECTED]
Date: Mon, 02 Oct 2000 13:25:07 GMT
[EMAIL PROTECTED] <Juliusz Chroboczek> wrote:
>Nix <$}xinix{[email protected]>:
>
>N> Using CORBA was probably right. It's just a super-RPC, is all. And it
>N> *is* damned useful. It's another componenting scheme, no better or worse
>N> than pipelines [...]
>
>As far as I recall, Corba doesn't support reliable asynchronous
>communication. (Neither does Sun RPC, by the way.)
CORBA is a nifty idea, for sure; but does GNOME actually
*use* any remote objects at all?
As far as I can make out, all CORBA objects in GNOME are run
on the localhost anyway, so what is the benefit of using a
platform-independant system like CORBA for stuff like cut-n-paste?
It just looks like a lot of unnecessary overhead from here.
GNOME doesn't seem to be any more a 'Network Object Model Environment'
than X is.
Any URLs proving me wrong gratefully recieved...
(currently toying with integrating Java into GNOME through CORBA/ORBit)
--
Rasputin.
Jack of All Trades - Master of Nuns.
------------------------------
From: Iwo Mergler <[EMAIL PROTECTED]>
Subject: Re: Linux partition access KERNEL BUG?
Date: Mon, 2 Oct 2000 14:03:13 GMT
Reply-To: [EMAIL PROTECTED]
Richard Krehbiel wrote:
>
> I've got a message routing service up and running on Linux, and it
> works great. It translates messages from one protocol and ships them
> to clients which talk another protocol. For robustness, I keep a
> transaction log on disk, so that system stops and restarts don't lose
> any messages. For high speed, it needs to use raw partition access (as
> in, fopen("/dev/hda6", "rb+")) for this transaction log.
>
> I prep these partitions simply by doing "dd if=/dev/zero of=/dev/hda6
> bs=4096".
>
> Now, why is it that this doesn't work on a 6.4G or a 27G hard disk? It
> works on the smaller 1G and 2G HDs that we've used.
>
> Reading from such a partition returns EOF. Writing aborts with "out of
> space." And since it doesn't work with "dd if=/dev/zero" either, I
> don't think my code is at fault.
>
> Kernel 2.2.5 (Red Hat 6.0), 2.2.12 (Red Hat 6.1), and 2.2.16 all show
> this. IDE hard disk. I haven't tried any 2.3 or 2.4 kernels; it
> doesn't matter whether they work 'cause I need stability.
>
> My guess is that there's a 32 bit addressing issue somehere. If
> someone can point me at the right files, I can try to fix it myself.
> Thanks.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
That's odd, just now I'm logging data with
dd if=/dev/rtf0 of=/dev/sda1 bs=128k and passed
the 27GB mark 5 minutes ago.
The problem seems to be limited to IDE...
Iwo
------------------------------
From: [EMAIL PROTECTED] (Christopher Browne)
Crossposted-To: comp.os.linux.x,comp.windows.x
Subject: Re: new windowing system
Reply-To: [EMAIL PROTECTED]
Date: Mon, 02 Oct 2000 14:52:18 GMT
In our last episode (Mon, 02 Oct 2000 13:25:07 GMT),
the artist formerly known as Rasputin said:
>[EMAIL PROTECTED] <Juliusz Chroboczek> wrote:
>>Nix <$}xinix{[email protected]>:
>>
>>N> Using CORBA was probably right. It's just a super-RPC, is all. And it
>>N> *is* damned useful. It's another componenting scheme, no better or worse
>>N> than pipelines [...]
>>
>>As far as I recall, Corba doesn't support reliable asynchronous
>>communication. (Neither does Sun RPC, by the way.)
>
>CORBA is a nifty idea, for sure; but does GNOME actually
>*use* any remote objects at all?
>
>As far as I can make out, all CORBA objects in GNOME are run
>on the localhost anyway, so what is the benefit of using a
>platform-independant system like CORBA for stuff like cut-n-paste?
>It just looks like a lot of unnecessary overhead from here.
>
>GNOME doesn't seem to be any more a 'Network Object Model Environment'
>than X is.
>
>Any URLs proving me wrong gratefully recieved...
The default configuration rejects IP-based connections (see your
/etc/orbitrc file) in favor of Unix Stream files.
Which means that you're _sort of_ right.
I'd very much like to see services be designed to actually be network
"enabled;" the more that happens, the more useful it should become.
But I don't think it's there yet.
--
[EMAIL PROTECTED] - <http://www.hex.net/~cbbrowne/linux.html>
Rules of the Evil Overlord #177. "If a scientist with a beautiful and
unmarried daughter refuses to work for me, I will not hold her
hostage. Instead, I will offer to pay for her future wedding and her
children's college tuition." <http://www.eviloverlord.com/>
------------------------------
** 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
******************************