mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-04 05:05:19 +08:00
More NFS updates
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4638 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
+129
-2
@@ -1174,7 +1174,7 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The source and target pathes might be relative to the current
|
/* The source and target paths might be relative to the current
|
||||||
* working directory.
|
* working directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1185,7 +1185,7 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
target = nsh_getfullpath(vtbl, argv[optind+1]);
|
target = nsh_getfullpath(vtbl, argv[optind+1]);
|
||||||
if (!source)
|
if (!target)
|
||||||
{
|
{
|
||||||
nsh_freefullpath(source);
|
nsh_freefullpath(source);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
@@ -1206,6 +1206,133 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: cmd_nfsmount
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && \
|
||||||
|
defined(CONFIG_FS_READABLE) && defined(CONFIG_NET) && defined(CONFIG_NFS)
|
||||||
|
#ifndef CONFIG_NSH_DISABLE_NFSMOUNT
|
||||||
|
int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
|
{
|
||||||
|
struct nfs_args data;
|
||||||
|
FAR char *address;
|
||||||
|
FAR char *target;
|
||||||
|
FAR char *protocol = NULL;
|
||||||
|
bool badarg = false;
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
struct in6_addr inaddr;
|
||||||
|
#else
|
||||||
|
struct in_addr inaddr:
|
||||||
|
#endif
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Get the NFS mount options */
|
||||||
|
|
||||||
|
int option;
|
||||||
|
while ((option = getopt(argc, argv, ":p:")) != ERROR)
|
||||||
|
{
|
||||||
|
switch (option)
|
||||||
|
{
|
||||||
|
/* Protocol may be UDP or TCP/IP */
|
||||||
|
|
||||||
|
case 'p':
|
||||||
|
protocol = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Handle missing required arguments */
|
||||||
|
|
||||||
|
case ':':
|
||||||
|
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
||||||
|
badarg = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Handle unrecognized arguments */
|
||||||
|
|
||||||
|
case '?':
|
||||||
|
default:
|
||||||
|
nsh_output(vtbl, g_fmtarginvalid, argv[0]);
|
||||||
|
badarg = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If a bad argument was encountered, then return without processing the
|
||||||
|
* command.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (badarg)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* There are two required arguments after the options: (1) The NFS server IP
|
||||||
|
* address and then (1) the path to the mount point.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (optind + 2 < argc)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
else if (optind + 2 > argc)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The next argument on the command line should be the NFS server IP address
|
||||||
|
* in standard IPv4 (or IPv6) dot format.
|
||||||
|
*/
|
||||||
|
|
||||||
|
address = argv[optind];
|
||||||
|
if (!address)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The target mount point path might be relative to the current working
|
||||||
|
* directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
target = nsh_getfullpath(vtbl, argv[optind+1]);
|
||||||
|
if (!target)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert the IP address string into its binary form */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
ret = inet_pton(AF_INET, address, &inaddr);
|
||||||
|
#else
|
||||||
|
ret = inet_pton(AF_INET6, address, &inaddr);
|
||||||
|
#endif
|
||||||
|
if (ret != 1)
|
||||||
|
{
|
||||||
|
nsh_freefullpath(target);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Place all of the NFS arguements into the nfs_args structure */
|
||||||
|
#warning "Missing logic"
|
||||||
|
|
||||||
|
/* Perform the mount */
|
||||||
|
|
||||||
|
ret = mount(NULL, target, "nfs", 0, (FAR void *)&data);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We no longer need the allocated mount point path */
|
||||||
|
|
||||||
|
nsh_freefullpath(target);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cmd_rm
|
* Name: cmd_rm
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||||||
|
|
||||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE)
|
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE)
|
||||||
# ifndef CONFIG_NSH_DISABLE_MOUNT
|
# ifndef CONFIG_NSH_DISABLE_MOUNT
|
||||||
{ "mount", cmd_mount, 4, 5, "-t <fstype> <block-device> <dir-path>" },
|
{ "mount", cmd_mount, 4, 5, "-t <fstype> <block-device> <mount-point>" },
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -267,6 +267,13 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||||||
{ "mw", cmd_mw, 2, 3, "<hex-address>[=<hex-value>][ <hex-byte-count>]" },
|
{ "mw", cmd_mw, 2, 3, "<hex-address>[=<hex-value>][ <hex-byte-count>]" },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && \
|
||||||
|
defined(CONFIG_FS_READABLE) && defined(CONFIG_NET) && defined(CONFIG_NFS)
|
||||||
|
# ifndef CONFIG_NSH_DISABLE_NFSMOUNT
|
||||||
|
{ "nfsmount", cmd_nfsmount, 3, 5, "[-p <protocol>] <server-address> <mount-point>" },
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) && \
|
#if defined(CONFIG_NET) && defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) && \
|
||||||
!defined(CONFIG_DISABLE_CLOCK) && !defined(CONFIG_DISABLE_SIGNALS)
|
!defined(CONFIG_DISABLE_CLOCK) && !defined(CONFIG_DISABLE_SIGNALS)
|
||||||
# ifndef CONFIG_NSH_DISABLE_PING
|
# ifndef CONFIG_NSH_DISABLE_PING
|
||||||
|
|||||||
+7
-1
@@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
/* These file systems do not require block drivers */
|
/* 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
|
# define NONBDFS_SUPPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -120,12 +120,18 @@ static const struct fsmap_t g_bdfsmap[] =
|
|||||||
#ifdef CONFIG_FS_NXFFS
|
#ifdef CONFIG_FS_NXFFS
|
||||||
extern const struct mountpt_operations nxffs_operations;
|
extern const struct mountpt_operations nxffs_operations;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_NFS
|
||||||
|
extern const struct mountpt_operations nfs_operations;
|
||||||
|
#endif
|
||||||
|
|
||||||
static const struct fsmap_t g_nonbdfsmap[] =
|
static const struct fsmap_t g_nonbdfsmap[] =
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_FS_NXFFS
|
#ifdef CONFIG_FS_NXFFS
|
||||||
{ "nxffs", &nxffs_operations },
|
{ "nxffs", &nxffs_operations },
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_NFS
|
||||||
|
{ "nfs", &nfs_operations },
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_APPS_BINDIR
|
#ifdef CONFIG_APPS_BINDIR
|
||||||
{ "binfs", &binfs_operations },
|
{ "binfs", &binfs_operations },
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ struct nfs_args
|
|||||||
int readahead; /* # of blocks to readahead */
|
int readahead; /* # of blocks to readahead */
|
||||||
int leaseterm; /* Term (sec) of lease */
|
int leaseterm; /* Term (sec) of lease */
|
||||||
int deadthresh; /* Retrans threshold */
|
int deadthresh; /* Retrans threshold */
|
||||||
char *hostname; /* server's name */
|
//char *hostname; /* server's name */
|
||||||
int acregmin; /* cache attrs for reg files min time */
|
int acregmin; /* cache attrs for reg files min time */
|
||||||
int acregmax; /* cache attrs for reg files max time */
|
int acregmax; /* cache attrs for reg files max time */
|
||||||
int acdirmin; /* cache attrs for dirs min time */
|
int acdirmin; /* cache attrs for dirs min time */
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ struct nfsmount
|
|||||||
{
|
{
|
||||||
int nm_flag; /* Flags for soft/hard... */
|
int nm_flag; /* Flags for soft/hard... */
|
||||||
int nm_state; /* Internal state flags */
|
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 */
|
struct nfsnode *nm_head; /* A list to all files opened on this mountpoint */
|
||||||
bool nm_mounted; /* true: The file system is ready */
|
bool nm_mounted; /* true: The file system is ready */
|
||||||
sem_t nm_sem; /* Used to assume thread-safe access */
|
sem_t nm_sem; /* Used to assume thread-safe access */
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ typedef struct fhandle fhandle_t;
|
|||||||
|
|
||||||
union nfsfh
|
union nfsfh
|
||||||
{
|
{
|
||||||
fhandle_t fh_generic;
|
//fhandle_t fh_generic;
|
||||||
unsigned char fh_bytes[NFS_MAXFHSIZE];
|
unsigned char fh_bytes[NFS_MAXFHSIZE];
|
||||||
};
|
};
|
||||||
typedef union nfsfh nfsfh_t;
|
typedef union nfsfh nfsfh_t;
|
||||||
|
|||||||
@@ -82,7 +82,11 @@ static struct rpc_program nfs3_program =
|
|||||||
* Public Variables
|
* Public Variables
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint32_t nfs_true;
|
||||||
|
uint32_t nfs_false;
|
||||||
|
uint32_t nfs_xdrneg1;
|
||||||
int nfs_ticks;
|
int nfs_ticks;
|
||||||
|
struct nfsstats nfsstats;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@@ -94,10 +98,20 @@ int nfs_ticks;
|
|||||||
|
|
||||||
void nfs_init(void)
|
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;
|
struct rpcclnt *rpc;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
@@ -151,19 +165,19 @@ int nfsx_connect(struct nfsmount *nmp)
|
|||||||
|
|
||||||
/* NFS disconnect. Clean up and unlink. */
|
/* NFS disconnect. Clean up and unlink. */
|
||||||
|
|
||||||
void nfsx_disconnect(struct nfsmount *nmp)
|
void nfs_disconnect(struct nfsmount *nmp)
|
||||||
{
|
{
|
||||||
rpcclnt_disconnect(nmp->nm_rpcclnt);
|
rpcclnt_disconnect(nmp->nm_rpcclnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NFS_TCPIP
|
#ifdef CONFIG_NFS_TCPIP
|
||||||
void nfsx_safedisconnect(struct nfsmount *nmp)
|
void nfs_safedisconnect(struct nfsmount *nmp)
|
||||||
{
|
{
|
||||||
rpcclnt_safedisconnect(nmp->nm_rpcclnt);
|
rpcclnt_safedisconnect(nmp->nm_rpcclnt);
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
int error;
|
||||||
struct rpcclnt *clnt;
|
struct rpcclnt *clnt;
|
||||||
@@ -223,7 +237,7 @@ out:
|
|||||||
|
|
||||||
/* terminate any outstanding RPCs. */
|
/* terminate any outstanding RPCs. */
|
||||||
|
|
||||||
int nfsx_nmcancelreqs(struct nfsmount *nmp)
|
int nfs_nmcancelreqs(struct nfsmount *nmp)
|
||||||
{
|
{
|
||||||
return rpcclnt_cancelreqs(nmp->nm_rpcclnt);
|
return rpcclnt_cancelreqs(nmp->nm_rpcclnt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,17 +42,6 @@
|
|||||||
* Pre-processor definitions
|
* 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
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -66,14 +55,14 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXTERN void nfs_init(void);
|
EXTERN void nfs_init(void);
|
||||||
EXTERN int nfsx_connect(struct nfsmount *);
|
EXTERN int nfs_connect(struct nfsmount *);
|
||||||
EXTERN void nfsx_disconnect(struct nfsmount *);
|
EXTERN void nfs_disconnect(struct nfsmount *);
|
||||||
#ifdef CONFIG_NFS_TCPIP
|
#ifdef CONFIG_NFS_TCPIP
|
||||||
EXTERN int nfsx_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
|
EXTERN int nfs_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
|
||||||
EXTERN void nfsx_safedisconnect(struct nfsmount *);
|
EXTERN void nfs_safedisconnect(struct nfsmount *);
|
||||||
#endif
|
#endif
|
||||||
EXTERN int nfsx_request_xx(struct nfsmount *, int, void*, void*);
|
EXTERN int nfs_request(struct nfsmount *, int, void*, void*);
|
||||||
EXTERN int nfsx_nmcancelreqs(struct nfsmount *);
|
EXTERN int nfs_nmcancelreqs(struct nfsmount *);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|||||||
+4
-12
@@ -120,31 +120,23 @@ void nfs_semgive(struct nfsmount *nmp)
|
|||||||
int nfs_checkmount(struct nfsmount *nmp)
|
int nfs_checkmount(struct nfsmount *nmp)
|
||||||
{
|
{
|
||||||
struct nfsnode *file;
|
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.
|
* of the mount.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUGASSERT(nmp && nmp->nm_blkdriver);
|
DEBUGASSERT(nmp);
|
||||||
if (nmp->nm_mounted)
|
if (nmp->nm_mounted)
|
||||||
{
|
{
|
||||||
/* We still think the mount is healthy. Check an see if this is
|
/* We still think the mount is healthy. Check an see if this is
|
||||||
* still the case
|
* still the case
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inode = nmp->nm_blkdriver;
|
#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 (inode->u.i_bops && inode->u.i_bops->geometry)
|
if (nmp->nm_mounted == true)
|
||||||
{
|
{
|
||||||
ret = inode->u.i_bops->geometry(inode, &geo);
|
|
||||||
if (ret == OK && geo.geo_available && !geo.geo_mediachanged)
|
|
||||||
{
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we get here, the mount is NOT healthy */
|
/* If we get here, the mount is NOT healthy */
|
||||||
|
|
||||||
nmp->nm_mounted = false;
|
nmp->nm_mounted = false;
|
||||||
|
|||||||
+24
-25
@@ -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,
|
static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
|
||||||
size_t buflen);
|
size_t buflen);
|
||||||
static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir);
|
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);
|
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_statfs(struct inode *mountpt, struct statfs *buf);
|
||||||
static int nfs_remove(struct inode *mountpt, const char *relpath);
|
static int nfs_remove(struct inode *mountpt, const char *relpath);
|
||||||
static int nfs_mkdir(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)
|
* 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 uint32_t nfs_xdrneg1;
|
||||||
extern nfstype nfsv3_type[8];
|
|
||||||
extern struct nfsstats nfsstats;
|
extern struct nfsstats nfsstats;
|
||||||
extern int nfs_ticks;
|
extern int nfs_ticks;
|
||||||
extern uint32_t nfs_procids[NFS_NPROCS];
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/* nfs vfs operations. */
|
/* nfs vfs operations. */
|
||||||
|
|
||||||
const struct mountpt_operations nfs_ops =
|
const struct mountpt_operations nfs_operations =
|
||||||
{
|
{
|
||||||
nfs_open, /* open */
|
nfs_open, /* open */
|
||||||
NULL, /* close */
|
NULL, /* close */
|
||||||
@@ -149,8 +148,8 @@ const struct mountpt_operations nfs_ops =
|
|||||||
nfs_readdir, /* readdir */
|
nfs_readdir, /* readdir */
|
||||||
NULL, /* rewinddir */
|
NULL, /* rewinddir */
|
||||||
|
|
||||||
nfs_mount, /* bind */
|
nfs_bind, /* bind */
|
||||||
nfs_unmount, /* unbind */
|
nfs_unbind, /* unbind */
|
||||||
nfs_statfs, /* statfs */
|
nfs_statfs, /* statfs */
|
||||||
|
|
||||||
nfs_remove, /* unlink */
|
nfs_remove, /* unlink */
|
||||||
@@ -220,7 +219,7 @@ nfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||||||
again:
|
again:
|
||||||
nfsstats.rpccnt[NFSPROC_CREATE]++;
|
nfsstats.rpccnt[NFSPROC_CREATE]++;
|
||||||
vap = nmp->nm_head->n_fattr;
|
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_mode = txdr_unsigned(vap.fa_mode);
|
||||||
sp.sa_uidfalse = nfs_xdrneg1;
|
sp.sa_uidfalse = nfs_xdrneg1;
|
||||||
sp.sa_gidfalse = 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 sockaddr *nam, void **handle)
|
||||||
{
|
{
|
||||||
struct nfsmount *nmp;
|
struct nfsmount *nmp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
/* Open the block driver */
|
/* Open the block driver */
|
||||||
|
/*
|
||||||
if (!blkdriver || !blkdriver->u.i_bops)
|
if (!blkdriver || !blkdriver->u.i_bops)
|
||||||
{
|
{
|
||||||
fdbg("No block driver/ops\n");
|
fdbg("No block driver/ops\n");
|
||||||
@@ -1000,16 +999,16 @@ int mountnfs(struct nfs_args *argp, struct inode *blkdriver,
|
|||||||
fdbg("No open method\n");
|
fdbg("No open method\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/* Create an instance of the mountpt state structure */
|
/* Create an instance of the mountpt state structure */
|
||||||
|
/*
|
||||||
nmp = (struct nfsmount *)kzalloc(sizeof(struct nfsmount));
|
nmp = (struct nfsmount *)kzalloc(sizeof(struct nfsmount));
|
||||||
if (!nmp)
|
if (!nmp)
|
||||||
{
|
{
|
||||||
fdbg("Failed to allocate mountpoint structure\n");
|
fdbg("Failed to allocate mountpoint structure\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/* Initialize the allocated mountpt state structure. The filesystem is
|
/* Initialize the allocated mountpt state structure. The filesystem is
|
||||||
* responsible for one reference ont the blkdriver inode and does not
|
* responsible for one reference ont the blkdriver inode and does not
|
||||||
* have to addref() here (but does have to release in ubind().
|
* 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 */
|
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_timeo = NFS_TIMEO;
|
||||||
nmp->nm_retry = NFS_RETRANS;
|
nmp->nm_retry = NFS_RETRANS;
|
||||||
nmp->nm_wsize = NFS_WSIZE;
|
nmp->nm_wsize = NFS_WSIZE;
|
||||||
@@ -1057,7 +1055,7 @@ int mountnfs(struct nfs_args *argp, struct inode *blkdriver,
|
|||||||
|
|
||||||
nmp->nm_mounted = true;
|
nmp->nm_mounted = true;
|
||||||
nfs_init();
|
nfs_init();
|
||||||
*handle = blkdriver->i_private = &nmp;
|
*handle /*= blkdriver->i_private*/ = &nmp;
|
||||||
nfs_semgive(nmp);
|
nfs_semgive(nmp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1070,7 +1068,7 @@ bad:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nfs_mount
|
* Name: nfs_bind
|
||||||
*
|
*
|
||||||
* Description: This implements a portion of the mount operation. This
|
* Description: This implements a portion of the mount operation. This
|
||||||
* function allocates and initializes the mountpoint private data and
|
* 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;
|
int error;
|
||||||
struct nfs_args args;
|
struct nfs_args args;
|
||||||
@@ -1107,7 +1105,7 @@ static int nfs_mount(struct inode *blkdriver, const void *data, void **handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nam = args.addr;
|
nam = args.addr;
|
||||||
error = mountnfs(&args, blkdriver, nam, handle);
|
error = mountnfs(&args/*, blkdriver*/, nam, handle);
|
||||||
return error;
|
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 ;
|
struct nfsmount *nmp = (struct nfsmount *) handle ;
|
||||||
int error;
|
int error;
|
||||||
@@ -1141,7 +1139,7 @@ int nfs_unmount(void *handle, struct inode **blkdriver)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Unmount ... close the block driver */
|
/* Unmount ... close the block driver */
|
||||||
|
/*
|
||||||
if (nmp->nm_blkdriver)
|
if (nmp->nm_blkdriver)
|
||||||
{
|
{
|
||||||
struct inode *inode = 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);
|
(void)inode->u.i_bops->close(inode);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/* We hold a reference to the block driver but should
|
/* We hold a reference to the block driver but should
|
||||||
* not but mucking with inodes in this context. So, we will just return
|
* 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
|
* our contained reference to the block driver inode and let the umount
|
||||||
* logic dispose of it.
|
* logic dispose of it.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
if (blkdriver)
|
if (blkdriver)
|
||||||
{
|
{
|
||||||
*blkdriver = inode;
|
*blkdriver = inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/* Release the mountpoint private data */
|
/* Release the mountpoint private data */
|
||||||
|
|
||||||
nfs_disconnect(nmp);
|
nfs_disconnect(nmp);
|
||||||
|
|||||||
Reference in New Issue
Block a user