From 37535317d9612bb365a3dce08b0b1d2d71e387b3 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 26 Jan 2001 14:12:48 +0000 Subject: 2001-01-25 Joel Sherrill * cpu.c, rtems/score/cpu.h: Bug report from Peter Mueller because of not correcting for the ISR vector table now being allocated from the workspace. --- c/src/exec/libcsupport/src/Makefile.am | 2 +- c/src/exec/libcsupport/src/chroot.c | 59 ++++++++++++++++++++++++++++++++++ c/src/lib/ChangeLog | 6 ++++ c/src/lib/libc/Makefile.am | 2 +- c/src/lib/libc/chroot.c | 59 ++++++++++++++++++++++++++++++++++ cpukit/libcsupport/src/chroot.c | 59 ++++++++++++++++++++++++++++++++++ 6 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 c/src/exec/libcsupport/src/chroot.c create mode 100644 c/src/lib/libc/chroot.c create mode 100644 cpukit/libcsupport/src/chroot.c diff --git a/c/src/exec/libcsupport/src/Makefile.am b/c/src/exec/libcsupport/src/Makefile.am index 2c68aa9377..03ac3854c3 100644 --- a/c/src/exec/libcsupport/src/Makefile.am +++ b/c/src/exec/libcsupport/src/Makefile.am @@ -23,7 +23,7 @@ SYSTEM_CALL_C_FILES = open.c close.c read.c write.c lseek.c ioctl.c mkdir.c \ mknod.c mkfifo.c rmdir.c chdir.c chmod.c fchdir.c fchmod.c chown.c \ link.c unlink.c umask.c ftruncate.c utime.c fstat.c fcntl.c fpathconf.c \ getdents.c fsync.c fdatasync.c pipe.c dup.c dup2.c symlink.c readlink.c \ - creat.c + creat.c chroot.c DIRECTORY_SCAN_C_FILES = opendir.c closedir.c readdir.c rewinddir.c \ scandir.c seekdir.c telldir.c getcwd.c diff --git a/c/src/exec/libcsupport/src/chroot.c b/c/src/exec/libcsupport/src/chroot.c new file mode 100644 index 0000000000..b48082bda7 --- /dev/null +++ b/c/src/exec/libcsupport/src/chroot.c @@ -0,0 +1,59 @@ +/* + * chroot() - Change Root Directory + * Author: fernando.ruiz@ctv.es + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#include + +int chroot( + const char *pathname +) +{ + int result; + rtems_filesystem_location_info_t loc; + + if (rtems_current_user_env == &rtems_global_user_env) + set_errno_and_return_minus_one( ENOTSUP ); + + loc = rtems_filesystem_root;i /* save the value */ + + /* if has been already changed */ + rtems_filesystem_root = rtems_global_user_env.filesystem_root; + + result = chdir(pathname); + if (result) { + rtems_filesystem_root = loc; /* restore the value */ + set_errno_and_return_minus_one( errno ); + }; + rtems_filesystem_root = rtems_filesystem_current; + + result = chdir("/"); + if (result) { + rtems_filesystem_root = loc; /* restore the value */ + set_errno_and_return_minus_one( errno ); + }; + + /*XXX : Call this? Sorry but I don't known if it is necesary */ + /* The old root. + rtems_filesystem_freenode( &loc ); + */ + return 0; +} diff --git a/c/src/lib/ChangeLog b/c/src/lib/ChangeLog index e53afe276f..75de54613c 100644 --- a/c/src/lib/ChangeLog +++ b/c/src/lib/ChangeLog @@ -1,4 +1,10 @@ +2001-01-25 Fernando Ruiz + + * Alternate email is correo@fernando-ruiz.com + * libc/chroot.c: New file. + * libc/Makefile.am: Reflect above. + 2001-01-25 Fernando Ruiz * Alternate email is correo@fernando-ruiz.com diff --git a/c/src/lib/libc/Makefile.am b/c/src/lib/libc/Makefile.am index 2c68aa9377..03ac3854c3 100644 --- a/c/src/lib/libc/Makefile.am +++ b/c/src/lib/libc/Makefile.am @@ -23,7 +23,7 @@ SYSTEM_CALL_C_FILES = open.c close.c read.c write.c lseek.c ioctl.c mkdir.c \ mknod.c mkfifo.c rmdir.c chdir.c chmod.c fchdir.c fchmod.c chown.c \ link.c unlink.c umask.c ftruncate.c utime.c fstat.c fcntl.c fpathconf.c \ getdents.c fsync.c fdatasync.c pipe.c dup.c dup2.c symlink.c readlink.c \ - creat.c + creat.c chroot.c DIRECTORY_SCAN_C_FILES = opendir.c closedir.c readdir.c rewinddir.c \ scandir.c seekdir.c telldir.c getcwd.c diff --git a/c/src/lib/libc/chroot.c b/c/src/lib/libc/chroot.c new file mode 100644 index 0000000000..b48082bda7 --- /dev/null +++ b/c/src/lib/libc/chroot.c @@ -0,0 +1,59 @@ +/* + * chroot() - Change Root Directory + * Author: fernando.ruiz@ctv.es + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#include + +int chroot( + const char *pathname +) +{ + int result; + rtems_filesystem_location_info_t loc; + + if (rtems_current_user_env == &rtems_global_user_env) + set_errno_and_return_minus_one( ENOTSUP ); + + loc = rtems_filesystem_root;i /* save the value */ + + /* if has been already changed */ + rtems_filesystem_root = rtems_global_user_env.filesystem_root; + + result = chdir(pathname); + if (result) { + rtems_filesystem_root = loc; /* restore the value */ + set_errno_and_return_minus_one( errno ); + }; + rtems_filesystem_root = rtems_filesystem_current; + + result = chdir("/"); + if (result) { + rtems_filesystem_root = loc; /* restore the value */ + set_errno_and_return_minus_one( errno ); + }; + + /*XXX : Call this? Sorry but I don't known if it is necesary */ + /* The old root. + rtems_filesystem_freenode( &loc ); + */ + return 0; +} diff --git a/cpukit/libcsupport/src/chroot.c b/cpukit/libcsupport/src/chroot.c new file mode 100644 index 0000000000..b48082bda7 --- /dev/null +++ b/cpukit/libcsupport/src/chroot.c @@ -0,0 +1,59 @@ +/* + * chroot() - Change Root Directory + * Author: fernando.ruiz@ctv.es + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#include + +int chroot( + const char *pathname +) +{ + int result; + rtems_filesystem_location_info_t loc; + + if (rtems_current_user_env == &rtems_global_user_env) + set_errno_and_return_minus_one( ENOTSUP ); + + loc = rtems_filesystem_root;i /* save the value */ + + /* if has been already changed */ + rtems_filesystem_root = rtems_global_user_env.filesystem_root; + + result = chdir(pathname); + if (result) { + rtems_filesystem_root = loc; /* restore the value */ + set_errno_and_return_minus_one( errno ); + }; + rtems_filesystem_root = rtems_filesystem_current; + + result = chdir("/"); + if (result) { + rtems_filesystem_root = loc; /* restore the value */ + set_errno_and_return_minus_one( errno ); + }; + + /*XXX : Call this? Sorry but I don't known if it is necesary */ + /* The old root. + rtems_filesystem_freenode( &loc ); + */ + return 0; +} -- cgit v1.2.3