Linux-Development-Sys Digest #675, Volume #8     Sat, 28 Apr 01 23:13:06 EDT

Contents:
  Re: mount root file system with read-write (John Kelly)
  Re: Startup service ("D. Stimits")
  Trouble with pipe implementation ("Frank L. Liao")
  Re: Startup service ("Darren")
  Re: kernel number meaning ("Darren")
  Re: How to find out whether the device(floppy drivers,zip drives) is removable on 
linux ("Luiz Rafael Culik Guimaraes")
  Re: ifconfig command (Sachio)
  Re: How to find out whether the device(floppy drivers,zip drives) is removable on 
linux ("Peter T. Breuer")
  Re: sockets ("Cameron Kerr")
  Re: Startup service ("Cameron Kerr")
  Re: ifconfig command ("Cameron Kerr")
  Kernel 2.4.4 Problems ("Fruitbat")
  Pipe problem (Frank)
  Pipe Problem (Frank)

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

From: John Kelly <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: Re: mount root file system with read-write
Date: Sat, 28 Apr 2001 15:19:45 -0600

In your /etc/lilo.conf file, you can make an entry similar to:

image = /boot/vmlinuz-2.2.16-22
  label = linux-ram
  root = /dev/ram0
  initrd = /boot/ramdisk.img.gz


Run lilo, reboot, and select linux-ram at the lilo prompt

-jk



lmc83 wrote:

> hi,
>     How to mount a initrd as root file system with read-write?
>     I pass kernel parameter with:
>         "linux root=/dev/ram0 init=/linuxrc rw"
>     but it seems still mounted as read-only,
>     what's wrong?
>
>     Liang Ming-Chung


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

Date: Sat, 28 Apr 2001 15:23:29 -0600
From: "D. Stimits" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: Re: Startup service

Darren wrote:
> 
> Hello all I am writing a small app that I want to run as a Linux service
> when it starts up. Can anyone tell me if I need any special consideration
> when writing a Linux tsr? also does one know which file it stores the info
> on startup apps in?
> 
> Thank you
> 
> Darren

There isn't really anything called a tsr in linux. It is just a daemon.
The typical daemon does a fork and exec after being started by an rc
script. For redhat, the script samples are in /etc/rc.d/init.d/. For
other distributions, they are in an init.d directory, but it might be
located somewhere else; I think SuSE uses /sbin/init.d/ or something
like that. Programs that are not really system daemons but are desired
to start each reboot often are just added in by editing
/etc/rc.d/rc.local (again, location will vary with distribution, but it
is usually named rc.local). SuSE also has an rc script in /etc/ that
yast uses.

The scripts usually take arguments of "start", "stop", "status", and
"restart". Symbolic links from various runlevel directories (e.g.,
/etc/rc.d/rc.0 through rc.6) named starting with a "k" will kill the
process at those levels, but if the sym link is done with a name
starting with "s" it starts it at that level (your mileage may vary
depending on distribution). Other complexities are that for security it
isn't unusual to arrange for the daemon to start as root but to be
transferred for execution as user "nobody" (or some other less
privileged user); and there is often some sort of lock file or pid file
to let the system know what pid the process is at.

D. Stimits, [EMAIL PROTECTED]

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

From: "Frank L. Liao" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Trouble with pipe implementation
Date: Sat, 28 Apr 2001 14:25:51 -0700

Hi guys,

I'm currently having a problem implmenting pipe into a custom shell I'm
writing.  It seems that when I do "ls | cat", it seems to be fine.
Though, when I call "ls | cat | netscape" it seems to hang on "cat".
Then, I try it again.  "ls | cat" works.  Then, I tried "ls | cat"
again, it would hang.  What am I doing wrong here?

Frank
TIA

/* The code I made is on the bottom.  pList is a link list of structs
which contains argv and argc.  nPipes is the number of Pipe operators
(not operands) that I'm going to execute.  So, if nPipe = 1, then there
are two argv's that need to be executed. */

