summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/nfsclient/src/nfs.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2010-05-31 13:56:37 +0000
committerChris Johns <chrisj@rtems.org>2010-05-31 13:56:37 +0000
commit29e92b090c8bc35745aa5c89231ce806bcb11e57 (patch)
treea253c33b1654609acfbd5216797976dce3b0748f /cpukit/libfs/src/nfsclient/src/nfs.c
parent2010-05-31 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff)
downloadrtems-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/src/nfs.c')
-rw-r--r--cpukit/libfs/src/nfsclient/src/nfs.c55
1 files changed, 38 insertions, 17 deletions
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 */