2010-05-31 Chris Johns <chrisj@rtems.org>

* 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.
This commit is contained in:
Chris Johns
2010-05-31 13:56:37 +00:00
parent eea48e2f82
commit 29e92b090c
38 changed files with 1125 additions and 901 deletions

View File

@@ -50,22 +50,6 @@ extern int rtems_deviceio_errno(rtems_status_code code);
extern uint32_t rtems_device_table_size;
/**
* The following defines the device-only filesystem operating
* handlers.
*/
extern rtems_filesystem_operations_table devFS_ops;
/**
* The following defines the device-only filesystem operating
* handlers.
*/
extern rtems_filesystem_file_handlers_r devFS_file_handlers;
/**
* This handler maps open operation to rtems_io_open.
* @param iop This is the RTEMS's internal representation of file.
@@ -257,14 +241,16 @@ extern int devFS_mknod(
* initializing it to a known state, and set device file operation
* handlers. After this, the device-only filesytem is ready for use
*
* @param temp_mt_entry
* @param mt_entry The filesystem mount table entry.
* @param data Filesystem specific data.
* @retval upon success, this routine returns 0; otherwise it returns
* -1 and errno is set to proper value. The only error is when malloc
* failed, and errno is set to NOMEM.
*/
extern int devFS_initialize(
rtems_filesystem_mount_table_entry_t *temp_mt_entry
rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data
);

View File