void ExecutePipe(struct CmdLine *pList, int nPipes)
{
 int i;
 int fidPipe[2];
 enum PIPES { READ, WRITE }; /* Constants 0 and 1 for READ and WRITE */
 struct CmdLine *pCurrent = pList;

 pipe(fidPipe);

 for(i = 0; i < nPipes + 1; i++) {
  if(i == nPipes) {
   /* If this is the last program to be executed, we need to close the
write pipe
         before continuing, since we have no need for this pipe anymore.
*/
   close(fidPipe[WRITE]);
   if(fork() == 0) {
    /* Close current stdin to keyboard */
    close(fileno(stdin));
    /* copy the handle of the pipe to stdin*/
    dup(fidPipe[READ]);
    /* now close the handle of the pipe. So that only stdin/pipe is
open*/
    close(fidPipe[READ]);

    execvp(pCurrent->argv[0], pCurrent->argv);
   } else {
    int status;
    wait(&status);
   }
  } else {
   if(fork() == 0) {
    if(i != 0) {
     /* if we are in the middle of a pipe, stdin should be closed and be
converted to
        the read of the pipe. */
     close(fileno(stdin));
     dup(fidPipe[READ]);
    }
    /* Now, close the read end of the pipe since we don't need it */
    close(fidPipe[READ]);
    /* Close stdout, which would be redircted the the write end of the
pipe */
    close(fileno(stdout));
    dup(fidPipe[WRITE]);
    /* Close the write pipe, which we don't need */
    close(fidPipe[WRITE]);

    execvp(pCurrent->argv[0], pCurrent->argv);
   } else {
    int status;
    wait(&status);
   }
  }
  pCurrent = pCurrent->pNextNode;

 }

 return;
}


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

From: "Darren" <[EMAIL PROTECTED]>
Subject: Re: Startup service
Date: Sat, 28 Apr 2001 22:57:37 +0100


D. Stimits <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> Darren wrote:
> >
> > Hello all I am writing a small app that I want to run as a Linux service
> > when it starts up. Can anyone tell me if I need any special
consideration
> > when writing a Linux tsr? also does one know which file it stores the
info
> > on startup apps in?
> >
> > Thank you
> >
> > Darren
>
> There isn't really anything called a tsr in linux. It is just a daemon.

that would be typical of linux. so smooth and consistent :-)

> The typical daemon does a fork and exec after being started by an rc
> script.
whats the differece between a fork and an exec?



For redhat, the script samples are in /etc/rc.d/init.d/. For
> other distributions, they are in an init.d directory, but it might be
> located somewhere else; I think SuSE uses /sbin/init.d/ or something
> like that. Programs that are not really system daemons but are desired
> to start each reboot often are just added in by editing
> /etc/rc.d/rc.local (again, location will vary with distribution, but it
> is usually named rc.local). SuSE also has an rc script in /etc/ that
> yast uses.

aha so it is rc.local i am looking for?

>
> The scripts usually take arguments of "start", "stop", "status", and
> "restart". Symbolic links from various runlevel directories (e.g.,
> /etc/rc.d/rc.0 through rc.6) named starting with a "k" will kill the
> process at those levels,
forgive me for being stupid, but i do not understand



but if the sym link is done with a name
> starting with "s" it starts it at that level (your mileage may vary
> depending on distribution). Other complexities are that for security it
> isn't unusual to arrange for the daemon to start as root but to be
> transferred for execution as user "nobody" (or some other less
> privileged user);
now this i understand. I do have need to have a process start at bootup and
as all processes need a user connection then i need to create a virual user
with priviledges to access only the required reources and attach the process
to that user, if that makes any sense




 and there is often some sort of lock file or pid file
> to let the system know what pid the process is at.

Thank you for your reply D you have been most kind

>
> D. Stimits, [EMAIL PROTECTED]



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

From: "Darren" <[EMAIL PROTECTED]>
Subject: Re: kernel number meaning
Date: Sat, 28 Apr 2001 23:02:21 +0100


stefano <[EMAIL PROTECTED]> wrote in message
news:9cej64$rat$[EMAIL PROTECTED]...
> Hi everybody,
> uname -a  informs me I'm using kernel 2.2.12-20 on my machine.
> But I can't figure out what does 12-20 mean?
> If I want to use a newer kernel from which patch should I start upgrading
?
> Thankyou for any help.

