forked from Imagelibrary/rtems
2001-01-25 Fernando Ruiz <fernando.ruiz@ctv.es>
* Alternate email is correo@fernando-ruiz.com * libc/privateenv.c: New file. * include/rtems/libio_.h, libc/Makefile.am, libc/base_fs.c, libc/unmount.c: Moved default umask, current working directory, root, and links followed count into a structure "user environment" that can then be treated as a unit. This enable giving unique copies of these to individual threads or collection of threads.
This commit is contained in:
@@ -64,12 +64,6 @@ extern rtems_libio_t *rtems_libio_iops;
|
||||
extern rtems_libio_t *rtems_libio_last_iop;
|
||||
extern rtems_libio_t *rtems_libio_iop_freelist;
|
||||
|
||||
/*
|
||||
* Default mode for all files.
|
||||
*/
|
||||
|
||||
extern mode_t rtems_filesystem_umask;
|
||||
|
||||
/*
|
||||
* set_errno_and_return_minus_one
|
||||
*
|
||||
@@ -214,10 +208,27 @@ extern mode_t rtems_filesystem_umask;
|
||||
/*
|
||||
* External structures
|
||||
*/
|
||||
typedef struct {
|
||||
rtems_filesystem_location_info_t current_directory;
|
||||
rtems_filesystem_location_info_t root_directory;
|
||||
/* Default mode for all files. */
|
||||
mode_t umask;
|
||||
nlink_t link_counts;
|
||||
} rtems_user_env_t;
|
||||
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_root;
|
||||
extern nlink_t rtems_filesystem_link_counts;
|
||||
extern rtems_user_env_t * rtems_current_user_env;
|
||||
extern rtems_user_env_t rtems_global_user_env;
|
||||
|
||||
#define rtems_filesystem_current (rtems_current_user_env->current_directory)
|
||||
#define rtems_filesystem_root (rtems_current_user_env->root_directory)
|
||||
#define rtems_filesystem_link_counts (rtems_current_user_env->link_counts)
|
||||
#define rtems_filesystem_umask (rtems_current_user_env->umask)
|
||||
|
||||
/*
|
||||
* Instantiate a private copy of the per user information for the calling task.
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_libio_set_private_env(void);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -64,12 +64,6 @@ extern rtems_libio_t *rtems_libio_iops;
|
||||
extern rtems_libio_t *rtems_libio_last_iop;
|
||||
extern rtems_libio_t *rtems_libio_iop_freelist;
|
||||
|
||||
/*
|
||||
* Default mode for all files.
|
||||
*/
|
||||
|
||||
extern mode_t rtems_filesystem_umask;
|
||||
|
||||
/*
|
||||
* set_errno_and_return_minus_one
|
||||
*
|
||||
@@ -214,10 +208,27 @@ extern mode_t rtems_filesystem_umask;
|
||||
/*
|
||||
* External structures
|
||||
*/
|
||||
typedef struct {
|
||||
rtems_filesystem_location_info_t current_directory;
|
||||
rtems_filesystem_location_info_t root_directory;
|
||||
/* Default mode for all files. */
|
||||
mode_t umask;
|
||||
nlink_t link_counts;
|
||||
} rtems_user_env_t;
|
||||
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_root;
|
||||
extern nlink_t rtems_filesystem_link_counts;
|
||||
extern rtems_user_env_t * rtems_current_user_env;
|
||||
extern rtems_user_env_t rtems_global_user_env;
|
||||
|
||||
#define rtems_filesystem_current (rtems_current_user_env->current_directory)
|
||||
#define rtems_filesystem_root (rtems_current_user_env->root_directory)
|
||||
#define rtems_filesystem_link_counts (rtems_current_user_env->link_counts)
|
||||
#define rtems_filesystem_umask (rtems_current_user_env->umask)
|
||||
|
||||
/*
|
||||
* Instantiate a private copy of the per user information for the calling task.
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_libio_set_private_env(void);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -12,7 +12,7 @@ ERROR_C_FILES = error.c
|
||||
ASSOCIATION_C_FILES = assoc.c assocnamebad.c
|
||||
|
||||
BASE_FS_C_FILES = base_fs.c mount.c unmount.c libio.c \
|
||||
libio_sockets.c eval.c fs_null_handlers.c
|
||||
libio_sockets.c eval.c fs_null_handlers.c privateenv.c
|
||||
|
||||
TERMIOS_C_FILES = cfgetispeed.c cfgetospeed.c cfsetispeed.c cfsetospeed.c \
|
||||
tcgetattr.c tcsetattr.c tcdrain.c tcflow.c tcflush.c tcgetprgrp.c \
|
||||
|
||||
@@ -23,15 +23,13 @@
|
||||
* Global information for the base file system.
|
||||
*/
|
||||
|
||||
rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
rtems_filesystem_location_info_t rtems_filesystem_root;
|
||||
nlink_t rtems_filesystem_link_counts;
|
||||
rtems_user_env_t rtems_global_user_env;
|
||||
rtems_user_env_t * rtems_current_user_env = &rtems_global_user_env;
|
||||
|
||||
/*
|
||||
* Default mode for created files.
|
||||
*/
|
||||
|
||||
mode_t rtems_filesystem_umask;
|
||||
|
||||
/*
|
||||
* rtems_filesystem_initialize
|
||||
|
||||
37
c/src/exec/libcsupport/src/privateenv.c
Normal file
37
c/src/exec/libcsupport/src/privateenv.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Instantatiate 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.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
rtems_status_code rtems_libio_set_private_env(void) {
|
||||
rtems_status_code sc;
|
||||
|
||||
sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
return sc;
|
||||
|
||||
rtems_current_user_env = malloc(sizeof(rtems_user_env_t));
|
||||
if (!rtems_current_user_env)
|
||||
return RTEMS_NO_MEMORY;
|
||||
|
||||
*rtems_current_user_env = rtems_global_user_env;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
@@ -37,7 +37,6 @@
|
||||
*/
|
||||
|
||||
extern Chain_Control rtems_filesystem_mount_table_control;
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
|
||||
int search_mt_for_mount_point(
|
||||
rtems_filesystem_location_info_t *location_of_mount_point
|
||||
|
||||
@@ -64,12 +64,6 @@ extern rtems_libio_t *rtems_libio_iops;
|
||||
extern rtems_libio_t *rtems_libio_last_iop;
|
||||
extern rtems_libio_t *rtems_libio_iop_freelist;
|
||||
|
||||
/*
|
||||
* Default mode for all files.
|
||||
*/
|
||||
|
||||
extern mode_t rtems_filesystem_umask;
|
||||
|
||||
/*
|
||||
* set_errno_and_return_minus_one
|
||||
*
|
||||
@@ -214,10 +208,27 @@ extern mode_t rtems_filesystem_umask;
|
||||
/*
|
||||
* External structures
|
||||
*/
|
||||
typedef struct {
|
||||
rtems_filesystem_location_info_t current_directory;
|
||||
rtems_filesystem_location_info_t root_directory;
|
||||
/* Default mode for all files. */
|
||||
mode_t umask;
|
||||
nlink_t link_counts;
|
||||
} rtems_user_env_t;
|
||||
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_root;
|
||||
extern nlink_t rtems_filesystem_link_counts;
|
||||
extern rtems_user_env_t * rtems_current_user_env;
|
||||
extern rtems_user_env_t rtems_global_user_env;
|
||||
|
||||
#define rtems_filesystem_current (rtems_current_user_env->current_directory)
|
||||
#define rtems_filesystem_root (rtems_current_user_env->root_directory)
|
||||
#define rtems_filesystem_link_counts (rtems_current_user_env->link_counts)
|
||||
#define rtems_filesystem_umask (rtems_current_user_env->umask)
|
||||
|
||||
/*
|
||||
* Instantiate a private copy of the per user information for the calling task.
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_libio_set_private_env(void);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -12,7 +12,7 @@ ERROR_C_FILES = error.c
|
||||
ASSOCIATION_C_FILES = assoc.c assocnamebad.c
|
||||
|
||||
BASE_FS_C_FILES = base_fs.c mount.c unmount.c libio.c \
|
||||
libio_sockets.c eval.c fs_null_handlers.c
|
||||
libio_sockets.c eval.c fs_null_handlers.c privateenv.c
|
||||
|
||||
TERMIOS_C_FILES = cfgetispeed.c cfgetospeed.c cfsetispeed.c cfsetospeed.c \
|
||||
tcgetattr.c tcsetattr.c tcdrain.c tcflow.c tcflush.c tcgetprgrp.c \
|
||||
|
||||
@@ -23,15 +23,13 @@
|
||||
* Global information for the base file system.
|
||||
*/
|
||||
|
||||
rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
rtems_filesystem_location_info_t rtems_filesystem_root;
|
||||
nlink_t rtems_filesystem_link_counts;
|
||||
rtems_user_env_t rtems_global_user_env;
|
||||
rtems_user_env_t * rtems_current_user_env = &rtems_global_user_env;
|
||||
|
||||
/*
|
||||
* Default mode for created files.
|
||||
*/
|
||||
|
||||
mode_t rtems_filesystem_umask;
|
||||
|
||||
/*
|
||||
* rtems_filesystem_initialize
|
||||
|
||||
37
c/src/lib/libc/privateenv.c
Normal file
37
c/src/lib/libc/privateenv.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Instantatiate 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.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
rtems_status_code rtems_libio_set_private_env(void) {
|
||||
rtems_status_code sc;
|
||||
|
||||
sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
return sc;
|
||||
|
||||
rtems_current_user_env = malloc(sizeof(rtems_user_env_t));
|
||||
if (!rtems_current_user_env)
|
||||
return RTEMS_NO_MEMORY;
|
||||
|
||||
*rtems_current_user_env = rtems_global_user_env;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
@@ -37,7 +37,6 @@
|
||||
*/
|
||||
|
||||
extern Chain_Control rtems_filesystem_mount_table_control;
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
|
||||
int search_mt_for_mount_point(
|
||||
rtems_filesystem_location_info_t *location_of_mount_point
|
||||
|
||||
@@ -64,12 +64,6 @@ extern rtems_libio_t *rtems_libio_iops;
|
||||
extern rtems_libio_t *rtems_libio_last_iop;
|
||||
extern rtems_libio_t *rtems_libio_iop_freelist;
|
||||
|
||||
/*
|
||||
* Default mode for all files.
|
||||
*/
|
||||
|
||||
extern mode_t rtems_filesystem_umask;
|
||||
|
||||
/*
|
||||
* set_errno_and_return_minus_one
|
||||
*
|
||||
@@ -214,10 +208,27 @@ extern mode_t rtems_filesystem_umask;
|
||||
/*
|
||||
* External structures
|
||||
*/
|
||||
typedef struct {
|
||||
rtems_filesystem_location_info_t current_directory;
|
||||
rtems_filesystem_location_info_t root_directory;
|
||||
/* Default mode for all files. */
|
||||
mode_t umask;
|
||||
nlink_t link_counts;
|
||||
} rtems_user_env_t;
|
||||
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_root;
|
||||
extern nlink_t rtems_filesystem_link_counts;
|
||||
extern rtems_user_env_t * rtems_current_user_env;
|
||||
extern rtems_user_env_t rtems_global_user_env;
|
||||
|
||||
#define rtems_filesystem_current (rtems_current_user_env->current_directory)
|
||||
#define rtems_filesystem_root (rtems_current_user_env->root_directory)
|
||||
#define rtems_filesystem_link_counts (rtems_current_user_env->link_counts)
|
||||
#define rtems_filesystem_umask (rtems_current_user_env->umask)
|
||||
|
||||
/*
|
||||
* Instantiate a private copy of the per user information for the calling task.
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_libio_set_private_env(void);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -64,12 +64,6 @@ extern rtems_libio_t *rtems_libio_iops;
|
||||
extern rtems_libio_t *rtems_libio_last_iop;
|
||||
extern rtems_libio_t *rtems_libio_iop_freelist;
|
||||
|
||||
/*
|
||||
* Default mode for all files.
|
||||
*/
|
||||
|
||||
extern mode_t rtems_filesystem_umask;
|
||||
|
||||
/*
|
||||
* set_errno_and_return_minus_one
|
||||
*
|
||||
@@ -214,10 +208,27 @@ extern mode_t rtems_filesystem_umask;
|
||||
/*
|
||||
* External structures
|
||||
*/
|
||||
typedef struct {
|
||||
rtems_filesystem_location_info_t current_directory;
|
||||
rtems_filesystem_location_info_t root_directory;
|
||||
/* Default mode for all files. */
|
||||
mode_t umask;
|
||||
nlink_t link_counts;
|
||||
} rtems_user_env_t;
|
||||
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_root;
|
||||
extern nlink_t rtems_filesystem_link_counts;
|
||||
extern rtems_user_env_t * rtems_current_user_env;
|
||||
extern rtems_user_env_t rtems_global_user_env;
|
||||
|
||||
#define rtems_filesystem_current (rtems_current_user_env->current_directory)
|
||||
#define rtems_filesystem_root (rtems_current_user_env->root_directory)
|
||||
#define rtems_filesystem_link_counts (rtems_current_user_env->link_counts)
|
||||
#define rtems_filesystem_umask (rtems_current_user_env->umask)
|
||||
|
||||
/*
|
||||
* Instantiate a private copy of the per user information for the calling task.
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_libio_set_private_env(void);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,15 +23,13 @@
|
||||
* Global information for the base file system.
|
||||
*/
|
||||
|
||||
rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
rtems_filesystem_location_info_t rtems_filesystem_root;
|
||||
nlink_t rtems_filesystem_link_counts;
|
||||
rtems_user_env_t rtems_global_user_env;
|
||||
rtems_user_env_t * rtems_current_user_env = &rtems_global_user_env;
|
||||
|
||||
/*
|
||||
* Default mode for created files.
|
||||
*/
|
||||
|
||||
mode_t rtems_filesystem_umask;
|
||||
|
||||
/*
|
||||
* rtems_filesystem_initialize
|
||||
|
||||
37
cpukit/libcsupport/src/privateenv.c
Normal file
37
cpukit/libcsupport/src/privateenv.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Instantatiate 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.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
rtems_status_code rtems_libio_set_private_env(void) {
|
||||
rtems_status_code sc;
|
||||
|
||||
sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
return sc;
|
||||
|
||||
rtems_current_user_env = malloc(sizeof(rtems_user_env_t));
|
||||
if (!rtems_current_user_env)
|
||||
return RTEMS_NO_MEMORY;
|
||||
|
||||
*rtems_current_user_env = rtems_global_user_env;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
@@ -37,7 +37,6 @@
|
||||
*/
|
||||
|
||||
extern Chain_Control rtems_filesystem_mount_table_control;
|
||||
extern rtems_filesystem_location_info_t rtems_filesystem_current;
|
||||
|
||||
int search_mt_for_mount_point(
|
||||
rtems_filesystem_location_info_t *location_of_mount_point
|
||||
|
||||
Reference in New Issue
Block a user