forked from Imagelibrary/rtems
* libcsupport/Makefile.am: Add mount-mgr.c.
* libcsupport/src/mount-mgr.c: New.
* include/rtems/fs.h: Added rtems_filesystem_location_mount.
* libcsupport/include/rtems/libio.h, libcsupport/src/mount.c: New
mount interface. It is similar to Linux.
* libcsupport/include/rtems/libio_.h: Remove the
init_fs_mount_table call.
* libcsupport/src/base_fs.c: Remove init_fs_mount_table_call. Use
the new mount call. Remove setting the root node in the global
pathloc. Mount does this now.
* libcsupport/src/privateenv.c: Remove the hack to set the root
mount table entry in the environment.
* libcsupport/src/unmount.cL Free the target string.
* libblock/src/bdpart-mount.c: New mount API.
* libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_init.c,
libfs/src/dosfs/dosfs.h, libfs/src/dosfs/msdos.h,
libfs/src/dosfs/msdos_init.c, libfs/src/imfs/imfs.h,
libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_init.c,
libfs/src/imfs/miniimfs_init.c,
libfs/src/nfsclient/src/librtemsNfs.h,
libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs.h,
libnetworking/lib/ftpfs.c, libnetworking/rtems/ftpfs.h,
libnetworking/rtems/tftp.h: New mount_h API.
* libfs/src/devfs/devfs_eval.c: Local include of extern ops.
* libfs/src/nfsclient/src/nfs.c: New mount API. Removed the mount
me call and fixed the initialisation to happen when mounting.
* libmisc/Makefile.am, libmisc/shell/shellconfig.h: Remove mount
filesystem files.
* libmisc/fsmount/fsmount.c, libmisc/fsmount/fsmount.h: Updated to
the new mount table values.
* libmisc/shell/main_mount_ftp.c,
libmisc/shell/main_mount_msdos.c, libmisc/shell/main_mount_rfs.c,
libmisc/shell/main_mount_tftp.c: Removed.
* libmisc/shell/main_mount.c: Use the new mount API. Also access
the file system table for the file system types.
* libnetworking/lib/tftpDriver.c: Updated to the new mount
API. Fixed to allow mounting from any mount point. Also can now
have more than file system mounted.
* sapi/include/confdefs.h: Add file system configuration support.
157 lines
4.2 KiB
C
157 lines
4.2 KiB
C
/*
|
|
* Instantiate a private user environment for the calling thread.
|
|
*
|
|
* Submitted by: fernando.ruiz@ctv.es (correo@fernando-ruiz.com)
|
|
*
|
|
* COPYRIGHT (c) 1989-2000.
|
|
* 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.rtems.com/license/LICENSE.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#if HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include <stdlib.h> /* free */
|
|
|
|
#include <rtems.h>
|
|
#include <rtems/chain.h>
|
|
#include <rtems/libio.h>
|
|
#include <rtems/libio_.h>
|
|
|
|
/* cleanup a user environment
|
|
* NOTE: this must be called with
|
|
* thread dispatching disabled!
|
|
*/
|
|
static void
|
|
free_user_env(void *venv)
|
|
{
|
|
rtems_user_env_t *env = (rtems_user_env_t*) venv ;
|
|
|
|
if (env != &rtems_global_user_env
|
|
#ifdef HAVE_USERENV_REFCNT
|
|
&& --env->refcnt <= 0
|
|
#endif
|
|
) {
|
|
rtems_filesystem_freenode( &env->current_directory);
|
|
rtems_filesystem_freenode( &env->root_directory);
|
|
free(env);
|
|
}
|
|
}
|
|
|
|
rtems_status_code rtems_libio_set_private_env(void) {
|
|
rtems_status_code sc;
|
|
rtems_id task_id;
|
|
rtems_filesystem_location_info_t loc;
|
|
|
|
sc=rtems_task_ident(RTEMS_SELF,0,&task_id);
|
|
if (sc != RTEMS_SUCCESSFUL) return sc;
|
|
|
|
/* Only for the first time a malloc is necesary */
|
|
if (rtems_current_user_env==&rtems_global_user_env) {
|
|
rtems_user_env_t *tmp = malloc(sizeof(rtems_user_env_t));
|
|
if (!tmp)
|
|
return RTEMS_NO_MEMORY;
|
|
|
|
#ifdef HAVE_USERENV_REFCNT
|
|
tmp->refcnt = 1;
|
|
#endif
|
|
|
|
sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,(void(*)(void *))free_user_env);
|
|
if (sc != RTEMS_SUCCESSFUL) {
|
|
/* don't use free_user_env because the pathlocs are
|
|
* not initialized yet
|
|
*/
|
|
free(tmp);
|
|
return sc;
|
|
}
|
|
rtems_current_user_env = tmp;
|
|
};
|
|
|
|
*rtems_current_user_env = rtems_global_user_env; /* get the global values*/
|
|
rtems_current_user_env->task_id=task_id; /* mark the local values*/
|
|
|
|
/* Clone the pathlocs. In contrast to most other
|
|
* code we must _not_ free the original locs because
|
|
* what we are trying to do here is forking off
|
|
* clones. The reason is a pathloc can be allocated by the
|
|
* file system and needs to be freed when deleting the environment.
|
|
*/
|
|
|
|
rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
|
|
rtems_filesystem_root = loc;
|
|
rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
|
|
rtems_filesystem_current = loc;
|
|
|
|
return RTEMS_SUCCESSFUL;
|
|
}
|
|
|
|
/*
|
|
* Share a same private environment beetween two task:
|
|
* Task_id (remote) and RTEMS_SELF(current).
|
|
*/
|
|
|
|
/* NOTE:
|
|
*
|
|
* THIS CODE HAS NO PROTECTION IMPLEMENTED
|
|
*
|
|
* Tasks who wish to share their environments must
|
|
*
|
|
* a) assert that no participants are concurrently
|
|
* executing
|
|
* libio_share_private_env() and/or libio_set_private_env()
|
|
*
|
|
* b) mutex access to rtems_filesystem_current, rtems_filesytem_root
|
|
* while changing any of those (chdir(), chroot()).
|
|
*/
|
|
|
|
#ifndef HAVE_USERENV_REFCNT
|
|
rtems_status_code rtems_libio_share_private_env(rtems_id task_id) {
|
|
rtems_status_code sc;
|
|
rtems_user_env_t * shared_user_env;
|
|
rtems_id current_task_id;
|
|
|
|
sc=rtems_task_ident(RTEMS_SELF,0,¤t_task_id);
|
|
if (sc != RTEMS_SUCCESSFUL) return sc;
|
|
|
|
if (rtems_current_user_env->task_id==current_task_id) {
|
|
/* kill the current user env & task_var*/
|
|
rtems_user_env_t *tmp = rtems_current_user_env;
|
|
sc = rtems_task_variable_delete(RTEMS_SELF,(void*)&rtems_current_user_env);
|
|
if (sc != RTEMS_SUCCESSFUL) return sc;
|
|
free_user_env(tmp);
|
|
};
|
|
|
|
/* AT THIS POINT, rtems_current_user_env is DANGLING */
|
|
|
|
sc = rtems_task_variable_get(task_id,(void*)&rtems_current_user_env,
|
|
(void*)&shared_user_env );
|
|
if (sc != RTEMS_SUCCESSFUL)
|
|
goto bailout;
|
|
|
|
sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free_user_env);
|
|
if (sc != RTEMS_SUCCESSFUL)
|
|
goto bailout;
|
|
|
|
/* the current_user_env is the same pointer that remote env */
|
|
rtems_current_user_env = shared_user_env;
|
|
|
|
/* increase the reference count */
|
|
#ifdef HAVE_USERENV_REFCNT
|
|
rtems_current_user_env->refcnt++;
|
|
#endif
|
|
|
|
return RTEMS_SUCCESSFUL;
|
|
|
|
bailout:
|
|
/* fallback to the global env */
|
|
rtems_current_user_env = &rtems_global_user_env;
|
|
return sc;
|
|
}
|
|
#endif
|