its a release thing. The kernel number is a reference to how many problems
have been found and fixed as well as how to handle new technology. For
example  kernel 1.1.59 recognized sound blaster CD roms but not IDE ones
where as kernel 1.7 does recons IDE CD roms. it is an evolution thing




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

From: "Luiz Rafael Culik Guimaraes" <[EMAIL PROTECTED]>
Crossposted-To: linux.act.gcc,linux.dev.c-programming
Subject: Re: How to find out whether the device(floppy drivers,zip drives) is 
removable on linux
Date: Sat, 28 Apr 2001 13:57:51 -0300

Dear Friend Peter
> > How  to retreive the free space on a device pointed by the filepath.
>
> man df

Thanks for the answer. But i need to get this From C code

is their any way

Regards

Luiz Rafael Culik



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

From: Sachio <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: ifconfig command
Date: Sat, 28 Apr 2001 23:13:23 GMT

Thanks, Peter, my response is mixed in with yours, please, scroll down.

"Peter T. Breuer" wrote:

> In comp.os.linux.development.apps Sachio <[EMAIL PROTECTED]> wrote:
> > When you execute 'ifconfig' with no other arguments, where does the
> > utility retrieve the information from?  I have one network adapter that
>
> From the kernel. It reports all "up" interfaces.
>

Yes, I understand that.   The question now would be where does the
kernel store it?  Is there a config file of some sort?


> > is dhcp, and I'm wanting to find out where ifconfig retrieves the
> > assigned ip from.
>
> It makes ioctls on a socket to get the information about each interface
> in turn.

> > Also, which directory/file contains the source code for the ifconfig utility?
>
> The one called ifconfig.c (and more). Download the source code for your
> ifconfig and you will see.

Ok, good!  I thought there might be a source file by that name.  I searched on
my system, but I guess I don't have that one stored on my drive.  I'll go get it.

Thanks, again, Peter!



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

From: "Peter T. Breuer" <[EMAIL PROTECTED]>
Crossposted-To: linux.act.gcc,linux.dev.c-programming
Subject: Re: How to find out whether the device(floppy drivers,zip drives) is 
removable on linux
Date: Sun, 29 Apr 2001 01:39:46 +0200

In comp.os.linux.development.system Luiz Rafael Culik Guimaraes 
<[EMAIL PROTECTED]> wrote:
> Dear Friend Peter
>> > How  to retreive the free space on a device pointed by the filepath.
>>
>> man df

> Thanks for the answer. But i need to get this From C code

> is their any way

man statfs

Peter

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

From: "Cameron Kerr" <[EMAIL PROTECTED]>
Subject: Re: sockets
Date: Sun, 29 Apr 2001 12:37:02 +1200

[Posting only to this group]

I found Beej's Guide to Socket Programming (or named similar)
to be a REALLY good tutorial (so have many many other poeple).

I wouldn't reccommend Unix Network Programming for someone
just learning standard sockets, its more useful as a more
advanced reference.

-- 
Cameron Kerr -- cameron.kerr @ paradise.net.nz
Praise Slackware, our baud and saviour!
--

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

From: "Cameron Kerr" <[EMAIL PROTECTED]>
Subject: Re: Startup service
Date: Sun, 29 Apr 2001 12:54:16 +1200

<snip>

> whats the differece between a fork and an exec?

Fork creates a child process. The created process is the
same as the creating process, with no shared state, and
same instruction pointers etc.

Exec is used to replace the current process (usually in
the child) with another process, overwriting the current
process. No new process is created.

<snip>

> aha so it is rc.local i am looking for?

