Linux-Development-Sys Digest #435, Volume #8 Mon, 22 Jan 01 12:13:18 EST
Contents:
Re: Specifying libraries with gcc and/or ld (Frank Sweetser)
Re: Specifying libraries with gcc and/or ld ([EMAIL PROTECTED])
Re: How to change a directory in a program? ([EMAIL PROTECTED])
Re: Specifying libraries with gcc and/or ld (Rouben Rostamian)
Re: How to change a directory in a program? (fred smith)
Re: How to change a directory in a program? (Mario Klebsch)
Device driver (Yamazaki Kasparov)
How to write an application similar to "ps -aux" ("Alan Po")
CHS value of a block (Marty)
Re: How to write an application similar to "ps -aux" (Josef Moellers)
Re: CHS value of a block (Josef Moellers)
Re: Device driver ("Z")
Re: CHS value of a block ([EMAIL PROTECTED])
Re: Distributed FileSystem (Alexander Eichhorn)
Re: How to write an application similar to "ps -aux" (Chris)
Re: double mmap calls ([EMAIL PROTECTED])
----------------------------------------------------------------------------
From: [EMAIL PROTECTED] (Frank Sweetser)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Specifying libraries with gcc and/or ld
Date: 22 Jan 2001 01:39:04 GMT
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>There may be a simple answer to this question, but hours of searching
>have not revealed it. Basically, what I'm trying to do is compile a
>program with precise library specification. I do not want any default
>system libraries or include files to be used. I have tried using
>
>make CFLAGS="-v -nostdlib -nostdinc -I/my/include/directory
>-L/my/library/directory -lsomelib"
And how, pray tell, do you plan to use C library functions without the
C library? Any such functions you use, you'll have to reimplement
purely in plain C and syscalls.
--
Frank Sweetser rasmusin at wpi.edu, fs at suave.net | $ x 14
Full-time WPI Network Tech, Part time Linux/Perl guy |
Dad are you vicariously living through me in the hope that my
accomplishments will validate your mediocre life and in some way compensate for
all the opportunities you botched ? -- Calvin
------------------------------
From: [EMAIL PROTECTED]
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Specifying libraries with gcc and/or ld
Date: Mon, 22 Jan 2001 03:55:32 GMT
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Frank Sweetser) wrote:
>
> And how, pray tell, do you plan to use C library functions without the
> C library? Any such functions you use, you'll have to reimplement
> purely in plain C and syscalls.
Scrapping libc is not really my intent. Suppose I want to compile two
versions of sed that link to two copies of libc in two different
locations. I want both sed's to link dynamically, and if I delete one of
the libc's, the corresponding sed should stop working. The reason why I
want to do this isn't really relevant, and sed/libc are just being used
as an example. Do you know how one could accomplish such a thing?
Sent via Deja.com
http://www.deja.com/
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: How to change a directory in a program?
Date: Mon, 22 Jan 2001 04:51:43 GMT
"Alan Po" <[EMAIL PROTECTED]> writes:
> I have tried to write an application which can let the user to
> change the current directory, I use a system function "chdir" but it
> doesn't work.
There seems to be several things not working.
> Part of my programme is:
>
> printf("Please input a directory name:");
> scanf(cp);
First error:
scanf expects to have multiple arguments. That should probably be:
scanf("%s", cp);
> if (chdir(cp))
> printf("no such directory %s", cp);
> It doesn't work. I am also try to use system("cd xyz") but also
> fail. Please give me some advices.
The _other_ error is in how you seem to be treating the "current
directory."
The process does not have any directory tied to it; the process runs
in memory and really doesn't care where it is.
When you use system("cd somewhere"), that takes the CWD directory
value associated with the shell environment, generates a new shell
environment where the directory changes based on "somewhere," and then
_throws the environment away_.
In effect, you're trying hard to do something that is unfortunately
fairly much useless.
You probably should explain a bit more clearly what it is that you're
trying to accomplish by "being in a particular directory;" it may be
something that would be better done using some other "idiom."
--
(concatenate 'string "cbbrowne" "@ntlug.org")
http://vip.hyperusa.com/~cbbrowne/unix.html
"It don't mean a thing, if it ain't got that swing..."
------------------------------
From: [EMAIL PROTECTED] (Rouben Rostamian)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Specifying libraries with gcc and/or ld
Date: 22 Jan 2001 00:39:49 -0500
In article <94gavi$lsj$[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]> wrote:
>
>Scrapping libc is not really my intent. Suppose I want to compile two
>versions of sed that link to two copies of libc in two different
>locations. I want both sed's to link dynamically, and if I delete one of
>the libc's, the corresponding sed should stop working. The reason why I
>want to do this isn't really relevant, and sed/libc are just being used
>as an example. Do you know how one could accomplish such a thing?
The rpath flag to the linker may be what you are looking for:
LIB=/path/to/testlib
gcc prog.c -W,l-rpath,$LIB -L$LIB -lmylib
(You may also need a -I/some/path for the #include files.)
The path to the library gets hard-coded in the resulting executable.
As long as the library is there, the executable will access it and run.
When the library goes away, the executable will stop working.
--
Rouben Rostamian <[EMAIL PROTECTED]>
------------------------------
Crossposted-To:
comp.os.linux.development,comp.os.linux.development.apps,linux.dev.c-programming
From: fred smith <[EMAIL PROTECTED]>
Subject: Re: How to change a directory in a program?
Date: Sun, 21 Jan 2001 23:56:05 GMT
In comp.os.linux.development Alan Po <[EMAIL PROTECTED]> wrote:
: Dear all
: I have tried to write an application which can let the user to change the
: current directory, I use a system function "chdir" but it doesn't work.
Actually it does, it's just not obvious because you're expecting it
to do it in a way that isn't how it works....
: Part of my programme is:
: printf("Please input a directory name:");
: scanf(cp);
: if (chdir(cp))
: printf("no such directory %s", cp);
: It doesn't work. I am also try to use system("cd xyz") but also fail. Please
: give me some advices.
Lemme guess, if your program is named chdir, at a shell prompt you are
typing:
chdir foobar
What happens is:
1. the shell that takes your command fork()s itself
2. the child of that fork is another shell which exec()s your program, chdir,
and gives it the argument "foobar".
3. chdir changes directories to foobar (assuming there is such a directory).
4. this child process then exits.
5. your original shell takes control again.
The original shell HAS NOT changed directories, just the program chdir
did. When chdir exited the change "evaporated". Why? Because the chdir
only affects the current process which happens to be the CHILD process
that is run and then exits, not the parent shell, which is the one to
which you are giving commands.
To help understand, in your program try adding this after the chdir():
{
char buf[255];
if (getcwd (buf, sizeof (buf)) != NULL)
printf ("current directory is: %s\n", buf);
}
Fred
--
---- Fred Smith -- [EMAIL PROTECTED] ----------------------------
"Not everyone who says to me, 'Lord, Lord,' will enter the kingdom of
heaven, but only he who does the will of my Father who is in heaven."
============================== Matthew 7:21 (niv) =============================
------------------------------
From: [EMAIL PROTECTED] (Mario Klebsch)
Subject: Re: How to change a directory in a program?
Date: Mon, 22 Jan 2001 09:56:50 +0100
[EMAIL PROTECTED] writes:
>The _other_ error is in how you seem to be treating the "current
>directory."
>The process does not have any directory tied to it;
It does have a CWD.
>the process runs
>in memory and really doesn't care where it is.
>When you use system("cd somewhere"), that takes the CWD directory
>value associated with the shell environment, generates a new shell
>environment where the directory changes based on "somewhere," and then
>_throws the environment away_.
There is a CWD environment variable, but it does not really have to do
with the CWD. It is a shell feature, to maintain this variable, but
the system completely ignores it.
73, Mario
--
Mario Klebsch [EMAIL PROTECTED]
PGP-Key available at http://www.klebsch.de/public.key
Fingerprint DSS: EE7C DBCC D9C8 5DC1 D4DB 1483 30CE 9FB2 A047 9CE0
Diffie-Hellman: D447 4ED6 8A10 2C65 C5E5 8B98 9464 53FF 9382 F518
------------------------------
From: Yamazaki Kasparov <[EMAIL PROTECTED]>
Subject: Device driver
Date: Mon, 22 Jan 2001 17:56:15 +0800
Reply-To: [EMAIL PROTECTED]
Hi ,
I have no experience in developing device driver . I read some books an
just follow the examples. But it was nothing and no use.
I still have no idea how to write a device driver .......... for mouse
, pci card , smart card etc .
Help me . Pls advice me on this .
------------------------------
From: "Alan Po" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: How to write an application similar to "ps -aux"
Date: Mon, 22 Jan 2001 18:06:37 +0800
Dear all
Alan Po again. This time is the question of a common command "ps". I need to
write an application to show all the process id (pid) of the Linux. The
result is same as "ps -aux". However, I have try to find the source code of
"ps" but fail. Please give some advices or suggestion or where can find the
source code of "ps".
Really thanks a lot.
Alan Po
------------------------------
From: Marty <[EMAIL PROTECTED]>
Subject: CHS value of a block
Date: Mon, 22 Jan 2001 18:20:58 +0800
How to get the CHS (cylinder, head, sector) value given a block number
in a hard disk ?
Thanks,
Marty.
------------------------------
From: Josef Moellers <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: How to write an application similar to "ps -aux"
Date: Mon, 22 Jan 2001 13:10:27 +0100
Alan Po wrote:
> =
> Dear all
> =
> Alan Po again. This time is the question of a common command "ps". I ne=
ed to
> write an application to show all the process id (pid) of the Linux. The=
> result is same as "ps -aux". However, I have try to find the source cod=
e of
> "ps" but fail. Please give some advices or suggestion or where can find=
the
> source code of "ps".
Although I should not do your homework, I'll give you some hints:
1) /proc
2) rpm -qif `which ps`
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
From: Josef Moellers <[EMAIL PROTECTED]>
Subject: Re: CHS value of a block
Date: Mon, 22 Jan 2001 13:14:50 +0100
Marty wrote:
> =
> How to get the CHS (cylinder, head, sector) value given a block number
> in a hard disk ?
> =
> Thanks,
> Marty.
Physically speaking, this may not be possible, because you may have a
solid state disk and these tend to not have cylinders and heads.
If you have the number of sectors/track (spt) and the number of heads
(hds), the assumption is that the sector numbers are such that tracks
fill first, the cylinders, so if you have a linear block address (LBA):
LBA mod spt + 1=3D sector (Note sectors are usually numbered 1..spt)
(LBA div spt) mod hds =3D head
LBA div (spt * hds) =3D cylinder
The values for spt and hds can be obtained using ioctl(fd,
HDIO_GETGEO,&buf).
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
From: "Z" <[EMAIL PROTECTED]>
Subject: Re: Device driver
Date: Mon, 22 Jan 2001 14:31:06 +0100
Once upon a while "Yamazaki Kasparov" <[EMAIL PROTECTED]> wrote:
> Hi ,
>
> I have no experience in developing device driver . I read some books an
> just follow the examples. But it was nothing and no use.
> I still have no idea how to write a device driver .......... for mouse
> , pci card , smart card etc .
>
> Help me . Pls advice me on this .
Well, I think there is nothing more than you can do
but read some book and understand what it says. My
copy of Alessandro Rubini's "Linux Device Drivers"
lead me quite good thru the process of developing a
driver for some pci device.
Also there is some web resources you should note which
guide you when writing drivers for newer kernels.
(Alessandro concentrated on the than actual kernel 2.0)
Richard Gooch writes up some very helpful changes document
for the newer kernel versions:
http://www.atnf.csiro.au/~rgooch/linux/docs/index.html
The "Linux Kernel Module Programming Guide" by Ori Pomerantz
is quite helpful too:
http://gd.tuwien.ac.at/platform/linux/LDP/LDP/lkmpg/mpg.html
Last but not least I'ld recommend to read up "The Linux Kernel"
by David A Rusling at:
http://www.linuxdoc.org/LDP/tlk/tlk.html
For smart cards (I hope you are talking of pcmcia but am
not absolutly sure :-) ) try:
http://pcmcia-cs.sourceforge.net/ftp/doc/PCMCIA-PROG.html
I hope that these links are helpful and wish you much luck
with your first kernel driver.
But note, that you should overthink twice wether you'll
need a kernel driver for what you want to do or not.
--
Z ([EMAIL PROTECTED])
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: CHS value of a block
Date: Mon, 22 Jan 2001 13:32:52 GMT
Josef Moellers <[EMAIL PROTECTED]> wrote:
> Marty wrote:
>>
>> How to get the CHS (cylinder, head, sector) value given a block number
>> in a hard disk ?
>>
>> Thanks,
>> Marty.
> Physically speaking, this may not be possible, because you may have a
> solid state disk and these tend to not have cylinders and heads.
> If you have the number of sectors/track (spt) and the number of heads
> (hds), the assumption is that the sector numbers are such that tracks
> fill first, the cylinders, so if you have a linear block address (LBA):
This will give you a number for the (C,H,S) set... but it may or may not
have any physical relevance.
Many modern hard drives, while working in CHS numbers do not map these
physically. For example, the CHS numbers assume a fixed nbr of sectors
on each track -- not necesarily the case since tracks at the periphery
of a platter can hold more sectors.
Basically the CHS number is a kludge which maps to a specific sector.
LBA maps to a specific sector also. Unless you know the internals of your
particular hard drive, these numbers do not have any guaranteed physical
relevance.
JT.
------------------------------
From: Alexander Eichhorn <[EMAIL PROTECTED]>
Subject: Re: Distributed FileSystem
Date: Mon, 22 Jan 2001 14:58:15 +0100
Reply-To: [EMAIL PROTECTED]
Joff schrieb:
>
> I'm trying to write from scratch a Distributed FileSystem for Linux.
> I don't know very well how to start. :)
> Does anyone have some experience, or links, or anything that can share with
> me for some help?
>
> Thanks in advance,
>
> Jos� Ferreira.
Oh, that isn't an easy task and too much work for a single person.
If you're interested in distributed filesystems, have a look at the
CODA Filesystem from the Carnegie Mellon University:
http://www.coda.cs.cmu.edu/
Take this as a very good starting point. Further readings should
include basic concepts from distributed systems research like concepts
for persistence, naming and replication (only to name a few).
Good Luck
--
Alexander Eichhorn
Technical University of Ilmenau
Computer Science And Automation Faculty
Distributed Systems and Operating Systems Department
Phone +49 3677 69 4557, Fax +49 3677 69 4541
------------------------------
From: Chris <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: How to write an application similar to "ps -aux"
Date: Mon, 22 Jan 2001 14:13:58 +0000
Alan Po wrote:
>
> Dear all
>
> Alan Po again. This time is the question of a common command "ps". I need to
> write an application to show all the process id (pid) of the Linux. The
> result is same as "ps -aux". However, I have try to find the source code of
> "ps" but fail. Please give some advices or suggestion or where can find the
> source code of "ps".
For each process, there exists a directory
/proc/<pid> where <pid> is the numeric process-id
of the process.
/proc/<pid>/cmdline is the \0-separated arguments
to the command.
The owner of /proc/<pid> is the owner of the
process.
The other information comes from /proc/<pid>/status
and other files.
But note that none of this is remotely portable.
--
Chris Lightfoot -- chris at ex dash parrot dot com --
www.ex-parrot.com/~chris/
Dogs believe they are human. Cats believe they are God.
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: double mmap calls
Date: Mon, 22 Jan 2001 16:26:08 -0000
On Sat, 20 Jan 2001 13:38:51 +0100 Kasper Dupont <[EMAIL PROTECTED]> wrote:
| The file may be removed with unlink as soon as it has been
| opened, and it may be closed as soon as it has been maped.
| If you don't want to use a file at all you can use a shared
| memory segment. See man pages for shmget, shmat and shmctl.
I can always mmap() on /dev/zero for anonymous space. But if
there is yet another way with shmget and friends, I'd at least
be curious how to set that up in this peculiar way. Since the
shm* functions have always confused me because documentation
all seems to lack some piece of crucial information I do not
know, maybe your example might even clear that up.
--
=================================================================
| Phil Howard - KA9WGN | Dallas | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/ |
=================================================================
------------------------------
** 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
******************************