@@ -15,6 +15,20 @@
#include <assert.h>
#include "devfs.h"
/**
* The following defines the device-only filesystem operating
* handlers.
*/
extern rtems_filesystem_operations_table devFS_ops;
/**
* The following defines the device-only filesystem operating
* handlers.
*/
extern rtems_filesystem_file_handlers_r devFS_file_handlers;
int devFS_evaluate_path(
const char *pathname,
size_t pathnamelen,

View File

@@ -59,7 +59,8 @@ rtems_filesystem_file_handlers_r devFS_file_handlers =
int devFS_initialize(
rtems_filesystem_mount_table_entry_t *temp_mt_entry
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
const void *data
)
{
rtems_device_name_t *device_name_table;

View File

@@ -25,7 +25,8 @@
extern "C" {
#endif
extern rtems_filesystem_operations_table msdos_ops;
int rtems_dosfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data);
#define MSDOS_FMT_FATANY 0
#define MSDOS_FMT_FAT12 1

View File

@@ -223,8 +223,6 @@ typedef enum msdos_token_types_e
#define MSDOS_DPS512_NUM 16
/* Prototypes */
int msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
int msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
int msdos_eval_path(

View File

@@ -16,6 +16,7 @@
#endif
#include <rtems/libio_.h>
#include "dosfs.h"
#include "msdos.h"
const rtems_filesystem_operations_table msdos_ops = {
@@ -28,7 +29,7 @@ const rtems_filesystem_operations_table msdos_ops = {
.chown_h = NULL,
.freenod_h = msdos_free_node_info,
.mount_h = NULL,
.fsmount_me_h = msdos_initialize,
.fsmount_me_h = rtems_dosfs_initialize,
.unmount_h = NULL,
.fsunmount_me_h = msdos_shut_down,
.utime_h = NULL,
@@ -50,11 +51,12 @@ const rtems_filesystem_operations_table msdos_ops = {
* RC_OK on success, or -1 if error occured (errno set apropriately).
*
*/
int msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry)
int rtems_dosfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data)
{
int rc;
rc = msdos_initialize_support(temp_mt_entry,
rc = msdos_initialize_support(mt_entry,
&msdos_ops,
&msdos_file_handlers,
&msdos_dir_handlers);

View File

@@ -255,11 +255,13 @@ extern const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS;
*/
extern int IMFS_initialize(
rtems_filesystem_mount_table_entry_t *mt_entry
rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data
);
extern int miniIMFS_initialize(
rtems_filesystem_mount_table_entry_t *mt_entry
rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data
);
extern int IMFS_initialize_support(

View File

@@ -490,7 +490,7 @@ int IMFS_eval_path(
size_t pathnamelen, /* IN */
int flags, /* IN */
rtems_filesystem_location_info_t *pathloc /* IN/OUT */
)
)
{
int i = 0;
int len;
@@ -531,40 +531,40 @@ int IMFS_eval_path(
if ( type != IMFS_NO_MORE_PATH )
if ( node->type == IMFS_DIRECTORY )
if ( !IMFS_evaluate_permission( pathloc, RTEMS_LIBIO_PERMS_SEARCH ) )
rtems_set_errno_and_return_minus_one( EACCES );
rtems_set_errno_and_return_minus_one( EACCES );
node = pathloc->node_access;
switch( type ) {
case IMFS_UP_DIR:
/*
* Am I at the root of all filesystems? (chroot'ed?)
*/
/*
* Am I at the root of all filesystems? (chroot'ed?)
*/
if ( pathloc->node_access == rtems_filesystem_root.node_access )
break; /* Throw out the .. in this case */
if ( pathloc->node_access == rtems_filesystem_root.node_access )
break; /* Throw out the .. in this case */
/*
* Am I at the root of this mounted filesystem?
*/
/*
* Am I at the root of this mounted filesystem?
*/
if (pathloc->node_access ==
pathloc->mt_entry->mt_fs_root.node_access) {
/*
* Am I at the root of all filesystems?
*/
* Am I at the root of all filesystems?
*/
if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
break; /* Throw out the .. in this case */
} else {
} else {
newloc = pathloc->mt_entry->mt_point_node;
*pathloc = newloc;
return (*pathloc->ops->evalpath_h)(&(pathname[i-len]),
pathnamelen+len,
flags,pathloc);
}
} else {
}
} else {
if ( !node->Parent )
rtems_set_errno_and_return_minus_one( ENOENT );
@@ -572,17 +572,17 @@ int IMFS_eval_path(
node = node->Parent;
pathloc->node_access = node;
}
}
pathloc->node_access = node;
break;
case IMFS_NAME:
/*
* If we are at a link follow it.
*/
/*
* If we are at a link follow it.
*/
if ( node->type == IMFS_HARD_LINK ) {
if ( node->type == IMFS_HARD_LINK ) {
IMFS_evaluate_hard_link( pathloc, 0 );
@@ -590,26 +590,26 @@ int IMFS_eval_path(
if ( !node )
rtems_set_errno_and_return_minus_one( ENOTDIR );
} else if ( node->type == IMFS_SYM_LINK ) {
} else if ( node->type == IMFS_SYM_LINK ) {
result = IMFS_evaluate_sym_link( pathloc, 0 );
node = pathloc->node_access;
if ( result == -1 )
return -1;
}
}
/*
* Only a directory can be decended into.
*/
/*
* Only a directory can be decended into.
*/
if ( node->type != IMFS_DIRECTORY )
if ( node->type != IMFS_DIRECTORY )
rtems_set_errno_and_return_minus_one( ENOTDIR );
/*
* If we are at a node that is a mount point. Set loc to the
* new fs root node and let them finish evaluating the path.
*/
/*
* If we are at a node that is a mount point. Set loc to the
* new fs root node and let them finish evaluating the path.
*/
if ( node->info.directory.mt_fs != NULL ) {
newloc = node->info.directory.mt_fs->mt_fs_root;
@@ -617,19 +617,19 @@ int IMFS_eval_path(
return (*pathloc->ops->evalpath_h)( &pathname[i-len],
pathnamelen+len,
flags, pathloc );
}
}
/*
* Otherwise find the token name in the present location.
*/
/*
* Otherwise find the token name in the present location.
*/
node = IMFS_find_match_in_dir( node, token );
if ( !node )
rtems_set_errno_and_return_minus_one( ENOENT );
/*
* Set the node access to the point we have found.
*/
/*
* Set the node access to the point we have found.
*/
pathloc->node_access = node;
break;

View File

@@ -59,7 +59,8 @@ const rtems_filesystem_operations_table IMFS_ops = {
*/
int IMFS_initialize(
rtems_filesystem_mount_table_entry_t *temp_mt_entry
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
const void *data
)
{
return IMFS_initialize_support(

View File

@@ -59,7 +59,8 @@ const rtems_filesystem_operations_table miniIMFS_ops = {
*/
int miniIMFS_initialize(
rtems_filesystem_mount_table_entry_t *temp_mt_entry
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
const void *data
)
{
return IMFS_initialize_support(

View File

@@ -70,6 +70,10 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef __cplusplus
extern "C" {
#endif
/* RPCIO driver interface.
* If you need RPCIO for other purposes than NFS
* you may want to include <rpcio.h>
@@ -82,7 +86,9 @@
*/
extern rtems_task_priority rpciodPriority;
/* Initialize the driver
/* Initialize the driver.
*
* Note, called in nfsfs initialise when mount is called.
*
* RETURNS: 0 on success, -1 on failure
*/
@@ -103,6 +109,8 @@ rpcUdpCleanup(void);
* NOTE: The RPCIO driver must have been initialized prior to
* calling this.
*
* Note, called in nfsfs initialise when mount is called with defaults.
*
* ARGS: depth of the small and big
* transaction pools, i.e. how
* many transactions (buffers)
@@ -131,22 +139,12 @@ nfsCleanup(void);
int
nfsMountsShow(FILE *f);
/* convenience wrapper
*
* NOTE: this routine calls NON-REENTRANT
* gethostbyname() if the host is
* not in 'dot' notation.
/*
* Filesystem mount table mount handler. Do not call, use the mount call.
*/
int
nfsMount(char *uidhost, char *path, char *mntpoint);
/* Alternatively, a pointer to the filesystem operations
* table can be supplied to the native RTEMS (NON-POSIX!)
* 'mount()' call.
* Supply a "<host.in.ip.dot.notation>:<path>" string
* for 'device' argument to 'mount()'.
*/
extern struct _rtems_filesystem_operations_table nfs_fs_ops;
int
rtems_nfsfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data);
/* A utility routine to find the path leading to a
* rtems_filesystem_location_info_t node.
@@ -174,4 +172,9 @@ nfsSetTimeout(uint32_t timeout_ms);
/* Read current timeout (in milliseconds) */
uint32_t
nfsGetTimeout(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -4,6 +4,8 @@
/* Author: Till Straumann <strauman@slac.stanford.edu> 2002 */
/* Hacked on by others. */
/*
* Authorship
* ----------
@@ -1193,8 +1195,7 @@ updateAttr(NfsNode node, int force)
}
/*
* IP address helper. Note that we avoid
* gethostbyname() since it's not reentrant.
* IP address helper.
*
* initialize a sockaddr_in from a
* [<uid>'.'<gid>'@']<host>':'<path>" string and let
@@ -1211,7 +1212,8 @@ buildIpAddr(u_long *puid, u_long *pgid,
char **pHost, struct sockaddr_in *psa,
char **pPath)
{
char host[30];
struct hostent *h;
char host[64];
char *chpt = *pPath;
char *path;
int len;
@@ -1238,7 +1240,7 @@ int len;
/* split the device name which is in the form
*
* <host_ip> ':' <path>
* <host> ':' <path>
*
* into its components using a local buffer
*/
@@ -1254,11 +1256,19 @@ int len;
strncpy(host, chpt, len);
host[len]=0;
if ( ! inet_pton(AF_INET, host, &psa->sin_addr) ) {
errno = ENXIO;
/* BEGIN OF NON-THREAD SAFE REGION */
h = gethostbyname(host);
if ( !h ) {
errno = EINVAL;
return -1;
}
memcpy(&psa->sin_addr, h->h_addr, sizeof (struct in_addr));
/* END OF NON-THREAD SAFE REGION */
psa->sin_family = AF_INET;
psa->sin_port = 0;
*pPath = path;
@@ -1898,9 +1908,9 @@ struct rtems_filesystem_mount_table_entry_tt {
#endif
/* This op is called as the last step of mounting this FS */
STATIC int nfs_fsmount_me(
rtems_filesystem_mount_table_entry_t *mt_entry
int rtems_nfsfs_initialize(
rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data
)
{
char *host;
@@ -1917,11 +1927,20 @@ RpcUdpServer nfsServer = 0;
int e = -1;
char *path = mt_entry->dev;
if (rpcUdpInit () < 0) {
fprintf (stderr, "error: initialising RPC\n");
return -1;
}
nfsInit(0, 0);
#if 0
printf("Trying to mount %s on %s\n",path,mntpoint);
#endif
if ( buildIpAddr(&uid, &gid, &host, &saddr, &path) )
return -1;
#ifdef NFS_V2_PORT
/* if the portmapper fails, retry a fixed port */
for (retry = 1, saddr.sin_port = 0, stat = RPC_FAILED;
@@ -2460,7 +2479,7 @@ struct _rtems_filesystem_operations_table nfs_fs_ops = {
nfs_chown, /* OPTIONAL; may be NULL */
nfs_freenode, /* OPTIONAL; may be NULL; (release node_access) */
nfs_mount, /* OPTIONAL; may be NULL */
nfs_fsmount_me, /* OPTIONAL; may be NULL -- but this makes NO SENSE */
rtems_nfsfs_initialize, /* OPTIONAL; may be NULL -- not used anymore */
nfs_unmount, /* OPTIONAL; may be NULL */
nfs_fsunmount_me, /* OPTIONAL; may be NULL */
nfs_utime, /* OPTIONAL; may be NULL */
@@ -3228,6 +3247,8 @@ Nfs nfs;
return 0;
}
#if 0
CCJ_REMOVE_MOUNT
/* convenience wrapper
*
* NOTE: this routine calls NON-REENTRANT
@@ -3237,7 +3258,6 @@ Nfs nfs;
int
nfsMount(char *uidhost, char *path, char *mntpoint)
{
rtems_filesystem_mount_table_entry_t *mtab;
struct stat st;
int devl;
char *host;
@@ -3310,11 +3330,11 @@ char *dev = 0;
printf("Trying to mount %s on %s\n",dev,mntpoint);
if (mount(&mtab,
&nfs_fs_ops,
RTEMS_FILESYSTEM_READ_WRITE,
dev,
mntpoint)) {
if (mount(dev,
mntpoint,
"nfs",
RTEMS_FILESYSTEM_READ_WRITE,
NULL)) {
perror("nfsMount - mount");
goto cleanup;
}
@@ -3325,6 +3345,7 @@ cleanup:
free(dev);
return rval;
}
#endif
/* HERE COMES A REALLY UGLY HACK */

View File

@@ -120,7 +120,7 @@ rtems_rfs_rtems_eval_path (const char* path,
node_len = 0;
while (!rtems_filesystem_is_separator (*path) &&
(*path != '\0') && pathlen &&
(node_len + 1 < rtems_rfs_fs_max_name (fs)))
((node_len + 1) < rtems_rfs_fs_max_name (fs)))
{
path++;
pathlen--;
@@ -1214,7 +1214,8 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_link_handlers =
* Forward decl for the ops table.
*/
int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry);
int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data);
int rtems_rfs_rtems_shutdown (rtems_filesystem_mount_table_entry_t *mt_entry);
/**
@@ -1247,7 +1248,8 @@ const rtems_filesystem_operations_table rtems_rfs_ops =
*/
int
rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t* mt_entry)
rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t* mt_entry,
const void* data)
{
rtems_rfs_rtems_private* rtems;
rtems_rfs_file_system* fs;

View File

@@ -22,14 +22,9 @@
#include <rtems.h>
#include <rtems/fs.h>
/**
* File ops table for the RFS file system.
*/
const rtems_filesystem_operations_table rtems_rfs_ops;
/**
* Initialise the RFS File system.
*/
int rtems_rfs_initialise (rtems_filesystem_mount_table_entry_t *mt_entry);
int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry);
#endif