More NFS updates
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4638 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
98105736c1
commit
dd8a881c5e
@ -78,7 +78,7 @@
|
||||
|
||||
/* These file systems do not require block drivers */
|
||||
|
||||
#if defined(CONFIG_FS_NXFFS) || defined(CONFIG_APPS_BINDIR)
|
||||
#if defined(CONFIG_FS_NXFFS) || defined(CONFIG_APPS_BINDIR) || defined(CONFIG_NFS)
|
||||
# define NONBDFS_SUPPORT
|
||||
#endif
|
||||
|
||||
@ -120,12 +120,18 @@ static const struct fsmap_t g_bdfsmap[] =
|
||||
#ifdef CONFIG_FS_NXFFS
|
||||
extern const struct mountpt_operations nxffs_operations;
|
||||
#endif
|
||||
#ifdef CONFIG_NFS
|
||||
extern const struct mountpt_operations nfs_operations;
|
||||
#endif
|
||||
|
||||
static const struct fsmap_t g_nonbdfsmap[] =
|
||||
{
|
||||
#ifdef CONFIG_FS_NXFFS
|
||||
{ "nxffs", &nxffs_operations },
|
||||
#endif
|
||||
#ifdef CONFIG_NFS
|
||||
{ "nfs", &nfs_operations },
|
||||
#endif
|
||||
#ifdef CONFIG_APPS_BINDIR
|
||||
{ "binfs", &binfs_operations },
|
||||
#endif
|
||||
|
@ -116,7 +116,7 @@ struct nfs_args
|
||||
int readahead; /* # of blocks to readahead */
|
||||
int leaseterm; /* Term (sec) of lease */
|
||||
int deadthresh; /* Retrans threshold */
|
||||
char *hostname; /* server's name */
|
||||
//char *hostname; /* server's name */
|
||||
int acregmin; /* cache attrs for reg files min time */
|
||||
int acregmax; /* cache attrs for reg files max time */
|
||||
int acdirmin; /* cache attrs for dirs min time */
|
||||
|
@ -68,7 +68,7 @@ struct nfsmount
|
||||
{
|
||||
int nm_flag; /* Flags for soft/hard... */
|
||||
int nm_state; /* Internal state flags */
|
||||
struct inode *nm_blkdriver; /* Vfs structure for this filesystem */
|
||||
//struct inode *nm_blkdriver; /* Vfs structure for this filesystem */
|
||||
struct nfsnode *nm_head; /* A list to all files opened on this mountpoint */
|
||||
bool nm_mounted; /* true: The file system is ready */
|
||||
sem_t nm_sem; /* Used to assume thread-safe access */
|
||||
|
@ -302,7 +302,7 @@ typedef struct fhandle fhandle_t;
|
||||
|
||||
union nfsfh
|
||||
{
|
||||
fhandle_t fh_generic;
|
||||
//fhandle_t fh_generic;
|
||||
unsigned char fh_bytes[NFS_MAXFHSIZE];
|
||||
};
|
||||
typedef union nfsfh nfsfh_t;
|
||||
|
@ -82,7 +82,11 @@ static struct rpc_program nfs3_program =
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t nfs_true;
|
||||
uint32_t nfs_false;
|
||||
uint32_t nfs_xdrneg1;
|
||||
int nfs_ticks;
|
||||
struct nfsstats nfsstats;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -94,10 +98,20 @@ int nfs_ticks;
|
||||
|
||||
void nfs_init(void)
|
||||
{
|
||||
rpcclnt_init();
|
||||
nfs_true = txdr_unsigned(TRUE);
|
||||
nfs_false = txdr_unsigned(FALSE);
|
||||
nfs_xdrneg1 = txdr_unsigned(-1);
|
||||
|
||||
nfs_ticks = (CLOCKS_PER_SEC * NFS_TICKINTVL + 500) / 1000;
|
||||
if (nfs_ticks < 1)
|
||||
{
|
||||
nfs_ticks = 1;
|
||||
}
|
||||
|
||||
rpcclnt_init();
|
||||
}
|
||||
|
||||
int nfsx_connect(struct nfsmount *nmp)
|
||||
int nfs_connect(struct nfsmount *nmp)
|
||||
{
|
||||
struct rpcclnt *rpc;
|
||||
int error = 0;
|
||||
@ -151,19 +165,19 @@ int nfsx_connect(struct nfsmount *nmp)
|
||||
|
||||
/* NFS disconnect. Clean up and unlink. */
|
||||
|
||||
void nfsx_disconnect(struct nfsmount *nmp)
|
||||
void nfs_disconnect(struct nfsmount *nmp)
|
||||
{
|
||||
rpcclnt_disconnect(nmp->nm_rpcclnt);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NFS_TCPIP
|
||||
void nfsx_safedisconnect(struct nfsmount *nmp)
|
||||
void nfs_safedisconnect(struct nfsmount *nmp)
|
||||
{
|
||||
rpcclnt_safedisconnect(nmp->nm_rpcclnt);
|
||||
}
|
||||
#endif
|
||||
|
||||
int nfsx_request_xx(struct nfsmount *nmp, int procnum, void *datain, void *dataout)
|
||||
int nfs_request(struct nfsmount *nmp, int procnum, void *datain, void *dataout)
|
||||
{
|
||||
int error;
|
||||
struct rpcclnt *clnt;
|
||||
@ -223,7 +237,7 @@ out:
|
||||
|
||||
/* terminate any outstanding RPCs. */
|
||||
|
||||
int nfsx_nmcancelreqs(struct nfsmount *nmp)
|
||||
int nfs_nmcancelreqs(struct nfsmount *nmp)
|
||||
{
|
||||
return rpcclnt_cancelreqs(nmp->nm_rpcclnt);
|
||||
}
|
||||
|
@ -42,17 +42,6 @@
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define nfs_connect(nmp) nfs_connect_nfsx (nmp)
|
||||
#define nfs_disconnect(nmp) nfs_disconnect_nfsx(nmp)
|
||||
#define nfs_nmcancelreqs (nmp) nfsx_nmcancelreqs(nmp)
|
||||
#define nfsx_request(nmp, m, i, o) \
|
||||
nfsx_request_xx(nmp, m, i, o)
|
||||
|
||||
#ifdef CONFIG_NFS_TCPIP
|
||||
# define nfs_sigintr nfs_sigintr_nfsx
|
||||
#define nfs_safedisconnect nfsx_safedisconnect
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
@ -66,14 +55,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
EXTERN void nfs_init(void);
|
||||
EXTERN int nfsx_connect(struct nfsmount *);
|
||||
EXTERN void nfsx_disconnect(struct nfsmount *);
|
||||
EXTERN int nfs_connect(struct nfsmount *);
|
||||
EXTERN void nfs_disconnect(struct nfsmount *);
|
||||
#ifdef CONFIG_NFS_TCPIP
|
||||
EXTERN int nfsx_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
|
||||
EXTERN void nfsx_safedisconnect(struct nfsmount *);
|
||||
EXTERN int nfs_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
|
||||
EXTERN void nfs_safedisconnect(struct nfsmount *);
|
||||
#endif
|
||||
EXTERN int nfsx_request_xx(struct nfsmount *, int, void*, void*);
|
||||
EXTERN int nfsx_nmcancelreqs(struct nfsmount *);
|
||||
EXTERN int nfs_request(struct nfsmount *, int, void*, void*);
|
||||
EXTERN int nfs_nmcancelreqs(struct nfsmount *);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
|
@ -120,31 +120,23 @@ void nfs_semgive(struct nfsmount *nmp)
|
||||
int nfs_checkmount(struct nfsmount *nmp)
|
||||
{
|
||||
struct nfsnode *file;
|
||||
struct inode *inode;
|
||||
struct geometry geo;
|
||||
int ret;
|
||||
|
||||
/* If the fs_mounted flag is false, then we have already handled the loss
|
||||
/* If the nm_mounted flag is false, then we have already handled the loss
|
||||
* of the mount.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(nmp && nmp->nm_blkdriver);
|
||||
DEBUGASSERT(nmp);
|
||||
if (nmp->nm_mounted)
|
||||
{
|
||||
/* We still think the mount is healthy. Check an see if this is
|
||||
* still the case
|
||||
*/
|
||||
|
||||
inode = nmp->nm_blkdriver;
|
||||
if (inode->u.i_bops && inode->u.i_bops->geometry)
|
||||
#warning "This makes no sense... If you get here, then you know that nmp->nm_mounted and the code will always return OK. Something is wrong."
|
||||
if (nmp->nm_mounted == true)
|
||||
{
|
||||
ret = inode->u.i_bops->geometry(inode, &geo);
|
||||
if (ret == OK && geo.geo_available && !geo.geo_mediachanged)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we get here, the mount is NOT healthy */
|
||||
|
||||
nmp->nm_mounted = false;
|
||||
|
@ -105,9 +105,9 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen);
|
||||
static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
|
||||
size_t buflen);
|
||||
static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir);
|
||||
static int nfs_mount(FAR struct inode *blkdriver, const void *data,
|
||||
static int nfs_bind(FAR struct inode *blkdriver, const void *data,
|
||||
void **handle);
|
||||
static int nfs_unmount(void *handle, FAR struct inode **blkdriver);
|
||||
static int nfs_unbind(void *handle, FAR struct inode **blkdriver);
|
||||
static int nfs_statfs(struct inode *mountpt, struct statfs *buf);
|
||||
static int nfs_remove(struct inode *mountpt, const char *relpath);
|
||||
static int nfs_mkdir(struct inode *mountpt, const char *relpath,
|
||||
@ -122,19 +122,18 @@ static int nfs_fsinfo(struct inode *mountpt, const char *relpath,
|
||||
* External Public Data (this belong in a header file)
|
||||
****************************************************************************/
|
||||
|
||||
extern uint32_t nfs_true, nfs_false;
|
||||
extern uint32_t nfs_true;
|
||||
extern uint32_t nfs_false;
|
||||
extern uint32_t nfs_xdrneg1;
|
||||
extern nfstype nfsv3_type[8];
|
||||
extern struct nfsstats nfsstats;
|
||||
extern int nfs_ticks;
|
||||
extern uint32_t nfs_procids[NFS_NPROCS];
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
/* nfs vfs operations. */
|
||||
|
||||
const struct mountpt_operations nfs_ops =
|
||||
const struct mountpt_operations nfs_operations =
|
||||
{
|
||||
nfs_open, /* open */
|
||||
NULL, /* close */
|
||||
@ -149,8 +148,8 @@ const struct mountpt_operations nfs_ops =
|
||||
nfs_readdir, /* readdir */
|
||||
NULL, /* rewinddir */
|
||||
|
||||
nfs_mount, /* bind */
|
||||
nfs_unmount, /* unbind */
|
||||
nfs_bind, /* bind */
|
||||
nfs_unbind, /* unbind */
|
||||
nfs_statfs, /* statfs */
|
||||
|
||||
nfs_remove, /* unlink */
|
||||
@ -220,7 +219,7 @@ nfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
again:
|
||||
nfsstats.rpccnt[NFSPROC_CREATE]++;
|
||||
vap = nmp->nm_head->n_fattr;
|
||||
sp.sa_modetrue = nfs_true;
|
||||
sp.sa_modetrue = true;
|
||||
sp.sa_mode = txdr_unsigned(vap.fa_mode);
|
||||
sp.sa_uidfalse = nfs_xdrneg1;
|
||||
sp.sa_gidfalse = nfs_xdrneg1;
|
||||
@ -980,14 +979,14 @@ void nfs_decode_args(struct nfsmount *nmp, struct nfs_args *argp)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mountnfs(struct nfs_args *argp, struct inode *blkdriver,
|
||||
int mountnfs(struct nfs_args *argp,/* struct inode *blkdriver,*/
|
||||
struct sockaddr *nam, void **handle)
|
||||
{
|
||||
struct nfsmount *nmp;
|
||||
int error;
|
||||
|
||||
/* Open the block driver */
|
||||
|
||||
/*
|
||||
if (!blkdriver || !blkdriver->u.i_bops)
|
||||
{
|
||||
fdbg("No block driver/ops\n");
|
||||
@ -1000,16 +999,16 @@ int mountnfs(struct nfs_args *argp, struct inode *blkdriver,
|
||||
fdbg("No open method\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
*/
|
||||
/* Create an instance of the mountpt state structure */
|
||||
|
||||
/*
|
||||
nmp = (struct nfsmount *)kzalloc(sizeof(struct nfsmount));
|
||||
if (!nmp)
|
||||
{
|
||||
fdbg("Failed to allocate mountpoint structure\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
*/
|
||||
/* Initialize the allocated mountpt state structure. The filesystem is
|
||||
* responsible for one reference ont the blkdriver inode and does not
|
||||
* have to addref() here (but does have to release in ubind().
|
||||
@ -1017,8 +1016,7 @@ int mountnfs(struct nfs_args *argp, struct inode *blkdriver,
|
||||
|
||||
sem_init(&nmp->nm_sem, 0, 0); /* Initialize the semaphore that controls access */
|
||||
|
||||
//vfs_getnewfsid(mp);
|
||||
nmp->nm_blkdriver = blkdriver; /* Save the block driver reference */
|
||||
//nmp->nm_blkdriver = blkdriver; /* Save the block driver reference */
|
||||
nmp->nm_timeo = NFS_TIMEO;
|
||||
nmp->nm_retry = NFS_RETRANS;
|
||||
nmp->nm_wsize = NFS_WSIZE;
|
||||
@ -1057,7 +1055,7 @@ int mountnfs(struct nfs_args *argp, struct inode *blkdriver,
|
||||
|
||||
nmp->nm_mounted = true;
|
||||
nfs_init();
|
||||
*handle = blkdriver->i_private = &nmp;
|
||||
*handle /*= blkdriver->i_private*/ = &nmp;
|
||||
nfs_semgive(nmp);
|
||||
|
||||
return 0;
|
||||
@ -1070,7 +1068,7 @@ bad:
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nfs_mount
|
||||
* Name: nfs_bind
|
||||
*
|
||||
* Description: This implements a portion of the mount operation. This
|
||||
* function allocates and initializes the mountpoint private data and
|
||||
@ -1080,7 +1078,7 @@ bad:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int nfs_mount(struct inode *blkdriver, const void *data, void **handle)
|
||||
static int nfs_bind(struct inode *blkdriver, const void *data, void **handle)
|
||||
{
|
||||
int error;
|
||||
struct nfs_args args;
|
||||
@ -1107,7 +1105,7 @@ static int nfs_mount(struct inode *blkdriver, const void *data, void **handle)
|
||||
}
|
||||
|
||||
nam = args.addr;
|
||||
error = mountnfs(&args, blkdriver, nam, handle);
|
||||
error = mountnfs(&args/*, blkdriver*/, nam, handle);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -1119,7 +1117,7 @@ static int nfs_mount(struct inode *blkdriver, const void *data, void **handle)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nfs_unmount(void *handle, struct inode **blkdriver)
|
||||
int nfs_unbind(void *handle, struct inode **blkdriver)
|
||||
{
|
||||
struct nfsmount *nmp = (struct nfsmount *) handle ;
|
||||
int error;
|
||||
@ -1141,7 +1139,7 @@ int nfs_unmount(void *handle, struct inode **blkdriver)
|
||||
else
|
||||
{
|
||||
/* Unmount ... close the block driver */
|
||||
|
||||
/*
|
||||
if (nmp->nm_blkdriver)
|
||||
{
|
||||
struct inode *inode = nmp->nm_blkdriver;
|
||||
@ -1151,20 +1149,21 @@ int nfs_unmount(void *handle, struct inode **blkdriver)
|
||||
{
|
||||
(void)inode->u.i_bops->close(inode);
|
||||
}
|
||||
|
||||
*/
|
||||
/* We hold a reference to the block driver but should
|
||||
* not but mucking with inodes in this context. So, we will just return
|
||||
* our contained reference to the block driver inode and let the umount
|
||||
* logic dispose of it.
|
||||
*/
|
||||
|
||||
/*
|
||||
if (blkdriver)
|
||||
{
|
||||
*blkdriver = inode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/* Release the mountpoint private data */
|
||||
|
||||
nfs_disconnect(nmp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user