If you want to create a standalone deamon. If you want
the internet super-server (inetd or xinetd), it is much
easier. You just write your program to use stdin and stdout
as the input/output to the client. You then edit
/etc/inetd.conf or /etc/xinetd.{conf|d/*} and restart
the super-server by sending the -HUP signal

killall -HUP inetd

>> The scripts usually take arguments of "start", "stop", "status", and
>> "restart". Symbolic links from various runlevel directories (e.g.,
>> /etc/rc.d/rc.0 through rc.6) named starting with a "k" will kill the
>> process at those levels,
> forgive me for being stupid, but i do not understand

Virtually all GNU/Linux systems have a concept of
"runlevels" (this is a System V concept). Runlevel
0 means "system shutdown", 6 means "system restart",
1 means "single user", 3 is typically "multiuser without
the X Window System", 4 or 5 is usually the same as 3, but
with GUI. Some of this is distribution independant. Look
in /etc/inittab for the gory details.

Anyway, on systems with SysV style setups (most), when
a runlevel is changed, services are started or stopped
according to the various symlinks. The best way to find
out would be to look for yourself (try /etc/rc.d/rc[0123456].d/
in Redhat. The system will automatically append "start"
or "stop" to services that it needs to start or stop.

In all, I suggest you read the following

The GNU libc manual (ftp.gnu.org/gnu/Manuals/glibc)
The Linux Programmers Guide (www.linuxdoc.org/guides)
And constantly be on the lookout for any useful articles
that teach you about certain things. You might find
www.ibm.com :: Developer :: Linux :: Linux Articles
useful. Also www.google.com :: Web directory :: * :: Linux ::
Resources would be useful to you.

Hope this helps
-- 
Cameron Kerr -- cameron.kerr @ paradise.net.nz
Praise Slackware, our baud and saviour!
--

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

From: "Cameron Kerr" <[EMAIL PROTECTED]>
Subject: Re: ifconfig command
Crossposted-To: comp.os.linux.development.apps
Date: Sun, 29 Apr 2001 13:02:36 +1200

<snip>

>> From the kernel. It reports all "up" interfaces.
>>
> 
> Yes, I understand that.   The question now would be where does the
> kernel store it?  Is there a config file of some sort?

No, ifconfig is called at startup with appropriate
paramamters according to the methods of the distrobution.

Slackware: neat the top of /etc/rc.d/rc.inet1
Redhat: /etc/sysconfig/network, and /etc/sysconfig.d/network-scripts
*BSD: /etc/rc.conf

As you can see, there is no standard way

>> > is dhcp, and I'm wanting to find out where ifconfig retrieves the
>> > assigned ip from.
>>
>> It makes ioctls on a socket to get the information about each interface
>> in turn.
> 
>> > Also, which directory/file contains the source code for the ifconfig
>> > utility?
>>
>> The one called ifconfig.c (and more). Download the source code for your
>> ifconfig and you will see.
> 
> Ok, good!  I thought there might be a source file by that name.  I
> searched on my system, but I guess I don't have that one stored on my
> drive.  I'll go get it.

Look for the source of netkit, I believe.
try www.sunsite.edu.au

-- 
Cameron Kerr -- cameron.kerr @ paradise.net.nz
Praise Slackware, our baud and saviour!
--

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

From: "Fruitbat" <[EMAIL PROTECTED]>
Subject: Kernel 2.4.4 Problems
Date: Sun, 29 Apr 2001 02:48:13 GMT

I have just compiled the 2.4.4 kernel and have found that my pppoe based
ADSL connection times out when attempting to connect on my RH7.1 system, the
system log is as follows:

Apr 29 10:45:31 fruitbat pppd[1301]: Exit.
Apr 29 10:45:57 fruitbat pppd[1351]: pppd 2.4.1 started by root, uid 0
Apr 29 10:45:57 fruitbat pppd[1351]: Using interface ppp0
Apr 29 10:45:57 fruitbat pppd[1351]: Connect: ppp0 <--> /dev/pts/2
Apr 29 10:46:28 fruitbat pppd[1351]: LCP: timeout sending Config-Requests
Apr 29 10:46:28 fruitbat pppd[1351]: Connection terminated.
Apr 29 10:46:32 fruitbat pppoe[1352]: Timeout waiting for PADO packets
Apr 29 10:46:32 fruitbat pppd[1351]: Exit.

I have backed out to kernel 2.4.3 and everything is fine. Has anyone else
experienced this problem with 2.4.4?


--
^^Fruitbat^^



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

From: Frank <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Pipe problem
Date: Sat, 28 Apr 2001 08:00:22 -0700

Hi all,

I'm currently implementing the pipe operator for a custom shell. 
Though, it seems that my pipe hangs on the second process when I try to
pipe more than 2 programs.  So, I could only assume that I might have
implemented the pipe wrong for all processes in between.  So, the only
assumption is the the first process and the last process works
correctly.  So, I'm wondering what am I doing wrong with the processes
in between.

Frank
TIA

/* NOTE:  nPipes is the number of operators present.  So, if nPipes = 2,
then 3 programs need to be executed */

void ExecutePipe(struct CmdLine *pList, int nPipes)
{
  int i;
  int fidPipe[2];
  enum PIPES { READ, WRITE }; /* Constants 0 and 1 for READ and WRITE */
  struct CmdLine *pCurrent = pList;

  pipe(fidPipe);

  for(i = 0; i < nPipes + 1; i++) {
    if(i == nPipes) {
      ...
      if( (pid = fork()) == 0
        execvp(pCurrent->argv[0], pCurrent->argv);
        } else {
        waitpid(...)
        ...
      }
    } else {
      int pid;
      if((pid = fork()) == 0) {
        if(i != 0) {
          /* if we are in the middle of a pipe, stdin should be closed
and be converted to the read of the pipe. */
          close(fileno(stdin));
          dup2(fidPipe[READ], fileno(stdin));
         }
         /* Now, close the read end of the pipe since we don't need it
*/
         lose(fidPipe[READ]);
         /* Close stdout, which would be redircted the the write end of
the pipe */
         close(fileno(stdout));
         dup2(fidPipe[WRITE], fileno(stdout));
         /* Close the write pipe, which we don't need */
         close(fidPipe[WRITE]);
         execvp(pCurrent->argv[0], pCurrent->argv);
       } else {
         int status;
         waitpid(pid, &status, 0);
       }
     }
     pCurrent = next in link list;
   }    
  return;
}

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

From: Frank <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Pipe Problem
Date: Sat, 28 Apr 2001 20:08:06 -0700

Hi all,

I'm currently implementing the pipe operator for a custom shell. 
Though, it seems that my pipe hangs on the second process when I try to
pipe more than 2 programs.  So, I could only assume that I might have
implemented the pipe wrong for all processes in between.  So, the only
assumption is the the first process and the last process works
correctly.  So, I'm wondering what am I doing wrong with the processes
in between.

Frank
TIA

/* NOTE:  nPipes is the number of operators present.  So, if nPipes = 2,
then 3 programs need to be executed */

void ExecutePipe(struct CmdLine *pList, int nPipes)
{
  int i;
  int fidPipe[2];
  enum PIPES { READ, WRITE }; /* Constants 0 and 1 for READ and WRITE */
  struct CmdLine *pCurrent = pList;

  pipe(fidPipe);

  for(i = 0; i < nPipes + 1; i++) {
    if(i == nPipes) {
      ...
      if( (pid = fork()) == 0
        execvp(pCurrent->argv[0], pCurrent->argv);
        } else {
        waitpid(...)
        ...
      }
    } else {
      int pid;
      if((pid = fork()) == 0) {
        if(i != 0) {
          /* if we are in the middle of a pipe, stdin should be closed
and be converted to the read of the pipe. */
          close(fileno(stdin));
          dup2(fidPipe[READ], fileno(stdin));
         }
         /* Now, close the read end of the pipe since we don't need it
*/
         lose(fidPipe[READ]);
         /* Close stdout, which would be redircted the the write end of
the pipe */
         close(fileno(stdout));
         dup2(fidPipe[WRITE], fileno(stdout));
         /* Close the write pipe, which we don't need */
         close(fidPipe[WRITE]);
         execvp(pCurrent->argv[0], pCurrent->argv);
       } else {
         int status;
         waitpid(pid, &status, 0);
       }
     }
     pCurrent = next in link list;
   }    
  return;
}

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


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

Reply via email to