diff options
author | Chris Johns <chrisj@rtems.org> | 2010-05-31 13:56:37 +0000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2010-05-31 13:56:37 +0000 |
commit | 29e92b090c8bc35745aa5c89231ce806bcb11e57 (patch) | |
tree | a253c33b1654609acfbd5216797976dce3b0748f /cpukit/libfs/src/nfsclient | |
parent | 2010-05-31 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff) | |
download | rtems-29e92b090c8bc35745aa5c89231ce806bcb11e57.tar.bz2 |
2010-05-31 Chris Johns <chrisj@rtems.org>
* libcsupport/Makefile.am: Add mount-mgr.c.
* libcsupport/src/mount-mgr.c: New.
* include/rtems/fs.h: Added rtems_filesystem_location_mount.
* libcsupport/include/rtems/libio.h, libcsupport/src/mount.c: New
mount interface. It is similar to Linux.
* libcsupport/include/rtems/libio_.h: Remove the
init_fs_mount_table call.
* libcsupport/src/base_fs.c: Remove init_fs_mount_table_call. Use
the new mount call. Remove setting the root node in the global
pathloc. Mount does this now.
* libcsupport/src/privateenv.c: Remove the hack to set the root
mount table entry in the environment.
* libcsupport/src/unmount.cL Free the target string.
* libblock/src/bdpart-mount.c: New mount API.
* libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_init.c,
libfs/src/dosfs/dosfs.h, libfs/src/dosfs/msdos.h,
libfs/src/dosfs/msdos_init.c, libfs/src/imfs/imfs.h,
libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_init.c,
libfs/src/imfs/miniimfs_init.c,
libfs/src/nfsclient/src/librtemsNfs.h,
libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs.h,
libnetworking/lib/ftpfs.c, libnetworking/rtems/ftpfs.h,
libnetworking/rtems/tftp.h: New mount_h API.
* libfs/src/devfs/devfs_eval.c: Local include of extern ops.
* libfs/src/nfsclient/src/nfs.c: New mount API. Removed the mount
me call and fixed the initialisation to happen when mounting.
* libmisc/Makefile.am, libmisc/shell/shellconfig.h: Remove mount
filesystem files.
* libmisc/fsmount/fsmount.c, libmisc/fsmount/fsmount.h: Updated to
the new mount table values.
* libmisc/shell/main_mount_ftp.c,
libmisc/shell/main_mount_msdos.c, libmisc/shell/main_mount_rfs.c,
libmisc/shell/main_mount_tftp.c: Removed.
* libmisc/shell/main_mount.c: Use the new mount API. Also access
the file system table for the file system types.
* libnetworking/lib/tftpDriver.c: Updated to the new mount
API. Fixed to allow mounting from any mount point. Also can now
have more than file system mounted.
* sapi/include/confdefs.h: Add file system configuration support.
Diffstat (limited to 'cpukit/libfs/src/nfsclient')
-rw-r--r-- | cpukit/libfs/src/nfsclient/src/librtemsNfs.h | 35 | ||||
-rw-r--r-- | cpukit/libfs/src/nfsclient/src/nfs.c | 55 |
2 files changed, 57 insertions, 33 deletions
diff --git a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h b/cpukit/libfs/src/nfsclient/src/librtemsNfs.h index 8afdb6c60f..01ef9a3a76 100644 --- a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h +++ b/cpukit/libfs/src/nfsclient/src/librtemsNfs.h @@ -70,6 +70,10 @@ #include <netinet/in.h> #include <arpa/inet.h> +#ifdef __cplusplus +extern "C" { +#endif + /* RPCIO driver interface. * If you need RPCIO for other purposes than NFS * you may want to include <rpcio.h> @@ -82,7 +86,9 @@ */ extern rtems_task_priority rpciodPriority; -/* Initialize the driver +/* Initialize the driver. + * + * Note, called in nfsfs initialise when mount is called. * * RETURNS: 0 on success, -1 on failure */ @@ -103,6 +109,8 @@ rpcUdpCleanup(void); * NOTE: The RPCIO driver must have been initialized prior to * calling this. * + * Note, called in nfsfs initialise when mount is called with defaults. + * * ARGS: depth of the small and big * transaction pools, i.e. how * many transactions (buffers) @@ -131,22 +139,12 @@ nfsCleanup(void); int nfsMountsShow(FILE *f); -/* convenience wrapper - * - * NOTE: this routine calls NON-REENTRANT - * gethostbyname() if the host is - * not in 'dot' notation. - */ -int -nfsMount(char *uidhost, char *path, char *mntpoint); - -/* Alternatively, a pointer to the filesystem operations - * table can be supplied to the native RTEMS (NON-POSIX!) - * 'mount()' call. - * Supply a "<host.in.ip.dot.notation>:<path>" string - * for 'device' argument to 'mount()'. +/* + * Filesystem mount table mount handler. Do not call, use the mount call. */ -extern struct _rtems_filesystem_operations_table nfs_fs_ops; +int +rtems_nfsfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data); /* A utility routine to find the path leading to a * rtems_filesystem_location_info_t node. @@ -174,4 +172,9 @@ nfsSetTimeout(uint32_t timeout_ms); /* Read current timeout (in milliseconds) */ uint32_t nfsGetTimeout(void); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c b/cpukit/libfs/src/nfsclient/src/nfs.c index 4444848f0e..de902cbbad 100644 --- a/cpukit/libfs/src/nfsclient/src/nfs.c +++ b/cpukit/libfs/src/nfsclient/src/nfs.c @@ -4,6 +4,8 @@ /* Author: Till Straumann <strauman@slac.stanford.edu> 2002 */ +/* Hacked on by others. */ + /* * Authorship * ---------- @@ -1193,8 +1195,7 @@ updateAttr(NfsNode node, int force) } /* - * IP address helper. Note that we avoid - * gethostbyname() since it's not reentrant. + * IP address helper. * * initialize a sockaddr_in from a * [<uid>'.'<gid>'@']<host>':'<path>" string and let @@ -1211,7 +1212,8 @@ buildIpAddr(u_long *puid, u_long *pgid, char **pHost, struct sockaddr_in *psa, char **pPath) { -char host[30]; +struct hostent *h; +char host[64]; char *chpt = *pPath; char *path; int len; @@ -1238,7 +1240,7 @@ int len; /* split the device name which is in the form * - * <host_ip> ':' <path> + * <host> ':' <path> * * into its components using a local buffer */ @@ -1254,11 +1256,19 @@ int len; strncpy(host, chpt, len); host[len]=0; - if ( ! inet_pton(AF_INET, host, &psa->sin_addr) ) { - errno = ENXIO; + /* BEGIN OF NON-THREAD SAFE REGION */ + + h = gethostbyname(host); + + if ( !h ) { + errno = EINVAL; return -1; } + memcpy(&psa->sin_addr, h->h_addr, sizeof (struct in_addr)); + + /* END OF NON-THREAD SAFE REGION */ + psa->sin_family = AF_INET; psa->sin_port = 0; *pPath = path; @@ -1898,9 +1908,9 @@ struct rtems_filesystem_mount_table_entry_tt { #endif -/* This op is called as the last step of mounting this FS */ -STATIC int nfs_fsmount_me( - rtems_filesystem_mount_table_entry_t *mt_entry +int rtems_nfsfs_initialize( + rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data ) { char *host; @@ -1917,11 +1927,20 @@ RpcUdpServer nfsServer = 0; int e = -1; char *path = mt_entry->dev; + if (rpcUdpInit () < 0) { + fprintf (stderr, "error: initialising RPC\n"); + return -1; + } + + nfsInit(0, 0); +#if 0 + printf("Trying to mount %s on %s\n",path,mntpoint); +#endif + if ( buildIpAddr(&uid, &gid, &host, &saddr, &path) ) return -1; - #ifdef NFS_V2_PORT /* if the portmapper fails, retry a fixed port */ for (retry = 1, saddr.sin_port = 0, stat = RPC_FAILED; @@ -2460,7 +2479,7 @@ struct _rtems_filesystem_operations_table nfs_fs_ops = { nfs_chown, /* OPTIONAL; may be NULL */ nfs_freenode, /* OPTIONAL; may be NULL; (release node_access) */ nfs_mount, /* OPTIONAL; may be NULL */ - nfs_fsmount_me, /* OPTIONAL; may be NULL -- but this makes NO SENSE */ + rtems_nfsfs_initialize, /* OPTIONAL; may be NULL -- not used anymore */ nfs_unmount, /* OPTIONAL; may be NULL */ nfs_fsunmount_me, /* OPTIONAL; may be NULL */ nfs_utime, /* OPTIONAL; may be NULL */ @@ -3228,6 +3247,8 @@ Nfs nfs; return 0; } +#if 0 +CCJ_REMOVE_MOUNT /* convenience wrapper * * NOTE: this routine calls NON-REENTRANT @@ -3237,7 +3258,6 @@ Nfs nfs; int nfsMount(char *uidhost, char *path, char *mntpoint) { -rtems_filesystem_mount_table_entry_t *mtab; struct stat st; int devl; char *host; @@ -3310,11 +3330,11 @@ char *dev = 0; printf("Trying to mount %s on %s\n",dev,mntpoint); - if (mount(&mtab, - &nfs_fs_ops, - RTEMS_FILESYSTEM_READ_WRITE, - dev, - mntpoint)) { + if (mount(dev, + mntpoint, + "nfs", + RTEMS_FILESYSTEM_READ_WRITE, + NULL)) { perror("nfsMount - mount"); goto cleanup; } @@ -3325,6 +3345,7 @@ cleanup: free(dev); return rval; } +#endif /* HERE COMES A REALLY UGLY HACK */ |