Browse Source

NFS update

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4532 7fd9a85b-ad96-42d3-883c-3090e2eb8679
sbg
patacongo 13 years ago
parent
commit
fb9d418f66
  1. 6
      apps/examples/nxconsole/nxcon_internal.h
  2. 33
      apps/examples/nxconsole/nxcon_main.c
  3. 12
      nuttx/fs/nfs/nfs.h
  4. 32
      nuttx/fs/nfs/nfs_args.h
  5. 24
      nuttx/fs/nfs/nfs_mount.h
  6. 30
      nuttx/fs/nfs/nfs_proto.h
  7. 10
      nuttx/fs/nfs/nfs_socket.c
  8. 6
      nuttx/fs/nfs/nfs_socket.h
  9. 15
      nuttx/fs/nfs/nfs_vfsops.c
  10. 2
      nuttx/fs/nfs/rpc.h
  11. 28
      nuttx/fs/nfs/rpc_clnt.c
  12. 4
      nuttx/graphics/nxbe/nxbe_bitmap.c
  13. 3
      nuttx/graphics/nxconsole/nxcon_font.c
  14. 2
      nuttx/sched/os_start.c

6
apps/examples/nxconsole/nxcon_internal.h

@ -173,6 +173,12 @@
# endif # endif
#endif #endif
/* Graphics Device */
#ifndef CONFIG_EXAMPLES_NXCON_DEVNO
# define CONFIG_EXAMPLES_NXCON_DEVNO 0
#endif
/* NX Console Device */ /* NX Console Device */
#ifndef CONFIG_EXAMPLES_NXCON_MINOR #ifndef CONFIG_EXAMPLES_NXCON_MINOR

33
apps/examples/nxconsole/nxcon_main.c

