Changeset 29e92b0 in rtems


Ignore:
Timestamp:
May 31, 2010, 1:56:37 PM (9 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
55d883d
Parents:
eea48e2f
Message:

2010-05-31 Chris Johns <chrisj@…>

  • 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.
Location:
cpukit
Files:
4 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    reea48e2f r29e92b0  
     12010-05-31      Chris Johns <chrisj@rtems.org>
     2
     3        * libcsupport/Makefile.am: Add mount-mgr.c.
     4        * libcsupport/src/mount-mgr.c: New.
     5        * include/rtems/fs.h: Added rtems_filesystem_location_mount.
     6        * libcsupport/include/rtems/libio.h, libcsupport/src/mount.c: New
     7        mount interface. It is similar to Linux.
     8        * libcsupport/include/rtems/libio_.h: Remove the
     9        init_fs_mount_table call.
     10        * libcsupport/src/base_fs.c: Remove init_fs_mount_table_call. Use
     11        the new mount call. Remove setting the root node in the global
     12        pathloc. Mount does this now.
     13        * libcsupport/src/privateenv.c: Remove the hack to set the root
     14        mount table entry in the environment.
     15        * libcsupport/src/unmount.cL Free the target string.
     16        * libblock/src/bdpart-mount.c: New mount API.
     17       
     18        * libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_init.c,
     19        libfs/src/dosfs/dosfs.h, libfs/src/dosfs/msdos.h,
     20        libfs/src/dosfs/msdos_init.c, libfs/src/imfs/imfs.h,
     21        libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_init.c,
     22        libfs/src/imfs/miniimfs_init.c,
     23        libfs/src/nfsclient/src/librtemsNfs.h,
     24        libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs.h,
     25        libnetworking/lib/ftpfs.c, libnetworking/rtems/ftpfs.h,
     26        libnetworking/rtems/tftp.h: New mount_h API.
     27       
     28        * libfs/src/devfs/devfs_eval.c: Local include of extern ops.
     29        * libfs/src/nfsclient/src/nfs.c: New mount API. Removed the mount
     30        me call and fixed the initialisation to happen when mounting.
     31       
     32        * libmisc/Makefile.am, libmisc/shell/shellconfig.h: Remove mount
     33        filesystem files.
     34
     35        * libmisc/fsmount/fsmount.c, libmisc/fsmount/fsmount.h: Updated to
     36        the new mount table values.
     37       
     38        * libmisc/shell/main_mount_ftp.c,
     39        libmisc/shell/main_mount_msdos.c, libmisc/shell/main_mount_rfs.c,
     40        libmisc/shell/main_mount_tftp.c: Removed.
     41
     42        * libmisc/shell/main_mount.c: Use the new mount API. Also access
     43        the file system table for the file system types.
     44
     45        * libnetworking/lib/tftpDriver.c: Updated to the new mount
     46        API. Fixed to allow mounting from any mount point. Also can now
     47        have more than file system mounted.
     48       
     49        * sapi/include/confdefs.h: Add file system configuration support.
     50
    1512010-05-29      Ralf Corsépius <ralf.corsepius@rtems.org>
    252
  • cpukit/include/rtems/fs.h

    reea48e2f r29e92b0  
    5353};
    5454
     55/*
     56 * Return the mount table entry for a path location.
     57 */
     58#define rtems_filesystem_location_mount(_pl) ((_pl)->mt_entry)
     59
    5560#ifdef __cplusplus
    5661}
  • cpukit/libblock/src/bdpart-mount.c

    reea48e2f r29e92b0  
    3030#include <rtems.h>
    3131#include <rtems/bdpart.h>
    32 #include <rtems/dosfs.h>
    3332#include <rtems/fsmount.h>
    3433
     
    10099    /* Mount */
    101100    rv = mount(
    102       NULL,
    103       &msdos_ops,
     101      logical_disk_name,
     102      mount_point,
     103      "msdos",
    104104      0,
    105       logical_disk_name,
    106       mount_point
     105      NULL
    107106    );
    108107    if (rv != 0) {
  • cpukit/libcsupport/Makefile.am

    reea48e2f r29e92b0  
    4545
    4646BASE_FS_C_FILES = src/base_fs.c src/mount.c src/unmount.c src/libio.c \
    47     src/libio_init.c \
     47    src/mount-mgr.c src/libio_init.c \
    4848    src/libio_sockets.c src/eval.c src/fs_null_handlers.c src/privateenv.c \
    4949    src/open_dev_console.c src/__usrenv.c
  • cpukit/libcsupport/include/rtems/libio.h

    reea48e2f r29e92b0  
    210210
    211211typedef int (* rtems_filesystem_mount_t ) (
    212    rtems_filesystem_mount_table_entry_t *mt_entry     /* in */
     212   rtems_filesystem_mount_table_entry_t *mt_entry     /* IN */
    213213);
    214214
    215215typedef int (* rtems_filesystem_fsmount_me_t )(
    216    rtems_filesystem_mount_table_entry_t *mt_entry
     216  rtems_filesystem_mount_table_entry_t *mt_entry,     /* IN */
     217  const void                           *data          /* IN */
    217218);
    218219
    219220typedef int (* rtems_filesystem_unmount_t ) (
    220    rtems_filesystem_mount_table_entry_t *mt_entry     /* in */
     221  rtems_filesystem_mount_table_entry_t *mt_entry     /* IN */
    221222);
    222223
    223224typedef int (* rtems_filesystem_fsunmount_me_t ) (
    224    rtems_filesystem_mount_table_entry_t *mt_entry    /* in */
     225   rtems_filesystem_mount_table_entry_t *mt_entry    /* IN */
    225226);
    226227
    227228typedef rtems_filesystem_node_types_t (* rtems_filesystem_node_type_t) (
    228   rtems_filesystem_location_info_t    *pathloc      /* in */
     229  rtems_filesystem_location_info_t    *pathloc      /* IN */
    229230);
    230231
     
    292293};
    293294
     295/*
     296 * File system table used by mount to manage file systems.
     297 */
     298typedef struct _rtems_filesystem_table {
     299  const char                    *type;
     300  rtems_filesystem_fsmount_me_t  mount_h;
     301} rtems_filesystem_table_t;
     302
     303/*
     304 * File system table runtime loaded nodes.
     305 */
     306typedef struct _rtems_filesystem_table_node {
     307  rtems_chain_node         node;
     308  rtems_filesystem_table_t entry;
     309} rtems_filesystem_table_node_t;
     310
     311/*
     312 * Get the first entry in the filesystem table.
     313 */
     314const rtems_filesystem_table_t* rtems_filesystem_table_first( void );
     315
     316/*
     317 * Get the next entry in the file system table.
     318 */
     319const rtems_filesystem_table_t*
     320rtems_filesystem_table_next( rtems_filesystem_table_t *entry );
     321
     322/*
     323 * Get the first entry in the mount table.
     324 */
     325rtems_filesystem_mount_table_entry_t*
     326rtems_filesystem_mounts_first( void );
     327
     328/*
     329 * Get the next entry in the mount table.
     330 */
     331rtems_filesystem_mount_table_entry_t*
     332rtems_filesystem_mounts_next( rtems_filesystem_mount_table_entry_t *entry );
     333
     334/*
     335 * Register a file system.
     336 */
     337int
     338rtems_filesystem_register(
     339  const char                    *type,
     340  rtems_filesystem_fsmount_me_t  mount_h
     341);
     342
     343/*
     344 * Unregister a file system.
     345 */
     346int
     347rtems_filesystem_unregister(
     348  const char *type
     349);
     350
    294351#if 0
    295352/* Now in exec/include/rtems/fs.h */
     
    314371
    315372typedef struct {
    316   int    link_max;
    317   int    max_canon;
    318   int    max_input;
    319   int    name_max;
    320   int    path_max;
    321   int    pipe_buf;
    322   int    posix_async_io;
    323   int    posix_chown_restrictions;
    324   int    posix_no_trunc;
    325   int    posix_prio_io;
    326   int    posix_sync_io;
    327   int    posix_vdisable;
     373  int    link_max;                 /* count */
     374  int    max_canon;                /* max formatted input line size */
     375  int    max_input;                /* max input line size */
     376  int    name_max;                 /* max name length */
     377  int    path_max;                 /* max path */
     378  int    pipe_buf;                 /* pipe buffer size */
     379  int    posix_async_io;           /* async IO supported on fs, 0=no, 1=yes */
     380  int    posix_chown_restrictions; /* can chown: 0=no, 1=yes */
     381  int    posix_no_trunc;           /* error on names > max name, 0=no, 1=yes */
     382  int    posix_prio_io;            /* priority IO, 0=no, 1=yes */
     383  int    posix_sync_io;            /* file can be sync'ed, 0=no, 1=yes */
     384  int    posix_vdisable;           /* special char processing, 0=no, 1=yes */
    328385} rtems_filesystem_limits_and_options_t;
     386
     387/*
     388 * Default pathconf settings. Override in a filesystem.
     389 */
     390extern const rtems_filesystem_limits_and_options_t rtems_filesystem_default_pathconf;
    329391
    330392/*
     
    340402
    341403  rtems_filesystem_limits_and_options_t  pathconf_limits_and_options;
     404
     405  /*
     406   * The target or mount point of the file system.
     407   */
     408  const char                            *target;
     409
     410  /*
     411   * The type of filesystem or the name of the filesystem.
     412   */
     413  const char                            *type;
    342414
    343415  /*
     
    350422  char                                  *dev;
    351423};
     424
     425/**
     426 * The pathconf setting for a file system.
     427 */
     428#define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options)
     429
     430/**
     431 * The type of file system. Its name.
     432 */
     433#define rtems_filesystem_type(_mte) ((_mte)->type)
     434
     435/**
     436 * The mount point of a file system.
     437 */
     438#define rtems_filesystem_mount_point(_mte) ((_mte)->target)
     439
     440/**
     441 * The device entry of a file system.
     442 */
     443#define rtems_filesystem_mount_device(_mte) ((_mte)->dev)
    352444
    353445/*
     
    638730
    639731int mount(
    640   rtems_filesystem_mount_table_entry_t    **mt_entry,
    641   const rtems_filesystem_operations_table  *fs_ops,
    642   rtems_filesystem_options_t                fsoptions,
    643   const char                               *device,
    644   const char                               *mount_point
     732  const char                 *source,
     733  const char                 *target,
     734  const char                 *filesystemtype,
     735  rtems_filesystem_options_t options,
     736  const void                 *data
    645737);
    646738
     
    650742
    651743typedef struct {
    652   const rtems_filesystem_operations_table *fs_ops;
     744  const char                              *type;
    653745  rtems_filesystem_options_t               fsoptions;
    654746  const char                              *device;
  • cpukit/libcsupport/include/rtems/libio_.h

    reea48e2f r29e92b0  
    272272void rtems_filesystem_initialize(void);
    273273
    274 int init_fs_mount_table(void);
    275 
    276274#ifdef __cplusplus
    277275}
  • cpukit/libcsupport/src/base_fs.c

    reea48e2f r29e92b0  
    3737{
    3838  int                                   status;
    39   rtems_filesystem_mount_table_entry_t *entry;
    4039  const rtems_filesystem_mount_table_t *mt;
    4140  rtems_filesystem_location_info_t      loc;
     
    4645
    4746  rtems_filesystem_umask = 022;
    48 
    49 
    50   init_fs_mount_table();
    5147
    5248  /*
     
    5955  mt = &rtems_filesystem_mount_table[0];
    6056
    61   status = mount(
    62      &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point );
     57  status = mount( mt->device, mt->mount_point, mt->type, mt->fsoptions, NULL );
    6358
    6459  if ( status == -1 )
     
    8782   *       Till Straumann, 10/25/2002
    8883   */
    89   rtems_filesystem_root        = entry->mt_fs_root;
    9084  /* Clone the root pathloc */
    9185  rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
  • cpukit/libcsupport/src/mount.c

    reea48e2f r29e92b0  
    3434#include <rtems/libio_.h>
    3535
     36/*
     37 * External defined by confdefs.h or the user.
     38 */
     39extern const rtems_filesystem_table_t configuration_filesystem_table[];
     40
     41/*
     42 * Points to a list of filesystems added at runtime.
     43 */
     44rtems_chain_control *rtems_filesystem_table;
     45
     46/*
     47 * Mount table list.
     48 */
    3649rtems_chain_control rtems_filesystem_mount_table_control;
    37 
    38 /*
    39  *  Prototypes that probably should be somewhere else.
    40  */
    41 
    42 int init_fs_mount_table( void );
    43 static bool Is_node_fs_root(
    44   rtems_filesystem_location_info_t  *loc
    45 );
    46 
    47 
    48 /*
    49  *  XXX
    50  */
    51 
    52 #define FOUND      0
    53 #define NOT_FOUND -1
    54 
    55 /*
    56  *  mount
    57  *
    58  *  This routine will attempt to mount a new file system at the specified
    59  *  mount point. A series of tests will be run to determine if any of the
    60  *  following reasons exist to prevent the mount operation:
    61  *
    62  *      1) The file system type or options are not valid
    63  *      2) No new file system root node is specified
    64  *      3) The selected file system has already been mounted
    65  *      4) The mount point exists with the proper permissions to allow mounting
    66  *      5) The selected mount point already has a file system mounted to it
    67  *
    68  */
    69 
    70 int mount(
    71   rtems_filesystem_mount_table_entry_t    **mt_entry,
    72   const rtems_filesystem_operations_table  *fs_ops,
    73   rtems_filesystem_options_t                options,
    74   const char                               *device,
    75   const char                               *mount_point
    76 )
    77 {
    78   rtems_filesystem_location_info_t      loc;
    79   rtems_filesystem_mount_table_entry_t *temp_mt_entry = NULL;
    80   rtems_filesystem_location_info_t     *loc_to_free = NULL;
    81   size_t size;
    82 
    83 /* XXX add code to check for required operations */
    84 
    85   /*
    86    *  Is there a file system operations table?
    87    */
    88 
    89   if ( fs_ops == NULL ) {
    90     errno = EINVAL;
    91     return -1;
    92   }
    93 
    94   /*
    95    *  Are the file system options valid?
    96    */
    97 
    98   if ( options != RTEMS_FILESYSTEM_READ_ONLY &&
    99        options != RTEMS_FILESYSTEM_READ_WRITE ) {
    100     errno = EINVAL;
    101     return -1;
    102   }
    103 
    104   /* Do they support being mounted at all ? */
    105   if ( !fs_ops->fsmount_me_h ) {
    106     errno = ENOTSUP;
    107     goto cleanup_and_bail;
    108   }
    109 
    110 
    111   /*
    112    * Allocate a mount table entry
    113    */
    114 
    115    size = sizeof(rtems_filesystem_mount_table_entry_t);
    116    if ( device )
    117      size += strlen( device ) + 1;
    118    temp_mt_entry = malloc( size );
    119 
    120    if ( !temp_mt_entry ) {
    121      errno = ENOMEM;
    122      return -1;
    123    }
    124 
    125    temp_mt_entry->mt_fs_root.mt_entry = temp_mt_entry;
    126    temp_mt_entry->options = options;
    127    if ( device ) {
    128      temp_mt_entry->dev =
    129        (char *)temp_mt_entry + sizeof( rtems_filesystem_mount_table_entry_t );
    130      strcpy( temp_mt_entry->dev, device );
    131    } else
    132      temp_mt_entry->dev = 0;
    133 
    134   /*
    135    *  The mount_point should be a directory with read/write/execute
    136    *  permissions in the existing tree.
    137    */
    138 
    139   if ( mount_point ) {
    140 
    141     if ( rtems_filesystem_evaluate_path(
    142            mount_point, strlen( mount_point ), RTEMS_LIBIO_PERMS_RWX, &loc, true ) == -1 )
    143       goto cleanup_and_bail;
    144 
    145     loc_to_free = &loc;
    146 
    147     /*
    148      * Test for node_type_h
    149      */
    150 
    151     if (!loc.ops->node_type_h) {
    152       errno =  ENOTSUP;
    153       goto cleanup_and_bail;
    154     }
    155 
    156     /*
    157      *  Test to see if it is a directory
    158      */
    159 
    160     if ( loc.ops->node_type_h( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
    161       errno = ENOTDIR;
    162       goto cleanup_and_bail;
    163     }
    164 
    165     /*
    166      *  You can only mount one file system onto a single mount point.
    167      */
    168 
    169     if ( Is_node_fs_root(  &loc ) ){
    170       errno = EBUSY;
    171       goto cleanup_and_bail;
    172     }
    173 
    174     /*
    175      *  This must be a good mount point, so move the location information
    176      *  into the allocated mount entry.  Note:  the information that
    177      *  may have been allocated in loc should not be sent to freenode
    178      *  until the system is unmounted.  It may be needed to correctly
    179      *  traverse the tree.
    180      */
    181 
    182     temp_mt_entry->mt_point_node.node_access = loc.node_access;
    183     temp_mt_entry->mt_point_node.handlers = loc.handlers;
    184     temp_mt_entry->mt_point_node.ops = loc.ops;
    185     temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
    186 
    187     /*
    188      *  This link to the parent is only done when we are dealing with system
    189      *  below the base file system
    190      */
    191 
    192     if ( !loc.ops->mount_h ){
    193       errno = ENOTSUP;
    194       goto cleanup_and_bail;
    195     }
    196 
    197     if ( loc.ops->mount_h( temp_mt_entry ) ) {
    198       goto cleanup_and_bail;
    199     }
    200   } else {
    201 
    202     /*
    203      *  This is a mount of the base file system --> The
    204      *  mt_point_node.node_access will be set to null to indicate that this
    205      *  is the root of the entire file system.
    206      */
    207 
    208     temp_mt_entry->mt_fs_root.node_access = NULL;
    209     temp_mt_entry->mt_fs_root.handlers = NULL;
    210     temp_mt_entry->mt_fs_root.ops = NULL;
    211 
    212     temp_mt_entry->mt_point_node.node_access = NULL;
    213     temp_mt_entry->mt_point_node.handlers = NULL;
    214     temp_mt_entry->mt_point_node.ops = NULL;
    215     temp_mt_entry->mt_point_node.mt_entry = NULL;
    216   }
    217 
    218   if ( fs_ops->fsmount_me_h( temp_mt_entry ) ) {
    219         /* try to undo the mount operation */
    220         if ( loc.ops->unmount_h ) {
    221                 loc.ops->unmount_h( temp_mt_entry );
    222     }
    223     goto cleanup_and_bail;
    224   }
    225 
    226   /*
    227    *  Add the mount table entry to the mount table chain
    228    */
    229 
    230   rtems_chain_append( &rtems_filesystem_mount_table_control,
    231                       &temp_mt_entry->Node );
    232 
    233   if ( mt_entry )
    234     *mt_entry = temp_mt_entry;
    235 
    236   return 0;
    237 
    238 cleanup_and_bail:
    239 
    240   free( temp_mt_entry );
    241 
    242   if ( loc_to_free )
    243     rtems_filesystem_freenode( loc_to_free );
    244 
    245   return -1;
    246 }
    247 
    248 
    249 
    250 /*
    251  *  init_fs_mount_table
    252  *
    253  *  This routine will initialize the chain control element that manages the
    254  *  mount table chain.
    255  */
    256 
    257 int init_fs_mount_table(void)
    258 {
    259   rtems_chain_initialize_empty ( &rtems_filesystem_mount_table_control );
    260   return 0;
    261 }
     50bool                rtems_filesystem_mount_table_control_init;
     51
     52/*
     53 * Default pathconfs.
     54 */
     55const rtems_filesystem_limits_and_options_t rtems_filesystem_default_pathconf = {
     56   5,    /* link_max: count */
     57   128,  /* max_canon: max formatted input line size */
     58   7,    /* max_input: max input line size */
     59   255,  /* name_max: max name */
     60   255,  /* path_max: max path */
     61   1024, /* pipe_buf: pipe buffer size */
     62   0,    /* posix_async_io: async IO supported on fs, 0=no, 1=yes */
     63   0 ,   /* posix_chown_restrictions: can chown: 0=no, 1=yes */
     64   1,    /* posix_no_trunc: error on filenames > max name, 0=no, 1=yes */
     65   0,    /* posix_prio_io: priority IO, 0=no, 1=yes */
     66   0,    /* posix_sync_io: file can be sync'ed, 0=no, 1=yes */
     67   0     /* posix_vdisable: special char processing, 0=no, 1=yes */
     68};
    26269
    26370/*
     
    28289   * For each mount table entry
    28390   */
    284 
    285   for ( the_node = rtems_filesystem_mount_table_control.first;
    286         !rtems_chain_is_tail( &rtems_filesystem_mount_table_control, the_node );
    287         the_node = the_node->next ) {
    288      the_mount_entry = (rtems_filesystem_mount_table_entry_t *) the_node;
    289      if ( the_mount_entry->mt_fs_root.node_access  == loc->node_access )
     91  if ( rtems_filesystem_mount_table_control_init ) {
     92    for ( the_node = rtems_chain_first( &rtems_filesystem_mount_table_control );
     93          !rtems_chain_is_tail( &rtems_filesystem_mount_table_control, the_node );
     94          the_node = rtems_chain_next( the_node ) ) {
     95      the_mount_entry = (rtems_filesystem_mount_table_entry_t *) the_node;
     96      if ( the_mount_entry->mt_fs_root.node_access  == loc->node_access )
    29097        return true;
     98    }
    29199  }
    292100  return false;
    293101}
     102
     103/*
     104 *  mount
     105 *
     106 *  This routine will attempt to mount a new file system at the specified
     107 *  mount point. A series of tests will be run to determine if any of the
     108 *  following reasons exist to prevent the mount operation:
     109 *
     110 *      1) The file system type or options are not valid
     111 *      2) No new file system root node is specified
     112 *      3) The selected file system has already been mounted
     113 *      4) The mount point exists with the proper permissions to allow mounting
     114 *      5) The selected mount point already has a file system mounted to it
     115 *
     116 */
     117
     118int mount(
     119  const char                 *source,
     120  const char                 *target,
     121  const char                 *filesystemtype,
     122  rtems_filesystem_options_t options,
     123  const void                 *data
     124          )
     125{
     126  const rtems_filesystem_table_t       *entry;
     127  rtems_filesystem_location_info_t      loc;
     128  rtems_filesystem_mount_table_entry_t *mt_entry = NULL;
     129  rtems_filesystem_location_info_t     *loc_to_free = NULL;
     130  size_t size;
     131
     132  /*
     133   * If mount is ever called we allocate the mount table control structure.
     134   */
     135  if ( !rtems_filesystem_mount_table_control_init ) {
     136    rtems_filesystem_mount_table_control_init = true;
     137    rtems_chain_initialize_empty ( &rtems_filesystem_mount_table_control );
     138  }
     139
     140  /*
     141   *  Are the file system options valid?
     142   */
     143
     144  if ( options != RTEMS_FILESYSTEM_READ_ONLY &&
     145       options != RTEMS_FILESYSTEM_READ_WRITE ) {
     146    errno = EINVAL;
     147    return -1;
     148  }
     149
     150  /*
     151   * Check the type.
     152   */
     153  if (!filesystemtype) {
     154    errno = EINVAL;
     155    return -1;
     156  }
     157
     158  if (strlen(filesystemtype) >= 128) {
     159    errno = EINVAL;
     160    return -1;
     161  }
     162   
     163  /*
     164   * Check the configuration table filesystems then check any runtime added
     165   * file systems.
     166   */
     167  entry = &configuration_filesystem_table[0];
     168  while (entry->type) {
     169    if (strcmp (filesystemtype, entry->type) == 0)
     170      break;
     171    ++entry;
     172  }
     173 
     174  if (!entry->type) {
     175    entry = NULL;
     176    if (rtems_filesystem_table) {
     177      rtems_chain_node *the_node;
     178      for (the_node = rtems_chain_first(rtems_filesystem_table);
     179           !rtems_chain_is_tail(rtems_filesystem_table, the_node);
     180           the_node = rtems_chain_next(the_node)) {
     181        entry = &(((rtems_filesystem_table_node_t*) the_node)->entry);
     182        if (strcmp (filesystemtype, entry->type) == 0)
     183          break;
     184        entry = NULL;
     185      }
     186    }
     187  }
     188
     189  if (!entry)
     190  {
     191    errno = EINVAL;
     192    return -1;
     193  }
     194 
     195  /*
     196   * Allocate a mount table entry
     197   */
     198
     199  size = sizeof(rtems_filesystem_mount_table_entry_t);
     200  if ( source )
     201    size += strlen( source ) + 1;
     202   
     203  mt_entry = malloc( size );
     204  if ( !mt_entry ) {
     205    errno = ENOMEM;
     206    return -1;
     207  }
     208
     209  memset( mt_entry, 0, size );
     210   
     211  mt_entry->mt_fs_root.mt_entry = mt_entry;
     212  mt_entry->type = entry->type;
     213  mt_entry->options = options;
     214  mt_entry->pathconf_limits_and_options = rtems_filesystem_default_pathconf;
     215   
     216  if ( source ) {
     217    mt_entry->dev =
     218      (char *)mt_entry + sizeof( rtems_filesystem_mount_table_entry_t );
     219    strcpy( mt_entry->dev, source );
     220  } else
     221    mt_entry->dev = 0;
     222
     223  /*
     224   *  The mount_point should be a directory with read/write/execute
     225   *  permissions in the existing tree.
     226   */
     227
     228  if ( target ) {
     229
     230    if ( rtems_filesystem_evaluate_path(
     231           target, strlen( target ), RTEMS_LIBIO_PERMS_RWX, &loc, true ) == -1 )
     232      goto cleanup_and_bail;
     233
     234    loc_to_free = &loc;
     235
     236    /*
     237     * Test for node_type_h
     238     */
     239
     240    if (!loc.ops->node_type_h) {
     241      errno =  ENOTSUP;
     242      goto cleanup_and_bail;
     243    }
     244
     245    /*
     246     *  Test to see if it is a directory
     247     */
     248
     249    if ( loc.ops->node_type_h( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
     250      errno = ENOTDIR;
     251      goto cleanup_and_bail;
     252    }
     253
     254    /*
     255     *  You can only mount one file system onto a single mount point.
     256     */
     257
     258    if ( Is_node_fs_root(  &loc ) ){
     259      errno = EBUSY;
     260      goto cleanup_and_bail;
     261    }
     262
     263    /*
     264     *  This must be a good mount point, so move the location information
     265     *  into the allocated mount entry.  Note:  the information that
     266     *  may have been allocated in loc should not be sent to freenode
     267     *  until the system is unmounted.  It may be needed to correctly
     268     *  traverse the tree.
     269     */
     270
     271    mt_entry->mt_point_node.node_access = loc.node_access;
     272    mt_entry->mt_point_node.handlers = loc.handlers;
     273    mt_entry->mt_point_node.ops = loc.ops;
     274    mt_entry->mt_point_node.mt_entry = loc.mt_entry;
     275     
     276    /*
     277     *  This link to the parent is only done when we are dealing with system
     278     *  below the base file system
     279     */
     280
     281    if ( !loc.ops->mount_h ){
     282      errno = ENOTSUP;
     283      goto cleanup_and_bail;
     284    }
     285
     286    if ( loc.ops->mount_h( mt_entry ) ) {
     287      goto cleanup_and_bail;
     288    }
     289
     290    mt_entry->target = strdup( target );
     291  } else {
     292
     293    /*
     294     * Do we already have a base file system ?
     295     */
     296    if ( !rtems_chain_is_empty( &rtems_filesystem_mount_table_control ) ) {
     297      errno = EINVAL;
     298      goto cleanup_and_bail;
     299    }
     300   
     301    /*
     302     *  This is a mount of the base file system --> The
     303     *  mt_point_node.node_access will be set to null to indicate that this
     304     *  is the root of the entire file system.
     305     */
     306
     307    mt_entry->mt_fs_root.node_access = NULL;
     308    mt_entry->mt_fs_root.handlers = NULL;
     309    mt_entry->mt_fs_root.ops = NULL;
     310
     311    mt_entry->mt_point_node.node_access = NULL;
     312    mt_entry->mt_point_node.handlers = NULL;
     313    mt_entry->mt_point_node.ops = NULL;
     314    mt_entry->mt_point_node.mt_entry = NULL;
     315
     316    mt_entry->target = "/";
     317  }
     318
     319  if ( entry->mount_h( mt_entry, data ) ) {
     320    /*
     321     * Try to undo the mount operation
     322     */
     323    if ( loc.ops->unmount_h ) {
     324      loc.ops->unmount_h( mt_entry );
     325    }
     326    goto cleanup_and_bail;
     327  }
     328
     329  /*
     330   *  Add the mount table entry to the mount table chain
     331   */
     332  rtems_chain_append( &rtems_filesystem_mount_table_control,
     333                      &mt_entry->Node );
     334
     335  if ( !target )
     336    rtems_filesystem_root = mt_entry->mt_fs_root;
     337
     338  return 0;
     339
     340cleanup_and_bail:
     341
     342  free( (void*) mt_entry->target );
     343  free( mt_entry );
     344
     345  if ( loc_to_free )
     346    rtems_filesystem_freenode( loc_to_free );
     347
     348  return -1;
     349}
     350
  • cpukit/libcsupport/src/privateenv.c

    reea48e2f r29e92b0  
    11/*
    2  *  Instantatiate a private user environment for the calling thread.
     2 *  Instantiate a private user environment for the calling thread.
    33 *
    44 *  Submitted by: fernando.ruiz@ctv.es (correo@fernando-ruiz.com)
     
    2424#include <rtems/libio.h>
    2525#include <rtems/libio_.h>
    26 
    27 extern rtems_chain_control rtems_filesystem_mount_table_control;
    28 
    29 #define THE_ROOT_FS_LOC \
    30         (((rtems_filesystem_mount_table_entry_t*)\
    31            rtems_filesystem_mount_table_control.first)->mt_fs_root)
    3226
    3327/* cleanup a user environment
     
    8377  rtems_current_user_env->task_id=task_id;         /* mark the local values*/
    8478
    85   /* get a clean root */
    86   rtems_filesystem_root    = THE_ROOT_FS_LOC;
    87 
    8879  /* Clone the pathlocs. In contrast to most other
    8980   * code we must _not_ free the original locs because
    9081   * what we are trying to do here is forking off
    91    * clones.
     82   * clones. The reason is a pathloc can be allocated by the
     83   * file system and needs to be freed when deleting the environment.
    9284   */
    9385
  • cpukit/libcsupport/src/unmount.c

    reea48e2f r29e92b0  
    214214
    215215  rtems_filesystem_freenode( fs_mount_loc );
     216  free( (void*) mt_entry->target );
    216217  free( mt_entry );
    217218
  • cpukit/libfs/src/devfs/devfs.h

    reea48e2f r29e92b0  
    5151extern uint32_t rtems_device_table_size;
    5252
    53 
    54 /**
    55  *  The following defines the device-only filesystem operating
    56  *  handlers.
    57  */
    58 
    59 extern rtems_filesystem_operations_table devFS_ops;
    60 
    61 /**
    62  *  The following defines the device-only filesystem operating
    63  *  handlers.
    64  */
    65 
    66 extern rtems_filesystem_file_handlers_r  devFS_file_handlers;
    67 
    68 
    6953/**
    7054 *  This handler maps open operation to rtems_io_open.
     
    258242 *  handlers. After this, the device-only filesytem is ready for use
    259243 *
    260  *  @param  temp_mt_entry
     244 *  @param  mt_entry The filesystem mount table entry.
     245 *  @param  data Filesystem specific data.
    261246 *  @retval upon success, this routine returns 0; otherwise it returns
    262247 *  -1 and errno is set to proper value. The only error is when malloc
     
    265250
    266251extern int devFS_initialize(
    267   rtems_filesystem_mount_table_entry_t *temp_mt_entry
     252  rtems_filesystem_mount_table_entry_t *mt_entry,
     253  const void                           *data
    268254);
    269255
  • cpukit/libfs/src/devfs/devfs_eval.c

    reea48e2f r29e92b0  
    1515#include <assert.h>
    1616#include "devfs.h"
     17
     18/**
     19 *  The following defines the device-only filesystem operating
     20 *  handlers.
     21 */
     22
     23extern rtems_filesystem_operations_table devFS_ops;
     24
     25/**
     26 *  The following defines the device-only filesystem operating
     27 *  handlers.
     28 */
     29
     30extern rtems_filesystem_file_handlers_r  devFS_file_handlers;
    1731
    1832int devFS_evaluate_path(
  • cpukit/libfs/src/devfs/devfs_init.c

    reea48e2f r29e92b0  
    6060
    6161int devFS_initialize(
    62   rtems_filesystem_mount_table_entry_t *temp_mt_entry
     62  rtems_filesystem_mount_table_entry_t *temp_mt_entry,
     63  const void                           *data
    6364)
    6465{
  • cpukit/libfs/src/dosfs/dosfs.h

    reea48e2f r29e92b0  
    2626#endif
    2727
    28 extern rtems_filesystem_operations_table  msdos_ops;
     28int rtems_dosfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry,
     29                           const void                           *data);
    2930
    3031#define MSDOS_FMT_FATANY 0
  • cpukit/libfs/src/dosfs/msdos.h

    reea48e2f r29e92b0  
    224224
    225225/* Prototypes */
    226 int msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
    227 
    228226int msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
    229227
  • cpukit/libfs/src/dosfs/msdos_init.c

    reea48e2f r29e92b0  
    1717
    1818#include <rtems/libio_.h>
     19#include "dosfs.h"
    1920#include "msdos.h"
    2021
     
    2930  .freenod_h      =  msdos_free_node_info,
    3031  .mount_h        =  NULL,
    31   .fsmount_me_h   =  msdos_initialize,
     32  .fsmount_me_h   =  rtems_dosfs_initialize,
    3233  .unmount_h      =  NULL,
    3334  .fsunmount_me_h =  msdos_shut_down,
     
    5152 *
    5253 */
    53 int msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry)
     54int rtems_dosfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry,
     55                           const void                           *data)
    5456{
    5557    int rc;
    5658
    57     rc = msdos_initialize_support(temp_mt_entry,
     59    rc = msdos_initialize_support(mt_entry,
    5860                                  &msdos_ops,
    5961                                  &msdos_file_handlers,
  • cpukit/libfs/src/imfs/imfs.h

    reea48e2f r29e92b0  
    256256
    257257extern int IMFS_initialize(
    258    rtems_filesystem_mount_table_entry_t *mt_entry
     258   rtems_filesystem_mount_table_entry_t *mt_entry,
     259   const void                           *data
    259260);
    260261
    261262extern int miniIMFS_initialize(
    262    rtems_filesystem_mount_table_entry_t *mt_entry
     263   rtems_filesystem_mount_table_entry_t *mt_entry,
     264   const void                           *data
    263265);
    264266
  • cpukit/libfs/src/imfs/imfs_eval.c

    reea48e2f r29e92b0  
    491491  int                                flags,        /* IN     */
    492492  rtems_filesystem_location_info_t  *pathloc       /* IN/OUT */
    493 )
     493                   )
    494494{
    495495  int                                 i = 0;
     
    532532      if ( node->type == IMFS_DIRECTORY )
    533533        if ( !IMFS_evaluate_permission( pathloc, RTEMS_LIBIO_PERMS_SEARCH ) )
    534            rtems_set_errno_and_return_minus_one( EACCES );
     534          rtems_set_errno_and_return_minus_one( EACCES );
    535535
    536536    node = pathloc->node_access;
     
    538538    switch( type ) {
    539539      case IMFS_UP_DIR:
    540        /*
    541         *  Am I at the root of all filesystems? (chroot'ed?)
    542         */
    543 
    544        if ( pathloc->node_access == rtems_filesystem_root.node_access )
    545          break;       /* Throw out the .. in this case */
    546 
    547         /*
    548         *  Am I at the root of this mounted filesystem?
    549         */
     540        /*
     541         *  Am I at the root of all filesystems? (chroot'ed?)
     542         */
     543
     544        if ( pathloc->node_access == rtems_filesystem_root.node_access )
     545          break;       /* Throw out the .. in this case */
     546
     547        /*
     548        *  Am I at the root of this mounted filesystem?
     549        */
    550550
    551551        if (pathloc->node_access ==
     
    553553
    554554          /*
    555            *  Am I at the root of all filesystems?
    556            */
     555           *  Am I at the root of all filesystems?
     556           */
    557557
    558558          if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
    559559            break;       /* Throw out the .. in this case */
    560           } else {
     560          } else {
    561561            newloc = pathloc->mt_entry->mt_point_node;
    562562            *pathloc = newloc;
     
    564564                                               pathnamelen+len,
    565565                                               flags,pathloc);
    566           }
    567         } else {
     566          }
     567        } else {
    568568
    569569          if ( !node->Parent )
     
    573573          pathloc->node_access = node;
    574574
    575         }
     575        }
    576576
    577577        pathloc->node_access = node;
     
    579579
    580580      case IMFS_NAME:
    581         /*
    582         *  If we are at a link follow it.
    583         */
    584 
    585         if ( node->type == IMFS_HARD_LINK ) {
     581        /*
     582        *  If we are at a link follow it.
     583        */
     584
     585        if ( node->type == IMFS_HARD_LINK ) {
    586586
    587587          IMFS_evaluate_hard_link( pathloc, 0 );
     
    591591            rtems_set_errno_and_return_minus_one( ENOTDIR );
    592592
    593         } else if ( node->type == IMFS_SYM_LINK ) {
     593        } else if ( node->type == IMFS_SYM_LINK ) {
    594594
    595595          result = IMFS_evaluate_sym_link( pathloc, 0 );
     
    598598          if ( result == -1 )
    599599            return -1;
    600         }
    601 
    602        /*
    603         *  Only a directory can be decended into.
    604         */
    605 
    606        if ( node->type != IMFS_DIRECTORY )
     600        }
     601
     602        /*
     603         *  Only a directory can be decended into.
     604         */
     605
     606        if ( node->type != IMFS_DIRECTORY )
    607607          rtems_set_errno_and_return_minus_one( ENOTDIR );
    608608
    609         /*
    610         *  If we are at a node that is a mount point. Set loc to the
    611         *  new fs root node and let them finish evaluating the path.
    612         */
     609        /*
     610        *  If we are at a node that is a mount point. Set loc to the
     611        *  new fs root node and let them finish evaluating the path.
     612        */
    613613
    614614        if ( node->info.directory.mt_fs != NULL ) {
     
    618618                                              pathnamelen+len,
    619619                                              flags, pathloc );
    620         }
    621 
    622         /*
    623         *  Otherwise find the token name in the present location.
    624         */
     620        }
     621
     622        /*
     623        *  Otherwise find the token name in the present location.
     624        */
    625625
    626626        node = IMFS_find_match_in_dir( node, token );
     
    628628          rtems_set_errno_and_return_minus_one( ENOENT );
    629629
    630         /*
    631         *  Set the node access to the point we have found.
    632         */
     630        /*
     631        *  Set the node access to the point we have found.
     632        */
    633633
    634634        pathloc->node_access = node;
  • cpukit/libfs/src/imfs/imfs_init.c

    reea48e2f r29e92b0  
    6060
    6161int IMFS_initialize(
    62   rtems_filesystem_mount_table_entry_t *temp_mt_entry
     62  rtems_filesystem_mount_table_entry_t *temp_mt_entry,
     63  const void                           *data
    6364)
    6465{
  • cpukit/libfs/src/imfs/miniimfs_init.c

    reea48e2f r29e92b0  
    6060
    6161int miniIMFS_initialize(
    62   rtems_filesystem_mount_table_entry_t *temp_mt_entry
     62  rtems_filesystem_mount_table_entry_t *temp_mt_entry,
     63  const void                           *data
    6364)
    6465{
  • cpukit/libfs/src/nfsclient/src/librtemsNfs.h

    reea48e2f r29e92b0  
    7171#include <arpa/inet.h>
    7272
     73#ifdef __cplusplus
     74extern "C" {
     75#endif
     76
    7377/* RPCIO driver interface.
    7478 * If you need RPCIO for other purposes than NFS
     
    8387extern rtems_task_priority rpciodPriority;
    8488
    85 /* Initialize the driver
     89/* Initialize the driver.
     90 *
     91 * Note, called in nfsfs initialise when mount is called.
    8692 *
    8793 * RETURNS: 0 on success, -1 on failure
     
    103109 * NOTE: The RPCIO driver must have been initialized prior to
    104110 *       calling this.
     111 *
     112 * Note, called in nfsfs initialise when mount is called with defaults.
    105113 *
    106114 * ARGS:        depth of the small and big
     
    132140nfsMountsShow(FILE *f);
    133141
    134 /* convenience wrapper
    135  *
    136  * NOTE: this routine calls NON-REENTRANT
    137  *       gethostbyname() if the host is
    138  *       not in 'dot' notation.
     142/*
     143 * Filesystem mount table mount handler. Do not call, use the mount call.
    139144 */
    140 int
    141 nfsMount(char *uidhost, char *path, char *mntpoint);
    142 
    143 /* Alternatively, a pointer to the filesystem operations
    144  * table can be supplied to the native RTEMS (NON-POSIX!)
    145  * 'mount()' call.
    146  * Supply a "<host.in.ip.dot.notation>:<path>" string
    147  * for 'device' argument to 'mount()'.
    148  */
    149 extern struct _rtems_filesystem_operations_table nfs_fs_ops;
     145int
     146rtems_nfsfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry,
     147                       const void                           *data);
    150148
    151149/* A utility routine to find the path leading to a
     
    175173uint32_t
    176174nfsGetTimeout(void);
     175
     176#ifdef __cplusplus
     177}
    177178#endif
     179
     180#endif
  • cpukit/libfs/src/nfsclient/src/nfs.c

    reea48e2f r29e92b0  
    44
    55/* Author: Till Straumann <strauman@slac.stanford.edu> 2002 */
     6
     7/* Hacked on by others. */
    68
    79/*
     
    11941196
    11951197/*
    1196  * IP address helper. Note that we avoid
    1197  * gethostbyname() since it's not reentrant.
     1198 * IP address helper.
    11981199 *
    11991200 * initialize a sockaddr_in from a
     
    12121213                        char **pPath)
    12131214{
    1214 char    host[30];
     1215struct hostent *h;
     1216char    host[64];
    12151217char    *chpt = *pPath;
    12161218char    *path;
     
    12391241        /* split the device name which is in the form
    12401242         *
    1241          * <host_ip> ':' <path>
     1243         * <host> ':' <path>
    12421244         *
    12431245         * into its components using a local buffer
     
    12551257        host[len]=0;
    12561258
    1257         if ( ! inet_pton(AF_INET, host, &psa->sin_addr) ) {
    1258                 errno = ENXIO;
     1259  /* BEGIN OF NON-THREAD SAFE REGION */
     1260
     1261        h = gethostbyname(host);
     1262
     1263        if ( !h ) {
     1264                errno = EINVAL;
    12591265                return -1;
    12601266        }
     1267
     1268        memcpy(&psa->sin_addr, h->h_addr, sizeof (struct in_addr));
     1269 
     1270  /* END OF NON-THREAD SAFE REGION */
    12611271
    12621272        psa->sin_family = AF_INET;
     
    18991909
    19001910
    1901 /* This op is called as the last step of mounting this FS */
    1902 STATIC int nfs_fsmount_me(
    1903         rtems_filesystem_mount_table_entry_t *mt_entry
     1911int rtems_nfsfs_initialize(
     1912        rtems_filesystem_mount_table_entry_t *mt_entry,
     1913  const void                           *data
    19041914)
    19051915{
     
    19181928char                            *path     = mt_entry->dev;
    19191929
    1920 
     1930  if (rpcUdpInit () < 0) {
     1931    fprintf (stderr, "error: initialising RPC\n");
     1932    return -1;
     1933  }
     1934 
     1935        nfsInit(0, 0);
     1936
     1937#if 0
     1938        printf("Trying to mount %s on %s\n",path,mntpoint);
     1939#endif
     1940 
    19211941        if ( buildIpAddr(&uid, &gid, &host, &saddr, &path) )
    19221942                return -1;
    1923 
    19241943
    19251944#ifdef NFS_V2_PORT
     
    24612480                nfs_freenode,           /* OPTIONAL; may be NULL; (release node_access) */
    24622481                nfs_mount,                      /* OPTIONAL; may be NULL */
    2463                 nfs_fsmount_me,         /* OPTIONAL; may be NULL -- but this makes NO SENSE */
     2482                rtems_nfsfs_initialize,         /* OPTIONAL; may be NULL -- not used anymore */
    24642483                nfs_unmount,            /* OPTIONAL; may be NULL */
    24652484                nfs_fsunmount_me,       /* OPTIONAL; may be NULL */
     
    32293248}
    32303249
     3250#if 0
     3251CCJ_REMOVE_MOUNT
    32313252/* convenience wrapper
    32323253 *
     
    32383259nfsMount(char *uidhost, char *path, char *mntpoint)
    32393260{
    3240 rtems_filesystem_mount_table_entry_t    *mtab;
    32413261struct stat                                                             st;
    32423262int                                                                             devl;
     
    33113331        printf("Trying to mount %s on %s\n",dev,mntpoint);
    33123332
    3313         if (mount(&mtab,
    3314                           &nfs_fs_ops,
    3315                           RTEMS_FILESYSTEM_READ_WRITE,
    3316                           dev,
    3317                           mntpoint)) {
     3333        if (mount(dev,
     3334                          mntpoint,
     3335                          "nfs",
     3336                          RTEMS_FILESYSTEM_READ_WRITE,
     3337                          NULL)) {
    33183338                perror("nfsMount - mount");
    33193339                goto cleanup;
     
    33263346        return rval;
    33273347}
     3348#endif
    33283349
    33293350/* HERE COMES A REALLY UGLY HACK */
  • cpukit/libfs/src/rfs/rtems-rfs-rtems.c

    reea48e2f r29e92b0  
    121121    while (!rtems_filesystem_is_separator (*path) &&
    122122           (*path != '\0') && pathlen &&
    123            (node_len + 1 < rtems_rfs_fs_max_name (fs)))
     123           ((node_len + 1) < rtems_rfs_fs_max_name (fs)))
    124124    {
    125125      path++;
     
    12151215 */
    12161216
    1217 int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry);
     1217int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry,
     1218                                const void                           *data);
    12181219int rtems_rfs_rtems_shutdown (rtems_filesystem_mount_table_entry_t *mt_entry);
    12191220
     
    12481249
    12491250int
    1250 rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t* mt_entry)
     1251rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t* mt_entry,
     1252                            const void*                           data)
    12511253{
    12521254  rtems_rfs_rtems_private* rtems;
  • cpukit/libfs/src/rfs/rtems-rfs.h

    reea48e2f r29e92b0  
    2424
    2525/**
    26  * File ops table for the RFS file system.
    27  */
    28 const rtems_filesystem_operations_table rtems_rfs_ops;
    29 
    30 /**
    3126 * Initialise the RFS File system.
    3227 */
    33 int rtems_rfs_initialise (rtems_filesystem_mount_table_entry_t *mt_entry);
     28int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry);
    3429
    3530#endif
  • cpukit/libmisc/Makefile.am

    reea48e2f r29e92b0  
    7777    shell/main_mallocinfo.c shell/main_mdump.c shell/main_medit.c \
    7878    shell/main_mfill.c shell/main_mkdir.c shell/main_mount.c \
    79     shell/main_mount_msdos.c shell/main_mmove.c shell/main_msdosfmt.c \
     79    shell/main_mmove.c shell/main_msdosfmt.c \
    8080    shell/main_mv.c shell/main_mwdump.c shell/main_perioduse.c \
    8181    shell/main_pwd.c shell/main_rm.c shell/main_rmdir.c shell/main_sleep.c \
     
    9696    shell/main_hexdump.c shell/hexdump-conv.c shell/hexdump-display.c \
    9797    shell/hexdump-odsyntax.c shell/hexdump-parse.c shell/hexsyntax.c \
    98     shell/main_time.c shell/main_mknod.c  shell/main_mount_rfs.c \
     98    shell/main_time.c shell/main_mknod.c \
    9999    shell/main_setenv.c shell/main_getenv.c shell/main_unsetenv.c \
    100100    shell/main_mkrfs.c shell/main_debugrfs.c
    101101
    102102if LIBNETWORKING
    103 libshell_a_SOURCES += shell/main_mount_ftp.c shell/main_mount_tftp.c \
    104     shell/main_ifconfig.c shell/main_route.c shell/main_netstats.c \
    105     shell/main_mount_nfs.c
     103libshell_a_SOURCES += \
     104    shell/main_ifconfig.c shell/main_route.c shell/main_netstats.c
    106105endif
    107106endif
  • cpukit/libmisc/fsmount/fsmount.c

    reea48e2f r29e92b0  
    119119(
    120120/*-------------------------------------------------------------------------*\
    121 | Purpose:                                                                  |
    122 |  This function will create the mount points listed and mount the file     |
    123 |   systems listed in the calling parameters                                |
    124 +---------------------------------------------------------------------------+
    125 | Input Parameters:                                                         |
    126 \*-------------------------------------------------------------------------*/
    127  const rtems_fstab_entry *fstab_ptr,
    128  size_t fstab_count,
    129  size_t *fail_idx
     121  | Purpose:                                                                  |
     122  |  This function will create the mount points listed and mount the file     |
     123  |   systems listed in the calling parameters                                |
     124  +---------------------------------------------------------------------------+
     125  | Input Parameters:                                                         |
     126  \*-------------------------------------------------------------------------*/
     127  const rtems_fstab_entry *fstab_ptr,
     128  size_t fstab_count,
     129  size_t *fail_idx
    130130 )
    131131/*-------------------------------------------------------------------------*\
    132 | Return Value:                                                             |
    133 |    0, if success, -1 and errno if failed                                  |
    134 \*=========================================================================*/
     132  | Return Value:                                                             |
     133  |    0, if success, -1 and errno if failed                                  |
     134  \*=========================================================================*/
    135135{
    136136  int rc = 0;
    137137  int tmp_rc;
    138138  size_t fstab_idx = 0;
    139   rtems_filesystem_mount_table_entry_t *tmp_mt_entry;
    140139  bool terminate = false;
    141140
     
    144143   */
    145144  while (!terminate &&
    146         (fstab_idx < fstab_count)) {
     145        (fstab_idx < fstab_count)) {
    147146    tmp_rc = 0;
    148147    /*
     
    150149     */
    151150    if (tmp_rc == 0) {
    152       tmp_rc = rtems_fsmount_create_mount_point(fstab_ptr->mount_point);
     151      tmp_rc = rtems_fsmount_create_mount_point(fstab_ptr->target);
    153152      if (tmp_rc != 0) {
    154         if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNTPNT_CRTERR)) {
    155           fprintf(stdout,"fsmount: creation of mount point \"%s\" failed: %s\n",
    156                  fstab_ptr->mount_point,
    157                 strerror(errno));
    158         }
    159         if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNTPNT_CRTERR)) {
    160           terminate = true;
    161           rc = tmp_rc;
    162         }
     153        if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNTPNT_CRTERR)) {
     154          fprintf(stdout,"fsmount: creation of mount point \"%s\" failed: %s\n",
     155                  fstab_ptr->target,
     156                  strerror(errno));
     157        }
     158        if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNTPNT_CRTERR)) {
     159          terminate = true;
     160          rc = tmp_rc;
     161        }
    163162      }
    164163    }
     
    167166     */
    168167    if (tmp_rc == 0) {
    169       tmp_rc = mount(&tmp_mt_entry,
    170                      fstab_ptr->fs_ops,
    171                      fstab_ptr->mount_options,
    172                      fstab_ptr->dev,
    173                      fstab_ptr->mount_point);
     168      tmp_rc = mount(fstab_ptr->source,
     169                     fstab_ptr->target,
     170                     fstab_ptr->type,
     171                     fstab_ptr->options,
     172                     NULL);
    174173      if (tmp_rc != 0) {
    175         if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNT_FAILED)) {
    176           fprintf(stdout,"fsmount: mounting of \"%s\" to"
    177                 " \"%s\" failed: %s\n",
    178                  fstab_ptr->dev,
    179                  fstab_ptr->mount_point,
    180                 strerror(errno));
    181         }
    182         if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNT_FAILED)) {
    183           terminate = true;
    184           rc = tmp_rc;
    185         }
     174        if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNT_FAILED)) {
     175          fprintf(stdout,"fsmount: mounting of \"%s\" to"
     176                  " \"%s\" failed: %s\n",
     177                  fstab_ptr->source,
     178                  fstab_ptr->target,
     179                  strerror(errno));
     180        }
     181        if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNT_FAILED)) {
     182          terminate = true;
     183          rc = tmp_rc;
     184        }
    186185      }
    187186      else {
    188         if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNT_OK)) {
    189           fprintf(stdout,"fsmount: mounting of \"%s\" to"
    190                 " \"%s\" succeeded\n",
    191                  fstab_ptr->dev,
    192                  fstab_ptr->mount_point);
    193         }
    194         if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNT_OK)) {
    195           terminate = true;
    196         }
     187        if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNT_OK)) {
     188          fprintf(stdout,"fsmount: mounting of \"%s\" to"
     189                  " \"%s\" succeeded\n",
     190                  fstab_ptr->source,
     191                  fstab_ptr->target);
     192        }
     193        if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNT_OK)) {
     194          terminate = true;
     195        }
    197196      }
    198197    }
  • cpukit/libmisc/fsmount/fsmount.h

    reea48e2f r29e92b0  
    9191typedef struct {
    9292  /**
    93    * Device file path.
    94    */
    95   const char *dev;
    96 
    97   /**
    98    * Mount point path.
    99    */
    100   const char *mount_point;
     93   * Source for the mount.
     94   */
     95  const char *source;
     96
     97  /**
     98   * Target for the mount.
     99   */
     100  const char *target;
    101101
    102102  /**
    103103   * File system operations.
    104104   */
    105   const rtems_filesystem_operations_table *fs_ops;
     105  const char *type;
    106106
    107107  /**
    108108   * File system mount options.
    109109   */
    110   rtems_filesystem_options_t mount_options;
     110  rtems_filesystem_options_t options;
    111111
    112112  /**
     
    129129 * @see rtems_fsmount().
    130130 */
    131 int rtems_fsmount_create_mount_point( const char *mount_point);
     131int rtems_fsmount_create_mount_point(const char *mount_point);
    132132
    133133/**
     
    161161 * #include <rtems.h>
    162162 * #include <rtems/bdpart.h>
    163  * #include <rtems/dosfs.h>
    164163 * #include <rtems/error.h>
    165164 * #include <rtems/fsmount.h>
     
    167166 * static const rtems_fstab_entry fstab [] = {
    168167 *   {
    169  *     .dev = "/dev/sd-card-a",
    170  *     .mount_point = "/mnt",
    171  *     .fs_ops = &msdos_ops,
    172  *     .mount_options = RTEMS_FILESYSTEM_READ_WRITE,
     168 *     .source = "/dev/sd-card-a",
     169 *     .target = "/mnt",
     170 *     .type = "dosfs",
     171 *     .options = RTEMS_FILESYSTEM_READ_WRITE,
    173172 *     .report_reasons = RTEMS_FSTAB_ANY,
    174173 *     .abort_reasons = RTEMS_FSTAB_OK
    175174 *   }, {
    176  *     .dev = "/dev/sd-card-a1",
    177  *     .mount_point = "/mnt",
    178  *     .fs_ops = &msdos_ops,
    179  *     .mount_options = RTEMS_FILESYSTEM_READ_WRITE,
     175 *     .source = "/dev/sd-card-a1",
     176 *     .target = "/mnt",
     177 *     .type = "dosfs",
     178 *     .options = RTEMS_FILESYSTEM_READ_WRITE,
    180179 *     .report_reasons = RTEMS_FSTAB_ANY,
    181180 *     .abort_reasons = RTEMS_FSTAB_NONE
  • cpukit/libmisc/shell/main_mount.c

    reea48e2f r29e92b0  
    2525#include <rtems/shell.h>
    2626#include <rtems/shellconfig.h>
    27 #include <rtems/dosfs.h>
    28 #include <rtems/fsmount.h>
     27#include <rtems/libio.h>
    2928#include "internal.h"
    30 
    31 static rtems_chain_control filesystems;
    32 static bool                fs_init;
    33 
    34 static void rtems_shell_mount_fsys_init(void)
    35 {
    36   if (!fs_init)
    37   {
    38     rtems_chain_initialize_empty (&filesystems);
    39     fs_init = true;
    40   }
    41 }
    42 
    43 void rtems_shell_mount_add_fsys(rtems_shell_filesystems_t* fs)
    44 {
    45   rtems_shell_mount_fsys_init();
    46   rtems_chain_append (&filesystems, &fs->link);
    47 }
    48 
    49 void rtems_shell_mount_del_fsys(rtems_shell_filesystems_t* fs)
    50 {
    51   if (fs_init)
    52     rtems_chain_extract (&fs->link);
    53 }
    54 
    55 int rtems_shell_libc_mounter(
    56   const char*                driver,
    57   const char*                path,
    58   rtems_shell_filesystems_t* fs,
    59   rtems_filesystem_options_t options)
    60 {
    61   rtems_filesystem_mount_table_entry_t* mt_entry;
    62   /*
    63    * Mount the disk.
    64    */
    65 
    66   if (mount (&mt_entry, fs->fs_ops, options, (char*) driver, (char*) path) < 0)
    67   {
    68     fprintf (stderr, "mount: mount failed: %s\n", strerror (errno));
    69     return 1;
    70   }
    71 
    72   return 0;
    73 }
    74 
    75 #define NUMOF(_i) (sizeof (_i) / sizeof (_i[0]))
    7629
    7730int rtems_shell_main_mount(
     
    8134{
    8235  rtems_filesystem_options_t options = RTEMS_FILESYSTEM_READ_WRITE;
    83   rtems_shell_filesystems_t* fs = NULL;
    84   char*                      driver = NULL;
    85   char*                      mount_point = NULL;
     36  char*                      type = NULL;
     37  char*                      source = NULL;
     38  char*                      target = NULL;
     39  char*                      fsoptions = NULL;
    8640  int                        arg;
    87 
    88   rtems_shell_mount_fsys_init();
    8941
    9042  for (arg = 1; arg < argc; arg++) {
    9143    if (argv[arg][0] == '-') {
    9244      if (argv[arg][1] == 't') {
    93         rtems_shell_filesystems_t** a;
    94 
    9545        arg++;
    9646        if (arg == argc) {
     
    10252          return 1;
    10353        }
    104 
    105         for (a = rtems_shell_Mount_filesystems; *a; a++) {
    106           if (strcmp (argv[arg], (*a)->name) == 0) {
    107             fs = *a;
    108             break;
    109           }
    110         }
    111 
    112         if (!fs && !rtems_chain_is_empty(&filesystems)) {
    113           rtems_chain_node* node = filesystems.first;
    114           while (!rtems_chain_is_tail (&filesystems, node)) {
    115             rtems_shell_filesystems_t* f = (rtems_shell_filesystems_t*)node;
    116             if (strcmp (argv[arg], f->name) == 0) {
    117               fs = f;
    118               break;
    119             }
    120             node = node->next;
    121           }
    122         }
     54        type = argv[arg];
    12355      } else if (argv[arg][1] == 'r') {
    12456        options = RTEMS_FILESYSTEM_READ_ONLY;
    12557      } else if (argv[arg][1] == 'L') {
    126         rtems_shell_filesystems_t** a;
    127         fprintf (stderr, "File systems: ");
    128         for (a = rtems_shell_Mount_filesystems; *a; a++)
    129           if (*a)
    130             fprintf (stderr, "%s ", (*a)->name);
    131         if (!rtems_chain_is_empty(&filesystems)) {
    132           rtems_chain_node* node = filesystems.first;
    133           while (!rtems_chain_is_tail (&filesystems, node)) {
    134             rtems_shell_filesystems_t* f = (rtems_shell_filesystems_t*)node;
    135             fprintf (stderr, "%s ", f->name);
    136             node = node->next;
    137           }
     58        const rtems_filesystem_table_t* fs;
     59        fs = rtems_filesystem_table_first();
     60        printf ("File systems: ");
     61        while (fs) {
     62          printf ("%s ", fs->type);
     63          fs = rtems_filesystem_table_next(fs);
    13864        }
    139         fprintf (stderr, "\n");
    140         return 1;
     65        printf ("\n");
     66        return 0;
     67      } else if (argv[arg][1] == 'o') {
     68        arg++;
     69        if (arg == argc) {
     70          fprintf(
     71            stderr,
     72            "%s: -o needs a list if filesystem options.\n",
     73            argv[0]
     74          );
     75          return 1;
     76        }
     77        fsoptions = argv[arg];
    14178      } else {
    14279        fprintf (stderr, "unknown option: %s\n", argv[arg]);
     
    14481      }
    14582    } else {
    146       if (!driver)
    147         driver = argv[arg];
    148       else if (!mount_point)
    149         mount_point = argv[arg];
     83      if (!source)
     84        source = argv[arg];
     85      else if (!target)
     86        target = argv[arg];
    15087      else {
    15188        fprintf (
    152           stderr, "mount: driver and mount only require: %s\n", argv[arg]);
     89          stderr, "mount: source and mount only require: %s\n", argv[arg]);
    15390        return 1;
    15491      }
     
    15693  }
    15794
    158   if (fs == NULL) {
     95  if (!type) {
    15996    fprintf (stderr, "mount: no file-system; see the -L option\n");
    16097    return 1;
    16198  }
    16299
    163   if (fs->driver_needed && !driver) {
    164     fprintf (stderr, "mount: no driver\n");
     100  if (!source) {
     101    fprintf (stderr, "mount: no source\n");
    165102    return 1;
    166103  }
    167104
    168   if (!mount_point) {
     105  if (!target) {
    169106    fprintf (stderr, "mount: no mount point\n");
    170107    return 1;
     
    175112   */
    176113
    177   if (fs->mounter (driver, mount_point, fs, options))
     114  if (mount (source, target, type, options, fsoptions) < 0) {
     115    fprintf (stderr, "error: %s\n", strerror(errno));
    178116    return 1;
     117  }
    179118
    180   printf ("mounted %s -> %s\n", driver, mount_point);
     119  printf ("mounted %s -> %s\n", source, target);
    181120
    182121  return 0;
     
    184123
    185124rtems_shell_cmd_t rtems_shell_MOUNT_Command = {
    186   "mount",                                                /* name */
    187   "mount [-t fstype] [-r] [-L] device path # mount disk", /* usage */
    188   "files",                                                /* topic */
    189   rtems_shell_main_mount,                                 /* command */
    190   NULL,                                                   /* alias */
    191   NULL                                                    /* next */
     125  "mount",                                     /* name */
     126  "mount [-t type] [-r] [-L] source target",  /* usage */
     127  "files",                                     /* topic */
     128  rtems_shell_main_mount,                      /* command */
     129  NULL,                                        /* alias */
     130  NULL                                         /* next */
    192131};
  • cpukit/libmisc/shell/shellconfig.h

    reea48e2f r29e92b0  
    9393
    9494/*
    95  *  Externs for mount command helpers
    96  */
    97 extern rtems_shell_filesystems_t rtems_shell_Mount_RFS;
    98 extern rtems_shell_filesystems_t rtems_shell_Mount_MSDOS;
    99 extern rtems_shell_filesystems_t rtems_shell_Mount_TFTP;
    100 extern rtems_shell_filesystems_t rtems_shell_Mount_FTP;
    101 extern rtems_shell_filesystems_t rtems_shell_Mount_NFS;
    102 
    103 extern rtems_shell_filesystems_t *rtems_shell_Mount_filesystems[];
    104 
    105 /*
    10695 *  If we are configured to alias a command, then make sure the underlying
    10796 *  command is configured.
     
    445434  };
    446435
    447   /*
    448    * The mount command's support file system types.
    449    */
    450   #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \
    451        !defined(CONFIGURE_SHELL_COMMAND_NO_MOUNT)) || \
    452        defined(CONFIGURE_SHELL_COMMAND_MOUNT)
    453     rtems_shell_filesystems_t *rtems_shell_Mount_filesystems[] = {
    454       #if defined(CONFIGURE_SHELL_MOUNT_RFS)
    455         &rtems_shell_Mount_RFS,
    456       #endif
    457       #if defined(CONFIGURE_SHELL_MOUNT_MSDOS)
    458         &rtems_shell_Mount_MSDOS,
    459       #endif
    460       #if RTEMS_NETWORKING
    461         #if defined(CONFIGURE_SHELL_MOUNT_TFTP)
    462           &rtems_shell_Mount_TFTP,
    463         #endif
    464         #if defined(CONFIGURE_SHELL_MOUNT_FTP)
    465           &rtems_shell_Mount_FTP,
    466         #endif
    467         #if defined(CONFIGURE_SHELL_MOUNT_NFS)
    468           &rtems_shell_Mount_NFS,
    469         #endif
    470       #endif
    471       NULL
    472     };
    473   #endif
    474 
    475436#endif
    476437
  • cpukit/libnetworking/lib/ftpfs.c

    reea48e2f r29e92b0  
    131131}
    132132
     133#if 0
     134CCJ_REMOVE_MOUNT
    133135rtems_status_code rtems_ftpfs_mount(const char *mount_point)
    134136{
     
    157159  return RTEMS_SUCCESSFUL;
    158160}
     161#endif
    159162
    160163static rtems_status_code rtems_ftpfs_do_ioctl(
     
    233236    timeout
    234237  );
    235 }
    236 
    237 int rtems_bsdnet_initialize_ftp_filesystem(void)
    238 {
    239   rtems_status_code sc = RTEMS_SUCCESSFUL;
    240 
    241   sc = rtems_ftpfs_mount(NULL);
    242 
    243   if (sc == RTEMS_SUCCESSFUL) {
    244     return 0;
    245   } else {
    246     return -1;
    247   }
    248238}
    249239
     
    12331223}
    12341224
    1235 static int rtems_ftpfs_mount_me(
    1236   rtems_filesystem_mount_table_entry_t *e
     1225int rtems_ftpfs_initialize(
     1226  rtems_filesystem_mount_table_entry_t *e,
     1227  const void                           *d
    12371228)
    12381229{
     
    13381329  .freenod_h = rtems_ftpfs_free_node,
    13391330  .mount_h = NULL,
    1340   .fsmount_me_h = rtems_ftpfs_mount_me,
     1331  .fsmount_me_h = rtems_ftpfs_initialize,
    13411332  .unmount_h = NULL,
    13421333  .fsunmount_me_h = rtems_ftpfs_unmount_me,
  • cpukit/libnetworking/lib/tftpDriver.c

    reea48e2f r29e92b0  
    3434#include <netinet/in.h>
    3535#include <arpa/inet.h>
     36#include <netdb.h>
    3637
    3738#ifdef RTEMS_TFTP_DRIVER_DEBUG
     
    4344 */
    4445#define UDP_PORT_BASE        3180
    45 
    46 /*
    47  * Pathname prefix
    48  */
    49 #define TFTP_PATHNAME_PREFIX "/TFTP/"
    50 
    51 /*
    52  * Root node_access value
    53  * By using the address of a local static variable
    54  * we ensure a unique value for this identifier.
    55  */
    56 #define ROOT_NODE_ACCESS    (&tftp_mutex)
    5746
    5847/*
     
    153142
    154143/*
     144 * Flags for filesystem info.
     145 */
     146#define TFTPFS_VERBOSE (1 << 0)
     147
     148/*
     149 * Root node_access value
     150 * By using the address of the file system
     151 * we ensure a unique value for this identifier.
     152 */
     153#define ROOT_NODE_ACCESS(_fs) (_fs)
     154
     155/*
     156 * TFTP File system info.
     157 */
     158typedef struct tftpfs_info_s {
     159  uint32_t flags;
     160  rtems_id tftp_mutex;
     161  int nStreams;
     162  struct tftpStream ** volatile tftpStreams;
     163} tftpfs_info_t;
     164
     165#define tftpfs_info_mount_table(_mt) ((tftpfs_info_t*) ((_mt)->fs_info))
     166#define tftpfs_info_pathloc(_pl)     ((tftpfs_info_t*) ((_pl)->mt_entry->fs_info))
     167#define tftpfs_info_iop(_iop)        (tftpfs_info_pathloc (&((_iop)->pathinfo)))
     168
     169/*
    155170 * Number of streams open at the same time
    156171 */
    157 static rtems_id tftp_mutex;
    158 static int nStreams;
    159 static struct tftpStream ** volatile tftpStreams;
    160172
    161173typedef const char *tftp_node;
     
    163175extern rtems_filesystem_file_handlers_r   rtems_tftp_handlers;
    164176
    165 /*
    166  *  Direct copy from the IMFS.  Look at this.
    167  */
    168 
    169 rtems_filesystem_limits_and_options_t rtems_tftp_limits_and_options = {
    170    5,   /* link_max */
    171    6,   /* max_canon */
    172    7,   /* max_input */
    173    255, /* name_max */
    174    255, /* path_max */
    175    2,   /* pipe_buf */
    176    1,   /* posix_async_io */
    177    2,   /* posix_chown_restrictions */
    178    3,   /* posix_no_trunc */
    179    4,   /* posix_prio_io */
    180    5,   /* posix_sync_io */
    181    6    /* posix_vdisable */
    182 };
    183 
    184 static int rtems_tftp_mount_me(
    185   rtems_filesystem_mount_table_entry_t *temp_mt_entry
     177int rtems_tftpfs_initialize(
     178  rtems_filesystem_mount_table_entry_t *mt_entry,
     179  const void                           *data
    186180)
    187181{
     182  tftpfs_info_t     *fs;
    188183  rtems_status_code  sc;
    189184
    190   temp_mt_entry->mt_fs_root.handlers = &rtems_tftp_handlers;
    191   temp_mt_entry->mt_fs_root.ops      = &rtems_tftp_ops;
     185  mt_entry->mt_fs_root.handlers = &rtems_tftp_handlers;
     186  mt_entry->mt_fs_root.ops      = &rtems_tftp_ops;
    192187
    193188  /*
     
    198193   */
    199194
    200   temp_mt_entry->fs_info                = NULL;
    201   temp_mt_entry->mt_fs_root.node_access = ROOT_NODE_ACCESS;
    202 
    203   /*
    204    *  These need to be looked at for full POSIX semantics.
    205    */
    206 
    207   temp_mt_entry->pathconf_limits_and_options = rtems_tftp_limits_and_options;
    208 
    209 
     195  fs = malloc (sizeof (tftpfs_info_t));
     196  if (!fs)
     197      rtems_set_errno_and_return_minus_one (ENOMEM);
     198
     199  fs->flags = 0;
     200  fs->nStreams = 0;
     201  fs->tftpStreams = 0;
     202 
     203  mt_entry->fs_info                  = fs;
     204  mt_entry->mt_fs_root.node_access   = ROOT_NODE_ACCESS (fs);
     205  mt_entry->mt_fs_root.node_access_2 = NULL;
     206 
    210207  /*
    211208   *  Now allocate a semaphore for mutual exclusion.
     
    223220    RTEMS_LOCAL,
    224221    0,
    225     &tftp_mutex
     222    &fs->tftp_mutex
    226223  );
    227224
    228225  if (sc != RTEMS_SUCCESSFUL)
    229     rtems_set_errno_and_return_minus_one( ENOMEM );
    230 
     226      rtems_set_errno_and_return_minus_one (ENOMEM);
     227
     228  if (data) {
     229      char* config = (char*) data;
     230      char* token;
     231      char* saveptr;
     232      token = strtok_r (config, " ", &saveptr);
     233      while (token) {
     234          if (strcmp (token, "verbose") == 0)
     235              fs->flags |= TFTPFS_VERBOSE;
     236          token = strtok_r (NULL, " ", &saveptr);
     237      }
     238  }
     239 
    231240  return 0;
    232241}
    233242
    234243/*
    235  * Initialize the TFTP driver
    236  */
    237 
    238 int rtems_bsdnet_initialize_tftp_filesystem (void)
    239 {
    240     int                                   status;
    241     rtems_filesystem_mount_table_entry_t *entry;
    242 
    243     status = mkdir( TFTP_PATHNAME_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO );
    244     if ( status == -1 )
    245         return status;
    246 
    247     status = mount(
    248             &entry,
    249             &rtems_tftp_ops,
    250             RTEMS_FILESYSTEM_READ_WRITE,
    251             NULL,
    252             TFTP_PATHNAME_PREFIX
    253     );
    254 
    255     if ( status )
    256         perror( "TFTP mount failed" );
    257 
    258     return status;
     244 * Release a stream and clear the pointer to it
     245 */
     246static void
     247releaseStream (tftpfs_info_t *fs, int s)
     248{
     249    if (fs->tftpStreams[s] && (fs->tftpStreams[s]->socket >= 0))
     250        close (fs->tftpStreams[s]->socket);
     251    rtems_semaphore_obtain (fs->tftp_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     252    free (fs->tftpStreams[s]);
     253    fs->tftpStreams[s] = NULL;
     254    rtems_semaphore_release (fs->tftp_mutex);
     255}
     256
     257static int
     258rtems_tftpfs_shutdown (rtems_filesystem_mount_table_entry_t* mt_entry)
     259{
     260  tftpfs_info_t *fs = tftpfs_info_mount_table (mt_entry);
     261  int            s;
     262  for (s = 0; s < fs->nStreams; s++)
     263      releaseStream (fs, s);
     264  rtems_semaphore_delete (fs->tftp_mutex);
     265  free (fs);
     266  return 0;
    259267}
    260268
     
    336344        socklen_t fromlen = sizeof from;
    337345        len = recvfrom (tp->socket, &tp->pkbuf,
    338                                                     sizeof tp->pkbuf, 0,
    339                                                     &from.s, &fromlen);
     346                        sizeof tp->pkbuf, 0,
     347                        &from.s, &fromlen);
    340348        if (len < 0)
    341349            break;
     
    411419}
    412420
    413 /*
    414  * Release a stream and clear the pointer to it
    415  */
    416 static void
    417 releaseStream (int s)
    418 {
    419     rtems_semaphore_obtain (tftp_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    420     free (tftpStreams[s]);
    421     tftpStreams[s] = NULL;
    422     rtems_semaphore_release (tftp_mutex);
    423 }
    424 
    425421static int rtems_tftp_evaluate_for_make(
    426422   const char                         *path __attribute__((unused)),       /* IN     */
     
    430426{
    431427  pathloc->node_access = NULL;
    432   rtems_set_errno_and_return_minus_one( EIO );
     428  pathloc->node_access_2 = NULL;
     429  rtems_set_errno_and_return_minus_one (EIO);
    433430}
    434431
     
    494491)
    495492{
    496     pathloc->handlers    = &rtems_tftp_handlers;
     493    tftpfs_info_t *fs;
     494    char          *cp;
     495
     496    /*
     497     * Get the file system info.
     498     */
     499    fs = tftpfs_info_pathloc (pathloc);
     500
     501    pathloc->handlers = &rtems_tftp_handlers;
    497502
    498503    /*
     
    501506     */
    502507    if (pathname[strlen(pathname)-1] == '/') {
    503         int isRelative = (pathloc->node_access != ROOT_NODE_ACCESS);
    504         char *cp;
    505 
    506         /*
    507          * Reject attempts to open() directories
    508          */
    509         if (flags & RTEMS_LIBIO_PERMS_RDWR)
    510             rtems_set_errno_and_return_minus_one( EISDIR );
    511         if (isRelative) {
    512             cp = malloc (strlen(pathloc->node_access)+strlen(pathname)+1);
    513             if (cp == NULL)
    514                 rtems_set_errno_and_return_minus_one( ENOMEM );
    515             strcpy (cp, pathloc->node_access);
    516             strcat (cp, pathname);
    517         }
    518         else {
    519             cp = strdup (pathname);
    520             if (cp == NULL)
    521                 rtems_set_errno_and_return_minus_one( ENOMEM );
    522         }
     508        int nal = 0;
     509        if (pathloc->node_access != ROOT_NODE_ACCESS (fs))
     510            nal = strlen(pathloc->node_access);
     511        cp = malloc(nal + pathnamelen + 1);
     512        if (cp == NULL)
     513            rtems_set_errno_and_return_minus_one(ENOMEM);
     514        if (nal)
     515            memcpy (cp, pathloc->node_access, nal);
     516        memcpy(cp + nal, pathname, pathnamelen);
     517        cp[nal + pathnamelen] = '\0';
    523518        fixPath (cp);
    524519        pathloc->node_access = cp;
    525         return 0;
    526     }
    527     if (pathloc->node_access != ROOT_NODE_ACCESS)
    528         pathloc->node_access = 0;
    529 
    530     /*
    531      * Reject it if it's not read-only or write-only.
    532      */
    533     flags &= RTEMS_LIBIO_PERMS_READ | RTEMS_LIBIO_PERMS_WRITE;
    534     if ((flags != RTEMS_LIBIO_PERMS_READ) && (flags != RTEMS_LIBIO_PERMS_WRITE) )
    535         rtems_set_errno_and_return_minus_one( EINVAL );
     520    }
     521    else {
     522        if (pathnamelen) {
     523            /*
     524             * Reject it if it's not read-only or write-only.
     525             */
     526            flags &= RTEMS_LIBIO_PERMS_READ | RTEMS_LIBIO_PERMS_WRITE;
     527            if ((flags != RTEMS_LIBIO_PERMS_READ)   \
     528                && (flags != RTEMS_LIBIO_PERMS_WRITE))
     529                rtems_set_errno_and_return_minus_one(EINVAL);
     530
     531            cp = malloc(pathnamelen + 1);
     532            if (cp == NULL)
     533                rtems_set_errno_and_return_minus_one(ENOMEM);
     534            memcpy(cp, pathname, pathnamelen);
     535            cp[pathnamelen] = '\0';
     536            fixPath (cp);
     537            pathloc->node_access_2 = cp;
     538        }
     539    }
     540
    536541    return 0;
    537542}
     
    547552)
    548553{
     554    tftpfs_info_t        *fs;
    549555    struct tftpStream    *tp;
    550556    int                  retryCount;
     
    560566
    561567    /*
     568     * Get the file system info.
     569     */
     570    fs = tftpfs_info_iop (iop);
     571   
     572    /*
    562573     * Extract the host name component
    563574     */
    564     cp2 = full_path_name;
    565     while (*cp2 == '/')
    566         cp2++;
    567     hostname = cp2;
    568     while (*cp2 != '/') {
    569         if (*cp2 == '\0')
    570             return ENOENT;
    571         cp2++;
    572     }
    573     *cp2++ = '\0';
     575    hostname = full_path_name;
     576    cp1 = strchr (full_path_name, ':');
     577    if (!cp1)
     578        hostname = "BOOTP_HOST";
     579    else {
     580        *cp1 = '\0';
     581        ++cp1;
     582    }
    574583
    575584    /*
     
    578587    if (strcmp (hostname, "BOOTP_HOST") == 0)
    579588        farAddress = rtems_bsdnet_bootp_server_address;
    580     else
    581         farAddress.s_addr = inet_addr (hostname);
    582     if ((farAddress.s_addr == INADDR_ANY) || (farAddress.s_addr == INADDR_BROADCAST))
     589    else if (inet_aton (hostname, &farAddress) == 0) {
     590        struct hostent *he = gethostbyname(hostname);
     591        if (he == NULL)
     592            return ENOENT;
     593        memcpy (&farAddress, he->h_addr, sizeof (farAddress));
     594    } else {
    583595        return ENOENT;
    584 
     596    }
     597   
    585598    /*
    586599     * Extract file pathname component
    587600     */
    588     while (*cp2 == '/')
    589         cp2++;
    590     if (strcmp (cp2, "BOOTP_FILE") == 0) {
    591         cp2 = rtems_bsdnet_bootp_boot_file_name;
    592         while (*cp2 == '/')
    593             cp2++;
    594     }
    595     if (*cp2 == '\0')
     601    if (strcmp (cp1, "BOOTP_FILE") == 0) {
     602        cp1 = rtems_bsdnet_bootp_boot_file_name;
     603    }
     604    if (*cp1 == '\0')
    596605        return ENOENT;
    597     remoteFilename = cp2;
     606    remoteFilename = cp1;
    598607    if (strlen (remoteFilename) > (TFTP_BUFSIZE - 10))
    599608        return ENOENT;
     
    602611     * Find a free stream
    603612     */
    604     sc = rtems_semaphore_obtain (tftp_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     613    sc = rtems_semaphore_obtain (fs->tftp_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    605614    if (sc != RTEMS_SUCCESSFUL)
    606615        return EBUSY;
    607     for (s = 0 ; s < nStreams ; s++) {
    608         if (tftpStreams[s] == NULL)
     616    for (s = 0 ; s < fs->nStreams ; s++) {
     617        if (fs->tftpStreams[s] == NULL)
    609618        break;
    610619    }
    611     if (s == nStreams) {
     620    if (s == fs->nStreams) {
    612621        /*
    613622         * Reallocate stream pointers
     
    616625        struct tftpStream **np;
    617626
    618         np = realloc (tftpStreams, ++nStreams * sizeof *tftpStreams);
     627        np = realloc (fs->tftpStreams, ++fs->nStreams * sizeof *fs->tftpStreams);
    619628        if (np == NULL) {
    620             rtems_semaphore_release (tftp_mutex);
     629            rtems_semaphore_release (fs->tftp_mutex);
    621630            return ENOMEM;
    622631        }
    623         tftpStreams = np;
    624     }
    625     tp = tftpStreams[s] = malloc (sizeof (struct tftpStream));
    626     rtems_semaphore_release (tftp_mutex);
     632        fs->tftpStreams = np;
     633    }
     634    tp = fs->tftpStreams[s] = malloc (sizeof (struct tftpStream));
     635    rtems_semaphore_release (fs->tftp_mutex);
    627636    if (tp == NULL)
    628637        return ENOMEM;
     
    634643     */
    635644    if ((tp->socket = socket (AF_INET, SOCK_DGRAM, 0)) < 0) {
    636         releaseStream (s);
     645        releaseStream (fs, s);
    637646        return ENOMEM;
    638647    }
     
    647656
    648657        tp->myAddress.sin_family = AF_INET;
    649         tp->myAddress.sin_port = htons (UDP_PORT_BASE + nStreams * try + s);
     658        tp->myAddress.sin_port = htons (UDP_PORT_BASE + fs->nStreams * try + s);
    650659        tp->myAddress.sin_addr.s_addr = htonl (INADDR_ANY);
    651660        if (bind (tp->socket, (struct sockaddr *)&tp->myAddress, sizeof tp->myAddress) >= 0)
    652661            break;
    653662        if (++retryCount == 10) {
    654             close (tp->socket);
    655             releaseStream (s);
     663            releaseStream (fs, s);
    656664            return EBUSY;
    657665        }
     
    698706                    (struct sockaddr *)&tp->farAddress,
    699707                    sizeof tp->farAddress) < 0) {
    700             close (tp->socket);
    701             releaseStream (s);
     708            releaseStream (fs, s);
    702709            return EIO;
    703710        }
     
    717724                tp->eof = (tp->nleft < TFTP_BUFSIZE);
    718725                if (sendAck (tp) != 0) {
    719                     close (tp->socket);
    720                     releaseStream (s);
     726                    releaseStream (fs, s);
    721727                    return EIO;
    722728                }
     
    732738            if (opcode == TFTP_OPCODE_ERROR) {
    733739                int e = tftpErrno (tp);
    734                 close (tp->socket);
    735                 releaseStream (s);
     740                releaseStream (fs, s);
    736741                return e;
    737742            }
     
    742747         */
    743748        if (++retryCount >= OPEN_RETRY_LIMIT) {
    744             close (tp->socket);
    745             releaseStream (s);
     749            releaseStream (fs, s);
    746750            return EIO;
    747751        }
     
    760764)
    761765{
    762     char *full_path_name;
    763     char *s1;
    764     int err;
    765 
    766     /*
    767      * Tack the `current directory' on to relative paths.
    768      * We know that the current directory ends in a / character.
    769      */
    770     if (*new_name == '/') {
    771         /*
    772          * Skip the TFTP filesystem prefix.
    773          */
    774         int len = strlen (TFTP_PATHNAME_PREFIX);
    775         if (strncmp (new_name, TFTP_PATHNAME_PREFIX, len))
    776             return ENOENT;
    777         new_name += len;
    778         s1 = "";
    779     }
     766    tftpfs_info_t *fs;
     767    const char    *device;
     768    char          *full_path_name;
     769    char          *na;
     770    char          *na2;
     771    int           dlen;
     772    int           nalen;
     773    int           na2len;
     774    int           sep1;
     775    int           err;
     776
     777    /*
     778     * Get the file system info.
     779     */
     780    fs = tftpfs_info_iop (iop);
     781   
     782    /*
     783     * Tack the prefix directory if one exists from the device name.
     784     */
     785    device =
     786      rtems_filesystem_mount_device (rtems_filesystem_location_mount (&iop->pathinfo));
     787    dlen = strlen (device);
     788    if (dlen == 0)
     789        rtems_set_errno_and_return_minus_one (ENOENT);
     790
     791    if (iop->pathinfo.node_access_2 == NULL)
     792        rtems_set_errno_and_return_minus_one (ENOENT);
     793
     794    if (iop->pathinfo.node_access != ROOT_NODE_ACCESS (fs)) {
     795        na = iop->pathinfo.node_access;
     796        nalen = strlen (na);
     797    }     
    780798    else {
    781         s1 = rtems_filesystem_current.node_access;
    782     }
    783     full_path_name = malloc (strlen (s1) + strlen (new_name) + 1);
     799        na = NULL;
     800        nalen = 0;
     801    }
     802
     803    na2 = iop->pathinfo.node_access_2;
     804   
     805    na2len = strlen (na2);
     806
     807    if (nalen) {
     808      sep1 = 1;
     809        if (na[nalen] == '/') {
     810            sep1 = 0;
     811            if (na2[0] == '/')
     812                ++na2;
     813        }
     814        else {
     815            if (na2[0] == '/')
     816                sep1 = 0;
     817            else
     818                sep1 = 1;
     819        }
     820    }
     821    else
     822      sep1 = 0;
     823
     824    full_path_name = malloc (dlen + nalen + sep1 + na2len + 1);
    784825    if (full_path_name == NULL)
    785         return ENOMEM;
    786     strcpy (full_path_name, s1);
    787     strcat (full_path_name, new_name);
     826        rtems_set_errno_and_return_minus_one(ENOMEM);
     827    strcpy (full_path_name, device);
     828    if (nalen)
     829      strcat (full_path_name, na);
     830    if (sep1)
     831        strcat (full_path_name, "/");
     832    strcat (full_path_name, na2);
    788833    fixPath (full_path_name);
     834
     835    if (fs->flags & TFTPFS_VERBOSE)
     836      printf ("TFTPFS: %s %s %s -> %s\n", device, na, na2, full_path_name);
     837
    789838    err = rtems_tftp_open_worker (iop, full_path_name, flags, mode);
    790839    free (full_path_name);
    791     return err;
     840    rtems_set_errno_and_return_minus_one(err);
    792841}
    793842
     
    806855    int               nwant;
    807856
    808 
     857    if (!tp)
     858        rtems_set_errno_and_return_minus_one( EIO );
     859   
    809860    /*
    810861     * Read till user request is satisfied or EOF is reached
     
    842893                 && (ntohs (tp->pkbuf.tftpDATA.blocknum) == nextBlock)) {
    843894                    tp->nused = 0;
    844                     tp->nleft = len - 2 * sizeof (uint16_t  );
     895                    tp->nleft = len - 2 * sizeof (uint16_t);
    845896                    tp->eof = (tp->nleft < TFTP_BUFSIZE);
    846897                    tp->blocknum++;
    847898                    if (sendAck (tp) != 0)
    848                         rtems_set_errno_and_return_minus_one( EIO );
     899                        rtems_set_errno_and_return_minus_one (EIO);
    849900                    break;
    850901                }
    851902                if (opcode == TFTP_OPCODE_ERROR)
    852                         rtems_set_errno_and_return_minus_one( tftpErrno (tp) );
     903                    rtems_set_errno_and_return_minus_one (tftpErrno (tp));
    853904            }
    854905
     
    857908             */
    858909            if (++retryCount == IO_RETRY_LIMIT)
    859                 rtems_set_errno_and_return_minus_one( EIO );
     910                rtems_set_errno_and_return_minus_one (EIO);
    860911            if (sendAck (tp) != 0)
    861                 rtems_set_errno_and_return_minus_one( EIO );
     912                rtems_set_errno_and_return_minus_one (EIO);
    862913        }
    863914    }
     
    868919 * Flush a write buffer and wait for acknowledgement
    869920 */
    870 static int rtems_tftp_flush ( struct tftpStream *tp )
     921static int rtems_tftp_flush (struct tftpStream *tp)
    871922{
    872923    int wlen, rlen;
     
    918969)
    919970{
    920     struct tftpStream *tp = iop->data1;;
    921 
     971    tftpfs_info_t     *fs;
     972    struct tftpStream *tp = iop->data1;
     973    int                e = 0;
     974   
     975    /*
     976     * Get the file system info.
     977     */
     978    fs = tftpfs_info_iop (iop);
     979   
     980    if (!tp)
     981        rtems_set_errno_and_return_minus_one (EIO);
     982   
    922983    if (tp->writing)
    923         rtems_tftp_flush (tp);
     984        e = rtems_tftp_flush (tp);
    924985    if (!tp->eof && !tp->firstReply) {
    925986        /*
     
    931992        rtems_task_wake_after (1 + ticksPerSecond / 10);
    932993    }
    933     close (tp->socket);
    934     releaseStream (iop->data0);
    935     return RTEMS_SUCCESSFUL;
     994    releaseStream (fs, iop->data0);
     995    rtems_set_errno_and_return_minus_one (e);
    936996}
    937997
     
    9501010     */
    9511011    if (!tp->writing)
    952         return EIO;
    953 
     1012        rtems_set_errno_and_return_minus_one (EIO);
    9541013
    9551014    /*
     
    9981057)
    9991058{
     1059    tftpfs_info_t *fs = tftpfs_info_pathloc (pathloc);
    10001060    if ((pathloc->node_access == NULL)
    1001      || (pathloc->node_access == ROOT_NODE_ACCESS))
     1061     || (pathloc->node_access_2 != NULL)
     1062        || (pathloc->node_access == ROOT_NODE_ACCESS (fs)))
    10021063        return RTEMS_FILESYSTEM_MEMORY_FILE;
    10031064    return RTEMS_FILESYSTEM_DIRECTORY;
     
    10081069)
    10091070{
    1010     if (pathloc->node_access && (pathloc->node_access != ROOT_NODE_ACCESS)) {
     1071    tftpfs_info_t *fs = tftpfs_info_pathloc (pathloc);
     1072    if (pathloc->node_access && \
     1073        (pathloc->node_access != ROOT_NODE_ACCESS (fs))) {
    10111074        free (pathloc->node_access);
    10121075        pathloc->node_access = NULL;
     1076    }
     1077    if (pathloc->node_access_2) {
     1078        free (pathloc->node_access_2);
     1079        pathloc->node_access_2 = NULL;
    10131080    }
    10141081    return 0;
     
    10261093    rtems_tftp_free_node_info,       /* freenodinfo */
    10271094    NULL,                            /* mount */
    1028     rtems_tftp_mount_me,             /* initialize */
     1095    rtems_tftpfs_initialize,         /* initialize */
    10291096    NULL,                            /* unmount */
    1030     NULL,                            /* fsunmount */
     1097    rtems_tftpfs_shutdown,           /* fsunmount */
    10311098    NULL,                            /* utime, */
    10321099    NULL,                            /* evaluate_link */
     
    10361103
    10371104rtems_filesystem_file_handlers_r rtems_tftp_handlers = {
    1038     rtems_tftp_open,   /* open */
    1039     rtems_tftp_close,  /* close */
    1040     rtems_tftp_read,   /* read */
    1041     rtems_tftp_write,  /* write */
    1042     NULL,              /* ioctl */
    1043     NULL,              /* lseek */
    1044     NULL,              /* fstat */
    1045     NULL,              /* fchmod */
     1105    rtems_tftp_open,      /* open */
     1106    rtems_tftp_close,     /* close */
     1107    rtems_tftp_read,      /* read */
     1108    rtems_tftp_write,     /* write */
     1109    NULL,                 /* ioctl */
     1110    NULL,                 /* lseek */
     1111    NULL,                 /* fstat */
     1112    NULL,                 /* fchmod */
    10461113    rtems_tftp_ftruncate, /* ftruncate */
    1047     NULL,              /* fpathconf */
    1048     NULL,              /* fsync */
    1049     NULL,              /* fdatasync */
    1050     NULL,              /* fcntl */
    1051     NULL               /* rmnod */
     1114    NULL,                 /* fpathconf */
     1115    NULL,                 /* fsync */
     1116    NULL,                 /* fdatasync */
     1117    NULL,                 /* fcntl */
     1118    NULL                  /* rmnod */
    10521119};
  • cpukit/libnetworking/rtems/ftpfs.h

    reea48e2f r29e92b0  
    100100
    101101/**
    102  * Creates the mount point @a mount_point and mounts the FTP file system.
    103  *
    104  * If @a mount_point is @c NULL the default mount point
    105  * @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT will be used.
    106  *
    107  * It is mounted with read and write access.
    108  */
    109 rtems_status_code rtems_ftpfs_mount( const char *mount_point);
    110 
    111 /**
    112102 * Returns in @a verbose if the verbose mode is enabled or disabled for the
    113103 * file system at @a mount_point.
     
    161151/**
    162152 * Creates the default mount point @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT and
    163  * mounts the FTP file system.
     153 * mounts the FTP file system. Do not call directly, use mount.xs
    164154 *
    165155 * It is mounted with read and write access.
    166  *
    167  * On success, zero is returned.  On error, -1 is returned.
    168  *
    169  * @deprecated Use rtems_ftpfs_mount() instead.
    170156 */
    171 int rtems_bsdnet_initialize_ftp_filesystem( void);
     157int rtems_ftpfs_initialize(rtems_filesystem_mount_table_entry_t *e,
     158                           const void                           *d);
    172159
    173160#ifdef __cplusplus
  • cpukit/libnetworking/rtems/tftp.h

    reea48e2f r29e92b0  
    2121 *         fd = open ("/TFTP/hostname/bootfiles/image", O_RDONLY);
    2222 *
    23  * The `hostname' must be four dot-separated decimal values.
     23 * The 'TFTP' is the mount path and the `hostname' must be four dot-separated
     24 * decimal values.
    2425 */
    2526
     
    3233
    3334#include <rtems/libio.h>
     35
     36/*
     37 * Filesystem Mount table entry.
     38 */
     39int rtems_tftpfs_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
    3440
    3541/*
  • cpukit/sapi/include/confdefs.h

    reea48e2f r29e92b0  
    175175#endif
    176176
     177/*
     178 *  Filesystems and Mount Table Configuration.
     179 *
     180 *  Defines to control the file system:
     181 *
     182 *   CONFIGURE_APPLICATION_DISABLE_FILESYSTEM:
     183 *     Disable the RTEMS filesystems. You get an empty DEVFS.
     184 *
     185 *   CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM:
     186 *     Use the DEVFS as the root file system. Limited functions are
     187 *     provided when this is used.
     188 *
     189 *   CONFIGURE_FILESYSTEM_ALL:
     190 *     Add file filesystems to the default filesystem table.
     191 *
     192 *   List of available file systems. You can define as many as you like:
     193 *     CONFIGURE_FILESYSTEM_miniIMFS - MiniIMFS, use DEVFS now
     194 *     CONFIGURE_FILESYSTEM_IMFS     - In Memory File System (IMFS)
     195 *     CONFIGURE_FILESYSTEM_DEVFS    - Device File System (DSVFS)
     196 *     CONFIGURE_FILESYSTEM_TFTPFS   - TFTP File System, networking enabled
     197 *     CONFIGURE_FILESYSTEM_FTPFS    - FTP File System, networking enabled
     198 *     CONFIGURE_FILESYSTEM_NFSFS    - Network File System, networking enabled
     199 *     CONFIGURE_FILESYSTEM_DOSFS    - DOS File System, uses libblock
     200 *     CONFIGURE_FILESYSTEM_RFS      - RTEMS File System (RFS), uses libblock
     201 *
     202 *   Combinations:
     203 *
     204 *    - If nothing is defined the base file system is the IMFS.
     205 *
     206 *    - If CONFIGURE_APPLICATION_DISABLE_FILESYSTEM is defined all filesystem
     207 *      are disabled by force and an empty DEVFS is created.
     208 *
     209 *    - If CONFIGURE_USE_DEV_AS_BASE_FILESYSTEM is defined all filesystem
     210 *      are disabled by force and DEVFS is defined.
     211 */
     212
    177213#ifdef CONFIGURE_INIT
    178   #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
    179     #if defined(RTEMS_COVERAGE)
    180       uint32_t rtems_device_table_size = 0;
    181     #endif
     214
     215  /*
     216   * Include all file systems. Do this before checking if the filesystem has
     217   * been disabled.
     218   */
     219  #ifdef CONFIGURE_FILESYSTEM_ALL
     220    #define CONFIGURE_FILESYSTEM_miniIMFS
     221    #define CONFIGURE_FILESYSTEM_IMFS
     222    #define CONFIGURE_FILESYSTEM_DEVFS
     223    #define CONFIGURE_FILESYSTEM_TFTPFS
     224    #define CONFIGURE_FILESYSTEM_FTPFS
     225    #define CONFIGURE_FILESYSTEM_NFSFS
     226    #define CONFIGURE_FILESYSTEM_DOSFS
     227    #define CONFIGURE_FILESYSTEM_RFS
     228  #endif
     229
     230  /*
     231   * If disabling the file system undef everything. If DEVFS as the base
     232   * filesystem undefine all other filesystems because you cannot mount other
     233   * filesystems.
     234   */
     235  #if defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) || \
     236      defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
     237    #if defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM)
     238      #undef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
     239    #endif
     240    #undef CONFIGURE_FILESYSTEM_miniIMFS
     241    #undef CONFIGURE_FILESYSTEM_IMFS
     242    #undef CONFIGURE_FILESYSTEM_DEVFS
     243    #undef CONFIGURE_FILESYSTEM_TFTPFS
     244    #undef CONFIGURE_FILESYSTEM_FTPFS
     245    #undef CONFIGURE_FILESYSTEM_NFSFS
     246    #undef CONFIGURE_FILESYSTEM_DOSFS
     247    #undef CONFIGURE_FILESYSTEM_RFS
     248  #endif
     249
     250  /*
     251   * If the base filesystem is DEVFS define it else define IMFS.
     252   * We will have either DEVFS or IMFS defined after this.
     253   */
     254  #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) && \
     255      !defined(CONFIGURE_FILESYSTEM_DEVFS)
     256    #define CONFIGURE_FILESYSTEM_DEVFS
     257  #elif !defined(CONFIGURE_FILESYSTEM_IMFS)
     258    #define CONFIGURE_FILESYSTEM_IMFS
     259  #endif
     260
     261#endif
     262
     263/**
     264 * IMFS
     265 */
     266#include <rtems/imfs.h>
     267
     268/**
     269 *  This specifies the number of bytes per block for files within the IMFS.
     270 *  There are a maximum number of blocks per file so this dictates the maximum
     271 *  size of a file.  This has to be balanced with the unused portion of each
     272 *  block that might be wasted.
     273 */
     274#ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
     275  #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \
     276                    IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK
     277#endif
     278
     279#ifdef CONFIGURE_INIT
     280  int imfs_rq_memfile_bytes_per_block = CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK;
     281#endif /* CONFIGURE_INIT */
     282
     283/**
     284 *  This defines the miniIMFS file system table entry.
     285 */
     286#if !defined(CONFIGURE_FILESYSTEM_ENTRY_miniIMFS) && \
     287    defined(CONFIGURE_FILESYSTEM_miniIMFS)
     288#define CONFIGURE_FILESYSTEM_ENTRY_miniIMFS { "mimfs", miniIMFS_initialize }
     289#endif
     290
     291/**
     292 *  This defines the IMFS file system table entry.
     293 */
     294#if !defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) && \
     295    defined(CONFIGURE_FILESYSTEM_IMFS)
     296#define CONFIGURE_FILESYSTEM_ENTRY_IMFS { "imfs", IMFS_initialize }
     297#endif
     298
     299/**
     300 * DEVFS
     301 */
     302#if !defined(CONFIGURE_FILESYSTEM_ENTRY_DEVFS) && \
     303    defined(CONFIGURE_FILESYSTEM_DEVFS)
     304#include <rtems/devfs.h>
     305#define CONFIGURE_FILESYSTEM_ENTRY_DEVFS { "devfs", devFS_initialize }
     306#endif
     307
     308#ifdef RTEMS_NETWORKING
     309  /**
     310   * FTPFS
     311   */
     312  #if !defined(CONFIGURE_FILESYSTEM_ENTRY_FTPFS) && \
     313      defined(CONFIGURE_FILESYSTEM_FTPFS)
     314    #include <rtems/ftpfs.h>
     315    #define CONFIGURE_FILESYSTEM_ENTRY_FTPFS { "ftpfs", rtems_ftpfs_initialize }
     316  #endif
     317
     318  /**
     319   * TFTPFS
     320   */
     321  #if !defined(CONFIGURE_FILESYSTEM_ENTRY_TFTPFS) && \
     322      defined(CONFIGURE_FILESYSTEM_TFTPFS)
     323    #include <rtems/tftp.h>
     324    #define CONFIGURE_FILESYSTEM_ENTRY_TFTPFS { "tftpfs", rtems_tftpfs_initialize }
     325  #endif
     326
     327  /**
     328   * NFSFS
     329   */
     330  #if !defined(CONFIGURE_FILESYSTEM_ENTRY_NFSFS) && \
     331      defined(CONFIGURE_FILESYSTEM_NFSFS)
     332    #include <librtemsNfs.h>
     333    #define CONFIGURE_FILESYSTEM_ENTRY_NFSFS { "nfs", rtems_nfsfs_initialize }
     334  #endif
     335#endif
     336
     337/**
     338 * DOSFS
     339 */
     340#if !defined(CONFIGURE_FILESYSTEM_ENTRY_DOSFS) && \
     341    defined(CONFIGURE_FILESYSTEM_DOSFS)
     342  #include <rtems/dosfs.h>
     343  #define CONFIGURE_FILESYSTEM_ENTRY_DOSFS { "dosfs", rtems_dosfs_initialize }
     344#endif
     345
     346/**
     347 * RFS
     348 */
     349#if !defined(CONFIGURE_FILESYSTEM_ENTRY_RFS) && \
     350    defined(CONFIGURE_FILESYSTEM_RFS)
     351  #include <rtems/rtems-rfs.h>
     352  #define CONFIGURE_FILESYSTEM_ENTRY_RFS { "rfs", rtems_rfs_rtems_initialise }
     353#endif
     354
     355#ifdef CONFIGURE_INIT
     356
     357  /*
     358   *  DEVFS variables.
     359   */
     360  #if defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) && !defined(RTEMS_COVERAGE)
    182361    #define CONFIGURE_MEMORY_FOR_DEVFS  0
    183   #elif defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
     362  #elif defined(CONFIGURE_FILESYSTEM_DEVFS)
    184363    #ifndef CONFIGURE_MAXIMUM_DEVICES
    185364      #define CONFIGURE_MAXIMUM_DEVICES 4
     
    196375    #define CONFIGURE_MEMORY_FOR_DEVFS  0
    197376  #endif
    198 #endif
    199 
    200 /*
    201  *  Mount Table Configuration
    202  */
    203 #include <rtems/imfs.h>
    204 
    205 /**
    206  *  This specifies the number of bytes per block for files within
    207  *  the IMFS.  There are a maximum number of blocks per file so
    208  *  this dictates the maximum size of a file.  This has to be balanced
    209  *  with the unused portion of each block that might be wasted.
    210  */
    211 #ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
    212   #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \
    213                     IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK
    214 #endif
    215 #ifdef CONFIGURE_INIT
    216   int imfs_rq_memfile_bytes_per_block = CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK;
    217 #endif /* CONFIGURE_INIT */
    218 
    219 #ifdef CONFIGURE_INIT
     377
     378  /**
     379   * Table termination record.
     380   */
     381  #define CONFIGURE_FILESYSTEM_NULL { NULL, NULL }
     382
     383  /**
     384   * The default file system table. Must be terminated with the NULL entry if
     385   * you provide your own.
     386   */
     387  #ifndef CONFIGURE_HAS_OWN_FILESYSTEM_TABLE
     388    const rtems_filesystem_table_t configuration_filesystem_table[] = {
     389      #if defined(CONFIGURE_FILESYSTEM_miniIMFS) && \
     390          defined(CONFIGURE_FILESYSTEM_ENTRY_miniIMFS)
     391        CONFIGURE_FILESYSTEM_ENTRY_miniIMFS,
     392      #endif
     393      #if defined(CONFIGURE_FILESYSTEM_IMFS) && \
     394          defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS)
     395        CONFIGURE_FILESYSTEM_ENTRY_IMFS,
     396      #endif
     397      #if defined(CONFIGURE_FILESYSTEM_DEVFS) && \
     398          defined(CONFIGURE_FILESYSTEM_ENTRY_DEVFS)
     399        CONFIGURE_FILESYSTEM_ENTRY_DEVFS,
     400      #endif
     401      #if defined(CONFIGURE_FILESYSTEM_TFTPFS) && \
     402          defined(CONFIGURE_FILESYSTEM_ENTRY_TFTPFS)
     403        CONFIGURE_FILESYSTEM_ENTRY_TFTPFS,
     404      #endif
     405      #if defined(CONFIGURE_FILESYSTEM_FTPFS) && \
     406          defined(CONFIGURE_FILESYSTEM_ENTRY_FTPFS)
     407        CONFIGURE_FILESYSTEM_ENTRY_FTPFS,
     408      #endif
     409      #if defined(CONFIGURE_FILESYSTEM_NFSFS) && \
     410          defined(CONFIGURE_FILESYSTEM_ENTRY_NFSFS)
     411        CONFIGURE_FILESYSTEM_ENTRY_NFSFS,
     412      #endif
     413      #if defined(CONFIGURE_FILESYSTEM_DOSFS) && \
     414          defined(CONFIGURE_FILESYSTEM_ENTRY_DOSFS)
     415        CONFIGURE_FILESYSTEM_ENTRY_DOSFS,
     416      #endif
     417      #if defined(CONFIGURE_FILESYSTEM_RFS) && \
     418          defined(CONFIGURE_FILESYSTEM_ENTRY_RFS)
     419        CONFIGURE_FILESYSTEM_ENTRY_RFS,
     420      #endif
     421      CONFIGURE_FILESYSTEM_NULL
     422    };
     423  #endif
     424
    220425  /**
    221426   *  This disables the inclusion of pipe support in the full IMFS.
     
    235440    const rtems_filesystem_mount_table_t configuration_mount_table = {
    236441      #ifdef CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
    237         &IMFS_ops,
     442        "imfs",
    238443      #elif defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
    239         &devFS_ops,
     444        "devfs",
    240445      #else  /* using miniIMFS as base filesystem */
    241         &miniIMFS_ops,
     446        "mimfs",
    242447      #endif
    243448      RTEMS_FILESYSTEM_READ_WRITE,
     
    250455    const int rtems_filesystem_mount_table_size = 1;
    251456  #endif
     457
    252458#endif
    253459
Note: See TracChangeset for help on using the changeset viewer.