system call in Sun OS - need help 
Author Message
 system call in Sun OS - need help

I am trying to use a system call in Sun OS 4.1.3, chroot. Below is the
pseudo code, the actual code of which compiles and runs without errors but
does not work, ie, change the root directory.

#include <stdio.h>
#include <string.h>
main()
{
int chroot();
char dir[80];

                strcpy(dir,"new/directory");
                chroot(dir);

Quote:
}

Is there something I am not doing in order to make a system call? I would
appreciate any help you can provide. Thanks in advance.

Regrards....John



Mon, 07 Jul 1997 19:10:48 GMT  
 system call in Sun OS - need help

Quote:

>Is there something I am not doing in order to make a system call? I would
>appreciate any help you can provide. Thanks in advance.

  you should check the return value of chroot(); if it fails, call perror()
to see why.  this will provide your answer (so would looking at the manpage).

d.

--
No dogs were harmed in the creation of this .sig.   A cat got sick,
and somebody shot a duck, but that's it.



Tue, 08 Jul 1997 22:32:34 GMT  
 system call in Sun OS - need help

Quote:
>#include <stdio.h>
>#include <string.h>
>main()
>{
>int chroot();
>char dir[80];

>            strcpy(dir,"new/directory");
>            chroot(dir);
>}

>Is there something I am not doing in order to make a system call? I would
>appreciate any help you can provide. Thanks in advance.

1. How do you know it fails?  You're not checking its return value and
   the program terminates before doing anything meaningful.

2. Are you root when executing the program?

3. Checking errno if chroot() doesn't return 0 will give you a clue about
   what went wrong.

4. If you expect the program to change the root directory of the shell
   which invoked it, this will never happen, chroot() will affect only
   the process that called it.

This is a Unix specific question, so it doesn't belong to c.l.c.  Post
such questions to comp.unix.programmer.

Dan
--
Dan Pop
CERN, CN Division

Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



Wed, 09 Jul 1997 08:59:18 GMT  
 system call in Sun OS - need help

    John> I am trying to use a system call in Sun OS 4.1.3,
    John> chroot. Below is the pseudo code, the actual code of which
    John> compiles and runs without errors but does not work, ie,
    John> change the root directory.

    John> #include <stdio.h>
    John> #include <string.h>
    John> main()
    John> {
    John> int chroot();
    John> char dir[80];
    John>            strcpy(dir,"new/directory");
    John>            chroot(dir);
    John> }

There's nothing wrong with this code (although BTW you can write
'chroot("new/directory")' directly), but the chroot function changes
the root directory for the current process and all children of the
current process. If you run this program from your shell it won't
change your shell's root directory--that seems to be what you were
expecting.

Jake

(Followups to comp.unix.programmer)



Sun, 13 Jul 1997 05:03:56 GMT  
 system call in Sun OS - need help

Quote:
> I am trying to use a system call in Sun OS 4.1.3, chroot.
> I would appreciate any help you can provide.  Thanks in advance.

I trust you are running as superuser (i.e., root).
You may need to chdir() to the directory before you chroot() to it.

P.S. Next time you have a question about a SunOS system call, you
might want to post it to comp.unix.programmer, comp.unix.questions
or comp.sys.sun.misc.



Sun, 13 Jul 1997 09:14:11 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. gcc c calls f77 fortran on Sun OS 4.1

2. Help : on using ndbm.h (SUN OS)

3. Calling System Command in SUN C

4. Inexplicable System call failure - HELP - expert needed

5. Inexplicable system call failure! HELP-Expert Needed

6. URGENT : Help needed with system()/fork() call

7. Help with system calls needed

8. Help: SUN Spark-calling Fortran functions

9. HELP:perform system call or call an external program

10. Porting C programs from a SPARC (SUN OS 4.1.1) to a VAX (VMS)

11. Problems Porting clcc code from sun/os to solaris

12. Request "lint" tool for SUN OS

 

 
Powered by phpBB® Forum Software