@ -321,10 +321,14 @@ static int nxcon_initialize(void)
int MAIN_NAME(int argc, char **argv) int MAIN_NAME(int argc, char **argv)
{ {
int exitcode = EXIT_FAILURE; int exitcode = EXIT_FAILURE;
#if 0 /* Don't re-direct... too hard to debug */
int fd;
#else
FILE *outstream;
#endif
nxgl_mxpixel_t color; nxgl_mxpixel_t color;
int ndx; int ndx;
int ret; int ret;
int fd;
/* Reset all global data */ /* Reset all global data */
@ -432,6 +436,7 @@ int MAIN_NAME(int argc, char **argv)
/* Open the driver */ /* Open the driver */
#if 0 /* Don't re-direct... too hard to debug */
fd = open(CONFIG_EXAMPLES_NXCON_DEVNAME, O_WRONLY); fd = open(CONFIG_EXAMPLES_NXCON_DEVNAME, O_WRONLY);
if (fd < 0) if (fd < 0)
{ {
@ -440,7 +445,10 @@ int MAIN_NAME(int argc, char **argv)
goto errout_with_driver; goto errout_with_driver;
} }
/* Now re-direct stdout and stderr so that they use the NX console driver */ /* Now re-direct stdout and stderr so that they use the NX console driver.
* If debug is enabled, then perform the test using only stderr so that we
* can still get debug output on stdout.
*/
(void)dup2(fd, 1); (void)dup2(fd, 1);
(void)dup2(fd, 2); (void)dup2(fd, 2);
@ -448,6 +456,17 @@ int MAIN_NAME(int argc, char **argv)
/* And we can close our original driver fd */ /* And we can close our original driver fd */
close(fd); close(fd);
#else
/* Open the Console driver as a write-only stream */
outstream = fopen(CONFIG_EXAMPLES_NXCON_DEVNAME, "w");
if (!outstream)
{
message(MAIN_NAME_STRING ": fopen %s read-only failed: %d\n",
CONFIG_EXAMPLES_NXCON_DEVNAME, errno);
goto errout_with_driver;
}
#endif
/* Test Loop **************************************************************/ /* Test Loop **************************************************************/
/* Now loop, adding text to the NX console */ /* Now loop, adding text to the NX console */
@ -461,7 +480,13 @@ int MAIN_NAME(int argc, char **argv)
/* Give another line of text to the NX console.*/ /* Give another line of text to the NX console.*/
#if 0 /* Don't re-direct... too hard to debug */
printf(g_nxcon_msg[ndx]); printf(g_nxcon_msg[ndx]);
fflush(stdout);
#else
fprintf(outstream, g_nxcon_msg[ndx]);
fflush(outstream);
#endif
if (++ndx >= NCON_MSG_NLINES) if (++ndx >= NCON_MSG_NLINES)
{ {
#ifdef CONFIG_NSH_BUILTIN_APPS #ifdef CONFIG_NSH_BUILTIN_APPS
@ -481,6 +506,10 @@ int MAIN_NAME(int argc, char **argv)
/* Clean-up and Error Exits ***********************************************/ /* Clean-up and Error Exits ***********************************************/
#if 1 /* Don't re-direct... too hard to debug */
fclose(outstream);
#endif
errout_with_driver: errout_with_driver:
message(MAIN_NAME_STRING ": Unregister the NX console device\n"); message(MAIN_NAME_STRING ": Unregister the NX console device\n");
(void)nxcon_unregister(g_nxcon_vars.hdrvr); (void)nxcon_unregister(g_nxcon_vars.hdrvr);

12
nuttx/fs/nfs/nfs.h

@ -215,7 +215,7 @@ struct nfsd_srvargs
unsigned char *nsd_authstr; /* Auth string (ret) */ unsigned char *nsd_authstr; /* Auth string (ret) */
int nsd_verflen; /* and the verifier */ int nsd_verflen; /* and the verifier */
unsigned char *nsd_verfstr; unsigned char *nsd_verfstr;
struct timeval nsd_timestamp; /* timestamp from verifier */ struct timeval nsd_timestamp; /* timestamp from verifier */
uint32_t nsd_ttl; /* credential ttl (sec) */ uint32_t nsd_ttl; /* credential ttl (sec) */
}; };
@ -303,13 +303,13 @@ enum nfs_rto_timers
union nethostaddr union nethostaddr
{ {
u_int32_t had_inetaddr; uint32_t had_inetaddr;
struct mbuf *had_nam; struct mbuf *had_nam;
}; };
struct nfssvc_sock struct nfssvc_sock
{ {
TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ // TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
struct file *ns_fp; /* fp from the... */ struct file *ns_fp; /* fp from the... */
struct socket *ns_so; /* ...socket this struct wraps */ struct socket *ns_so; /* ...socket this struct wraps */
int ns_flag; /* socket status flags */ int ns_flag; /* socket status flags */
@ -323,7 +323,7 @@ struct nfssvc_sock
struct nfsd struct nfsd
{ {
TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ //TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
int nfsd_flag; /* NFSD_ flags */ int nfsd_flag; /* NFSD_ flags */
struct nfssvc_sock *nfsd_slp; /* Current socket */ struct nfssvc_sock *nfsd_slp; /* Current socket */
struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
@ -342,7 +342,7 @@ struct nfsrv_descript
/**************************************************************************** /****************************************************************************
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
/*
extern int nfs_niothreads; extern int nfs_niothreads;
extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
extern int nfssvc_sockhead_flag; extern int nfssvc_sockhead_flag;
@ -351,7 +351,7 @@ extern struct pool nfsreqpl;
extern struct pool nfs_node_pool; extern struct pool nfs_node_pool;
extern TAILQ_HEAD(nfsdhead, nfsd) nfsd_head; extern TAILQ_HEAD(nfsdhead, nfsd) nfsd_head;
extern int nfsd_head_flag; extern int nfsd_head_flag;
*/
/**************************************************************************** /****************************************************************************
* Public Function Prototypes * Public Function Prototypes
****************************************************************************/ ****************************************************************************/

32
nuttx/fs/nfs/nfs_args.h

@ -46,14 +46,12 @@
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
#include "nfs_proto.h"
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* File identifier */
#define MAXFIDSZ 16
/* NFS mount option flags */ /* NFS mount option flags */
#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
@ -92,32 +90,6 @@
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
typedef struct
{
int32_t val[2];
} fsid_t; /* file system id type */
/* File identifier.
* These are unique per filesystem on a single machine.
*/
struct fid
{
unsigned short fid_len; /* length of data in bytes */
unsigned short fid_reserved; /* force longword alignment */
char fid_data[MAXFIDSZ]; /* data (variable length) */
};
/* Generic file handle */
struct fhandle
{
fsid_t fh_fsid; /* File system id of mount point */
struct fid fh_fid; /* File sys specific id */
};
typedef struct fhandle fhandle_t;
/* Arguments to mount NFS */ /* Arguments to mount NFS */
struct nfs_args struct nfs_args

24
nuttx/fs/nfs/nfs_mount.h

@ -109,20 +109,18 @@ struct nfsmount
/* Prototypes for NFS mount operations: */ /* Prototypes for NFS mount operations: */
int nfs_mount(struct mount *, const char *, void *, struct nameidata *, int nfs_mount(struct inode *, const char *, void *);
struct proc *); int mountnfs(struct nfs_args *, struct inode *, char *, char *);
int mountnfs(struct nfs_args *, struct mount *, struct mbuf *, char *, char *);
void nfs_decode_args(struct nfsmount *, struct nfs_args *, struct nfs_args *); void nfs_decode_args(struct nfsmount *, struct nfs_args *, struct nfs_args *);
int nfs_start(struct mount *, int, struct proc *); int nfs_start(struct inode *, int);
int nfs_unmount(struct mount *, int, struct proc *); int nfs_unmount(struct inode *, int);
int nfs_root(struct mount *, struct vnode **); int nfs_root(struct inode *, struct file **);
int nfs_statfs(struct mount *, struct statfs *, struct proc *); int nfs_statfs(struct inode *, struct statfs *);
int nfs_sync(struct mount *, int, struct ucred *, struct proc *); int nfs_sync(struct inode *, int);
int nfs_vget(struct mount *, ino_t, struct vnode **); int nfs_vget(struct inode *, ino_t, struct file **);
int nfs_fhtovp(struct mount *, struct fid *, struct vnode **); int nfs_fhtovp(struct inode *, struct fid *);
int nfs_vptofh(struct vnode *, struct fid *); int nfs_vptofh(struct file *, struct fid *);
int nfs_fsinfo(struct nfsmount *, struct vnode *, struct ucred *, int nfs_fsinfo(struct nfsmount *, struct file *);
struct proc *);
void nfs_init(void); void nfs_init(void);
#endif #endif

30
nuttx/fs/nfs/nfs_proto.h

@ -249,6 +249,10 @@
# define NFS_MAXFHSIZE 64 # define NFS_MAXFHSIZE 64
#endif #endif
/* File identifier */
#define MAXFIDSZ 16
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
@ -267,6 +271,32 @@ typedef enum
NFFIFO = 7 NFFIFO = 7
} nfstype; } nfstype;
typedef struct
{
int32_t val[2];
} fsid_t; /* file system id type */
/* File identifier.
* These are unique per filesystem on a single machine.
*/
struct fid
{
unsigned short fid_len; /* length of data in bytes */
unsigned short fid_reserved; /* force longword alignment */
char fid_data[MAXFIDSZ]; /* data (variable length) */
};
/* Generic file handle */
struct fhandle
{
fsid_t fh_fsid; /* File system id of mount point */
struct fid fh_fid; /* File sys specific id */
};
typedef struct fhandle fhandle_t;
/* File Handle (32 bytes for version 2), variable up to 64 for version 3. */ /* File Handle (32 bytes for version 2), variable up to 64 for version 3. */
union nfsfh union nfsfh

10
nuttx/fs/nfs/nfs_socket.c

@ -80,7 +80,7 @@ static struct rpc_program nfs3_program =
* Public Variables * Public Variables
****************************************************************************/ ****************************************************************************/
int nfs_ticks = rpcclnt_ticks; int nfs_ticks;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@ -163,7 +163,7 @@ int nfsx_request_xx(struct nfsmount *nm, int procnum, void *data)
int error; int error;
struct nfsmount *nmp; struct nfsmount *nmp;
struct rpcclnt *clnt; struct rpcclnt *clnt;
struct rpc_reply reply; struct rpc_reply *reply;
int trylater_delay; int trylater_delay;
nmp = nm; nmp = nm;
@ -171,12 +171,12 @@ int nfsx_request_xx(struct nfsmount *nm, int procnum, void *data)
tryagain: tryagain:
memset(&reply, 0, sizeof(reply)); memset(reply, 0, sizeof(struct rpc_reply));
if ((error = rpcclnt_request(clnt, procnum, &reply)) != 0) if ((error = rpcclnt_request(clnt, procnum, reply)) != 0)
goto out; goto out;
data = reply->where; data = reply->stat.where;
if (reply->rpc_verfi.authtype != 0) if (reply->rpc_verfi.authtype != 0)
{ {

6
nuttx/fs/nfs/nfs_socket.h

@ -53,14 +53,14 @@ int nfsx_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
void nfsx_safedisconnect(struct nfsmount *); void nfsx_safedisconnect(struct nfsmount *);
#define nfs_safedisconnect nfsx_safedisconnect #define nfs_safedisconnect nfsx_safedisconnect
#endif #endif
int nfsx_request_xx(struct nfsmount *, int); int nfsx_request_xx(struct nfsmount *, int, void*);
int nfsx_nmcancelreqs(struct nfsmount *); int nfsx_nmcancelreqs(struct nfsmount *);
#define nfs_connect nfs_connect_nfsx #define nfs_connect nfs_connect_nfsx
#define nfs_disconnect nfs_disconnect_nfsx #define nfs_disconnect nfs_disconnect_nfsx
#define nfs_nmcancelreqs nfsx_nmcancelreqs #define nfs_nmcancelreqs nfsx_nmcancelreqs
#define nfsx_request(nmp, m) \ #define nfsx_request(nmp, m, s) \
nfsx_request_xx(nmp, m) nfsx_request_xx(nmp, m, s)
#ifdef CONFIG_NFS_TCPIP #ifdef CONFIG_NFS_TCPIP
#define nfs_sigintr nfs_sigintr_nfsx #define nfs_sigintr nfs_sigintr_nfsx

15
nuttx/fs/nfs/nfs_vfsops.c

@ -1,4 +1,3 @@
/**************************************************************************** /****************************************************************************
* fs/nfs/nfs_vfsops.c * fs/nfs/nfs_vfsops.c
* *
@ -64,17 +63,17 @@
#include <sys/statfs> #include <sys/statfs>
#include <queue.h> #include <queue.h>
#include <nuttx/fs/fs.h>
#include <net/if.h> #include <net/if.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <nfs/rpcv2.h> #include "rpcv2.h"
#include <nfs/nfsproto.h> #include "nfsproto.h"
#include <nfs/nfsnode.h> #include "nfs_node.h"
#include <nfs/nfs.h> #include "nfs.h"
#include <nfs/nfsmount.h> #include "nfs_mount.h"
#include <nfs/xdr_subs.h> #include "xdr_subs.h"
#include <nfs/nfs_var.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions

2
nuttx/fs/nfs/rpc.h

@ -158,7 +158,7 @@ struct rpc_reply
uint32_t type; uint32_t type;
uint32_t status; uint32_t status;
void where; /* Data */ void *where; /* Data */
/* used only when reply == RPC_MSGDENIED and status == RPC_AUTHERR */ /* used only when reply == RPC_MSGDENIED and status == RPC_AUTHERR */

28
nuttx/fs/nfs/rpc_clnt.c

@ -92,9 +92,9 @@
#include <debug.h> #include <debug.h>
#include "xdr_subs.h" #include "xdr_subs.h"
#include "nfs_args.h"
#include "nfs_proto.h" #include "nfs_proto.h"
#include "nfs.h" #include "nfs.h"
#include "nfs_args.h"
#include "rpc.h" #include "rpc.h"
#include "rpc_clnt_private.h" #include "rpc_clnt_private.h"
#include "rpc_v2.h" #include "rpc_v2.h"
@ -186,8 +186,8 @@ static uint32_t rpc_reply, rpc_call, rpc_vers, rpc_msgdenied,
static uint32_t rpcclnt_xid = 0; static uint32_t rpcclnt_xid = 0;
static uint32_t rpcclnt_xid_touched = 0; static uint32_t rpcclnt_xid_touched = 0;
struct rpcstats rpcstats;
int rpcclnt_ticks; int rpcclnt_ticks;
struct rpcstats rpcstats;
struct rpc_call *callmgs; struct rpc_call *callmgs;
struct rpc_reply *replymsg; struct rpc_reply *replymsg;
@ -512,7 +512,7 @@ rpcclnt_reply(struct rpctask *myrep, struct rpc_call *call,
struct rpctask *rep; struct rpctask *rep;
struct rpcclnt *rpc = myrep->r_rpcclnt; struct rpcclnt *rpc = myrep->r_rpcclnt;
int32_t t1; int32_t t1;
struct sockaddr *nam; struct sockaddr *nam = NULL;
uint32_t rxid; uint32_t rxid;
int error; int error;
@ -845,8 +845,8 @@ int rpcclnt_connect(struct rpcclnt *rpc)
struct socket *so; struct socket *so;
int error; int error;
struct sockaddr *saddr; struct sockaddr *saddr;
struct sockaddr_in *sin; struct sockaddr_in *sin = NULL;
struct timeval *tv; struct timeval *tv = NULL;
uint16_t tport; uint16_t tport;
/* create the socket */ /* create the socket */
@ -932,10 +932,8 @@ int rpcclnt_connect(struct rpcclnt *rpc)
/* Initialize other non-zero congestion variables */ /* Initialize other non-zero congestion variables */
rpc->rc_srtt[0] = rpc->rc_srtt[1] = rpc->rc_srtt[2] = rpc->rc_srtt[3] = rpc->rc_srtt[0] = rpc->rc_srtt[1] = rpc->rc_srtt[2] = rpc->rc_srtt[3] = (RPC_TIMEO << 3);
rpc->rc_srtt[4] = (RPC_TIMEO << 3); rpc->rc_sdrtt[0] = rpc->rc_sdrtt[1] = rpc->rc_sdrtt[2] = rpc->rc_sdrtt[3] = 0;
rpc->rc_sdrtt[0] = rpc->rc_sdrtt[1] = rpc->rc_sdrtt[2] = rpc->rc_sdrtt[3] =
rpc->rc_sdrtt[4] = 0;
rpc->rc_cwnd = RPC_MAXCWND / 2; /* Initial send window */ rpc->rc_cwnd = RPC_MAXCWND / 2; /* Initial send window */
rpc->rc_sent = 0; rpc->rc_sent = 0;
rpc->rc_timeouts = 0; rpc->rc_timeouts = 0;
@ -1023,11 +1021,11 @@ void rpcclnt_safedisconnect(struct rpcclnt *rpc)
int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply) int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply)
{ {
struct rpc_call *call; struct rpc_call *call = NULL;
struct rpc_reply *replysvr; struct rpc_reply *replysvr = NULL;
struct rpctask *task, _task; struct rpctask *task, _task;
int error = 0; int error = 0;
int xid; int xid = 0;
task = &_task; task = &_task;
memset(task, 0, sizeof(*task)); memset(task, 0, sizeof(*task));
@ -1163,7 +1161,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply)
if (reply->stat.status == RPC_SUCCESS) if (reply->stat.status == RPC_SUCCESS)
{ {
printf("RPC_SUCCESS"); printf("RPC_SUCCESS");
reply->where = replysvr->where; reply->stat.where = replysvr->stat.where;
} }
else if (reply->stat.status == RPC_PROGMISMATCH) else if (reply->stat.status == RPC_PROGMISMATCH)
{ {
@ -1291,7 +1289,7 @@ void rpcclnt_timer(void *arg, struct rpc_call *call)
int rpcclnt_buildheader(struct rpcclnt *rc, int procid, int rpcclnt_buildheader(struct rpcclnt *rc, int procid,
int xidp, struct rpc_call *call) int xidp, struct rpc_call *call)
{ {
struct timeval *tv; struct timeval *tv = NULL;
srand(time(NULL)); srand(time(NULL));
/* The RPC header.*/ /* The RPC header.*/
@ -1326,6 +1324,7 @@ int rpcclnt_buildheader(struct rpcclnt *rc, int procid,
call->rpc_auth.authlen = txdr_unsigned(sizeof(NULL)); call->rpc_auth.authlen = txdr_unsigned(sizeof(NULL));
tv->tv_sec = 1; tv->tv_sec = 1;
tv->tv_usec = 0;
#ifdef CONFIG_NFS_UNIX_AUTH #ifdef CONFIG_NFS_UNIX_AUTH
call->rpc_unix.ua_time = txdr_unsigned(tv->tv_sec); call->rpc_unix.ua_time = txdr_unsigned(tv->tv_sec);
call->rpc_unix.ua_hostname = 0; call->rpc_unix.ua_hostname = 0;
@ -1368,3 +1367,4 @@ int rpcclnt_cancelreqs(struct rpcclnt *rpc)
return (EBUSY); return (EBUSY);
} }
#endif

4
nuttx/graphics/nxbe/nxbe_bitmap.c

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* graphics/nxbe/nxbe_bitmap.c * graphics/nxbe/nxbe_bitmap.c
* *
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

3
nuttx/graphics/nxconsole/nxcon_font.c

@ -183,6 +183,9 @@ nxcon_allocglyph(FAR struct nxcon_state_s *priv)
luglyph->usecnt = 1; luglyph->usecnt = 1;
return luglyph; return luglyph;
#else #else
/* TODO: Instead allocating an freeing, just allocate the max glyph once */
nxcon_freeglyph(&priv->glyph);
return &priv->glyph; return &priv->glyph;
#endif #endif
} }

2
nuttx/sched/os_start.c

@ -278,7 +278,7 @@ void os_start(void)
strncpy(g_idletcb.name, g_idlename, CONFIG_TASK_NAME_SIZE-1); strncpy(g_idletcb.name, g_idlename, CONFIG_TASK_NAME_SIZE-1);
g_idletcb.argv[0] = g_idletcb.name; g_idletcb.argv[0] = g_idletcb.name;
#else #else
g_idletcb.argv[0] = g_idlename; g_idletcb.argv[0] = (char*)g_idlename;
#endif /* CONFIG_TASK_NAME_SIZE */ #endif /* CONFIG_TASK_NAME_SIZE */
/* Then add the idle task's TCB to the head of the ready to run list */ /* Then add the idle task's TCB to the head of the ready to run list */

Loading…
Cancel
Save