kern/sys: Add NFSv4 client

Update #4475
This commit is contained in:
Chris Johns 2021-07-29 15:49:52 +10:00
parent 6138f242be
commit 882425fe54
39 changed files with 1104 additions and 91 deletions

View File

@ -40,6 +40,8 @@ dhcpcd = on
dpaa = on dpaa = on
evdev = on evdev = on
fdt = on fdt = on
fs_nfs = on
fs_nfsclient = on
imx = on imx = on
in_cksum = on in_cksum = on
mdnsresponder = on mdnsresponder = on
@ -50,14 +52,15 @@ net80211 = off
netinet = on netinet = on
netinet6 = on netinet6 = on
netipsec = off netipsec = off
nfsv2 = on nfsv2 = off
rpc = on nfs = on
nvme = on nvme = on
opencrypto = on opencrypto = on
pci = on pci = on
pf = on pf = on
regulator = on regulator = on
rpc_user = on rpc = on
rpc_user = off
rtems = on rtems = on
tests = on tests = on
tty = on tty = on

13
buildset/nfsv2.ini Normal file
View File

@ -0,0 +1,13 @@
#
# The configuration to build legacy NFSv2 client
#
[general]
name = nfsv2
extends = default.ini
[modules]
nfsv2 = on
rpc_user = on
fs_nfs = off
fs_nfsclient = off

View File

@ -3,3 +3,4 @@ NET_CFG_SELF_IP = 10.0.2.1
NET_CFG_NETMASK = 255.255.0.0 NET_CFG_NETMASK = 255.255.0.0
NET_CFG_PEER_IP = 192.168.100.11 NET_CFG_PEER_IP = 192.168.100.11
NET_CFG_GATEWAY_IP = 192.168.100.11 NET_CFG_GATEWAY_IP = 192.168.100.11
NET_CFG_NFS_MOUNT_PATH = 192.168.100.11:/srv/nfs

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
* *

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -40,8 +42,8 @@ __FBSDID("$FreeBSD$");
* Socket operations for use by nfs * Socket operations for use by nfs
*/ */
#include "opt_kgssapi.h" #include <rtems/bsd/local/opt_kgssapi.h>
#include "opt_nfs.h" #include <rtems/bsd/local/opt_nfs.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -62,7 +64,9 @@ __FBSDID("$FreeBSD$");
#include <rpc/rpc.h> #include <rpc/rpc.h>
#include <rpc/krpc.h> #include <rpc/krpc.h>
#ifndef __rtems__
#include <kgssapi/krb5/kcrypto.h> #include <kgssapi/krb5/kcrypto.h>
#endif /* __rtems__ */
#include <fs/nfs/nfsport.h> #include <fs/nfs/nfsport.h>
@ -215,7 +219,7 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq *nrp,
nconf = getnetconfigent("udp6"); nconf = getnetconfigent("udp6");
else else
nconf = getnetconfigent("tcp6"); nconf = getnetconfigent("tcp6");
pktscale = nfs_bufpackets; pktscale = nfs_bufpackets;
if (pktscale < 2) if (pktscale < 2)
pktscale = 2; pktscale = 2;
@ -233,7 +237,7 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq *nrp,
*/ */
so = NULL; so = NULL;
saddr = NFSSOCKADDR(nrp->nr_nam, struct sockaddr *); saddr = NFSSOCKADDR(nrp->nr_nam, struct sockaddr *);
error = socreate(saddr->sa_family, &so, nrp->nr_sotype, error = socreate(saddr->sa_family, &so, nrp->nr_sotype,
nrp->nr_soproto, td->td_ucred, td); nrp->nr_soproto, td->td_ucred, td);
if (error) { if (error) {
td->td_ucred = origcred; td->td_ucred = origcred;
@ -387,7 +391,7 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq *nrp,
/* /*
* For UDP, there are 2 timeouts: * For UDP, there are 2 timeouts:
* - CLSET_RETRY_TIMEOUT sets the initial timeout for the timer * - CLSET_RETRY_TIMEOUT sets the initial timeout for the timer
* that does a retransmit of an RPC request using the same * that does a retransmit of an RPC request using the same
* socket and xid. This is what you normally want to do, * socket and xid. This is what you normally want to do,
* since NFS servers depend on "same xid" for their * since NFS servers depend on "same xid" for their
* Duplicate Request Cache. * Duplicate Request Cache.
@ -737,7 +741,7 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp,
if (dtrace_nfscl_nfs234_start_probe != NULL) { if (dtrace_nfscl_nfs234_start_probe != NULL) {
uint32_t probe_id; uint32_t probe_id;
int probe_procnum; int probe_procnum;
if (nd->nd_flag & ND_NFSV4) { if (nd->nd_flag & ND_NFSV4) {
probe_id = probe_id =
nfscl_nfs4_start_probes[nd->nd_procnum]; nfscl_nfs4_start_probes[nd->nd_procnum];
@ -1139,9 +1143,9 @@ tryagain:
j != NFSERR_STALESTATEID && j != NFSERR_STALESTATEID &&
j != NFSERR_BADSTATEID && j != NFSERR_BADSTATEID &&
j != NFSERR_BADSEQID && j != NFSERR_BADSEQID &&
j != NFSERR_BADXDR && j != NFSERR_BADXDR &&
j != NFSERR_RESOURCE && j != NFSERR_RESOURCE &&
j != NFSERR_NOFILEHANDLE))) j != NFSERR_NOFILEHANDLE)))
nd->nd_flag |= ND_INCRSEQID; nd->nd_flag |= ND_INCRSEQID;
} }
/* /*
@ -1260,13 +1264,13 @@ static int
nfs_sig_pending(sigset_t set) nfs_sig_pending(sigset_t set)
{ {
int i; int i;
for (i = 0 ; i < nitems(newnfs_sig_set); i++) for (i = 0 ; i < nitems(newnfs_sig_set); i++)
if (SIGISMEMBER(set, newnfs_sig_set[i])) if (SIGISMEMBER(set, newnfs_sig_set[i]))
return (1); return (1);
return (0); return (0);
} }
/* /*
* The set/restore sigmask functions are used to (temporarily) overwrite * The set/restore sigmask functions are used to (temporarily) overwrite
* the thread td_sigmask during an RPC call (for example). These are also * the thread td_sigmask during an RPC call (for example). These are also
@ -1275,10 +1279,11 @@ nfs_sig_pending(sigset_t set)
void void
newnfs_set_sigmask(struct thread *td, sigset_t *oldset) newnfs_set_sigmask(struct thread *td, sigset_t *oldset)
{ {
#ifndef __rtems__
sigset_t newset; sigset_t newset;
int i; int i;
struct proc *p; struct proc *p;
SIGFILLSET(newset); SIGFILLSET(newset);
if (td == NULL) if (td == NULL)
td = curthread; /* XXX */ td = curthread; /* XXX */
@ -1301,14 +1306,17 @@ newnfs_set_sigmask(struct thread *td, sigset_t *oldset)
kern_sigprocmask(td, SIG_SETMASK, &newset, oldset, kern_sigprocmask(td, SIG_SETMASK, &newset, oldset,
SIGPROCMASK_PROC_LOCKED); SIGPROCMASK_PROC_LOCKED);
PROC_UNLOCK(p); PROC_UNLOCK(p);
#endif /* __rtems__ */
} }
void void
newnfs_restore_sigmask(struct thread *td, sigset_t *set) newnfs_restore_sigmask(struct thread *td, sigset_t *set)
{ {
#ifndef __rtems__
if (td == NULL) if (td == NULL)
td = curthread; /* XXX */ td = curthread; /* XXX */
kern_sigprocmask(td, SIG_SETMASK, set, NULL, 0); kern_sigprocmask(td, SIG_SETMASK, set, NULL, 0);
#endif /* __rtems__ */
} }
/* /*
@ -1338,9 +1346,10 @@ newnfs_msleep(struct thread *td, void *ident, struct mtx *mtx, int priority, cha
int int
newnfs_sigintr(struct nfsmount *nmp, struct thread *td) newnfs_sigintr(struct nfsmount *nmp, struct thread *td)
{ {
#ifndef __rtems__
struct proc *p; struct proc *p;
sigset_t tmpset; sigset_t tmpset;
/* Terminate all requests while attempting a forced unmount. */ /* Terminate all requests while attempting a forced unmount. */
if (NFSCL_FORCEDISM(nmp->nm_mountp)) if (NFSCL_FORCEDISM(nmp->nm_mountp))
return (EIO); return (EIO);
@ -1362,6 +1371,7 @@ newnfs_sigintr(struct nfsmount *nmp, struct thread *td)
return (EINTR); return (EINTR);
} }
PROC_UNLOCK(p); PROC_UNLOCK(p);
#endif /* __rtems__ */
return (0); return (0);
} }
@ -1423,7 +1433,7 @@ nfs_up(struct nfsmount *nmp, struct thread *td, const char *msg,
VQ_NOTRESP, 1); VQ_NOTRESP, 1);
} else } else
mtx_unlock(&nmp->nm_mtx); mtx_unlock(&nmp->nm_mtx);
mtx_lock(&nmp->nm_mtx); mtx_lock(&nmp->nm_mtx);
if ((flags & NFSSTA_LOCKTIMEO) && (nmp->nm_state & NFSSTA_LOCKTIMEO)) { if ((flags & NFSSTA_LOCKTIMEO) && (nmp->nm_state & NFSSTA_LOCKTIMEO)) {
nmp->nm_state &= ~NFSSTA_LOCKTIMEO; nmp->nm_state &= ~NFSSTA_LOCKTIMEO;
@ -1433,4 +1443,3 @@ nfs_up(struct nfsmount *nmp, struct thread *td, const char *msg,
} else } else
mtx_unlock(&nmp->nm_mtx); mtx_unlock(&nmp->nm_mtx);
} }

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -816,4 +818,3 @@ DECLARE_MODULE(nfscommon, nfscommon_mod, SI_SUB_VFS, SI_ORDER_ANY);
MODULE_VERSION(nfscommon, 1); MODULE_VERSION(nfscommon, 1);
MODULE_DEPEND(nfscommon, nfssvc, 1, 1, 1); MODULE_DEPEND(nfscommon, nfssvc, 1, 1, 1);
MODULE_DEPEND(nfscommon, krpc, 1, 1, 1); MODULE_DEPEND(nfscommon, krpc, 1, 1, 1);

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -42,8 +44,8 @@ __FBSDID("$FreeBSD$");
* copy data between mbuf chains and uio lists. * copy data between mbuf chains and uio lists.
*/ */
#ifndef APPLEKEXT #ifndef APPLEKEXT
#include "opt_inet.h" #include <rtems/bsd/local/opt_inet.h>
#include "opt_inet6.h" #include <rtems/bsd/local/opt_inet6.h>
#include <fs/nfs/nfsport.h> #include <fs/nfs/nfsport.h>
@ -3814,8 +3816,10 @@ nfssvc_idname(struct nfsd_idargs *nidp)
cr->cr_uid = cr->cr_ruid = cr->cr_svuid = nidp->nid_uid; cr->cr_uid = cr->cr_ruid = cr->cr_svuid = nidp->nid_uid;
crsetgroups(cr, nidp->nid_ngroup, grps); crsetgroups(cr, nidp->nid_ngroup, grps);
cr->cr_rgid = cr->cr_svgid = cr->cr_groups[0]; cr->cr_rgid = cr->cr_svgid = cr->cr_groups[0];
#ifndef __rtems__
cr->cr_prison = &prison0; cr->cr_prison = &prison0;
prison_hold(cr->cr_prison); prison_hold(cr->cr_prison);
#endif /* __rtems__ */
#ifdef MAC #ifdef MAC
mac_cred_associate_nfsd(cr); mac_cred_associate_nfsd(cr);
#endif #endif
@ -4766,4 +4770,3 @@ nfsv4_findmirror(struct nfsmount *nmp)
} }
return (ds); return (ds);
} }

View File

@ -42,7 +42,7 @@
* to be the cleanest way to handle #include files for the ports. * to be the cleanest way to handle #include files for the ports.
*/ */
#ifdef _KERNEL #ifdef _KERNEL
#include <sys/unistd.h> #include <rtems/bsd/sys/unistd.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/conf.h> #include <sys/conf.h>
@ -53,7 +53,9 @@
#include <sys/filedesc.h> #include <sys/filedesc.h>
#include <sys/jail.h> #include <sys/jail.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#ifndef __rtems__
#include <sys/lockf.h> #include <sys/lockf.h>
#endif /* __rtems__ */
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <sys/mount.h> #include <sys/mount.h>
@ -77,7 +79,9 @@
#include <sys/acl.h> #include <sys/acl.h>
#include <sys/module.h> #include <sys/module.h>
#include <sys/sysent.h> #include <sys/sysent.h>
#ifndef __rtems__
#include <sys/syscall.h> #include <sys/syscall.h>
#endif /* __rtems__ */
#include <sys/priv.h> #include <sys/priv.h>
#include <sys/kthread.h> #include <sys/kthread.h>
#include <sys/syscallsubr.h> #include <sys/syscallsubr.h>
@ -108,6 +112,7 @@
* (This is always defined as nil otherwise.) * (This is always defined as nil otherwise.)
*/ */
#define APPLESTATIC #define APPLESTATIC
#ifndef __rtems__
#include <ufs/ufs/dir.h> #include <ufs/ufs/dir.h>
#include <ufs/ufs/quota.h> #include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h> #include <ufs/ufs/inode.h>
@ -117,9 +122,10 @@
#include <vm/vm.h> #include <vm/vm.h>
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vm_extern.h> #include <vm/vm_extern.h>
#endif /* __rtems__ */
#include <nfs/nfssvc.h> #include <nfs/nfssvc.h>
#include "opt_nfs.h" #include <rtems/bsd/local/opt_nfs.h>
#include "opt_ufs.h" #include <rtems/bsd/local/opt_ufs.h>
/* /*
* These types must be defined before the nfs includes. * These types must be defined before the nfs includes.
@ -697,8 +703,13 @@ void nfsrvd_rcv(struct socket *, void *, int);
#define NFSASSERTIOD() mtx_assert(&ncl_iod_mutex, MA_OWNED) #define NFSASSERTIOD() mtx_assert(&ncl_iod_mutex, MA_OWNED)
#define NFSLOCKREQUEST(r) mtx_lock(&((r)->r_mtx)) #define NFSLOCKREQUEST(r) mtx_lock(&((r)->r_mtx))
#define NFSUNLOCKREQUEST(r) mtx_unlock(&((r)->r_mtx)) #define NFSUNLOCKREQUEST(r) mtx_unlock(&((r)->r_mtx))
#ifndef __rtems__
#define NFSPROCLISTLOCK() sx_slock(&allproc_lock) #define NFSPROCLISTLOCK() sx_slock(&allproc_lock)
#define NFSPROCLISTUNLOCK() sx_sunlock(&allproc_lock) #define NFSPROCLISTUNLOCK() sx_sunlock(&allproc_lock)
#else /* __rtems__ */
#define NFSPROCLISTLOCK()
#define NFSPROCLISTUNLOCK()
#endif /* __rtems__ */
#define NFSLOCKSOCKREQ(r) mtx_lock(&((r)->nr_mtx)) #define NFSLOCKSOCKREQ(r) mtx_lock(&((r)->nr_mtx))
#define NFSUNLOCKSOCKREQ(r) mtx_unlock(&((r)->nr_mtx)) #define NFSUNLOCKSOCKREQ(r) mtx_unlock(&((r)->nr_mtx))
#define NFSLOCKDS(d) mtx_lock(&((d)->nfsclds_mtx)) #define NFSLOCKDS(d) mtx_lock(&((d)->nfsclds_mtx))

View File

@ -96,7 +96,8 @@ void ncl_doio_directwrite(struct buf *);
int ncl_bioread(struct vnode *, struct uio *, int, struct ucred *); int ncl_bioread(struct vnode *, struct uio *, int, struct ucred *);
int ncl_biowrite(struct vnode *, struct uio *, int, struct ucred *); int ncl_biowrite(struct vnode *, struct uio *, int, struct ucred *);
int ncl_vinvalbuf(struct vnode *, int, struct thread *, int); int ncl_vinvalbuf(struct vnode *, int, struct thread *, int);
int ncl_asyncio(struct nfsmount *, struct buf *, struct ucred *, int ncl_asyncio(struct
nfsmount *, struct buf *, struct ucred *,
struct thread *); struct thread *);
int ncl_doio(struct vnode *, struct buf *, struct ucred *, struct thread *, int ncl_doio(struct vnode *, struct buf *, struct ucred *, struct thread *,
int); int);

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -53,7 +55,9 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_page.h> #include <vm/vm_page.h>
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vm_pager.h> #include <vm/vm_pager.h>
#ifndef __rtems__
#include <vm/vnode_pager.h> #include <vm/vnode_pager.h>
#endif /* __rtems__ */
#include <fs/nfs/nfsport.h> #include <fs/nfs/nfsport.h>
#include <fs/nfsclient/nfsmount.h> #include <fs/nfsclient/nfsmount.h>
@ -173,10 +177,12 @@ ncl_getpages(struct vop_getpages_args *ap)
* *
* XXXGL: is that true for NFS, where short read can occur??? * XXXGL: is that true for NFS, where short read can occur???
*/ */
#ifndef __rtems__
VM_OBJECT_WLOCK(object); VM_OBJECT_WLOCK(object);
if (pages[npages - 1]->valid != 0 && --npages == 0) if (pages[npages - 1]->valid != 0 && --npages == 0)
goto out; goto out;
VM_OBJECT_WUNLOCK(object); VM_OBJECT_WUNLOCK(object);
#endif /* __rtems__*/
/* /*
* We use only the kva address for the buffer, but this is extremely * We use only the kva address for the buffer, but this is extremely
@ -185,7 +191,9 @@ ncl_getpages(struct vop_getpages_args *ap)
bp = getpbuf(&ncl_pbuf_freecnt); bp = getpbuf(&ncl_pbuf_freecnt);
kva = (vm_offset_t) bp->b_data; kva = (vm_offset_t) bp->b_data;
#ifndef __rtems__
pmap_qenter(kva, pages, npages); pmap_qenter(kva, pages, npages);
#endif /* __rtems__*/
VM_CNT_INC(v_vnodein); VM_CNT_INC(v_vnodein);
VM_CNT_ADD(v_vnodepgsin, npages); VM_CNT_ADD(v_vnodepgsin, npages);
@ -194,14 +202,20 @@ ncl_getpages(struct vop_getpages_args *ap)
iov.iov_len = count; iov.iov_len = count;
uio.uio_iov = &iov; uio.uio_iov = &iov;
uio.uio_iovcnt = 1; uio.uio_iovcnt = 1;
#ifndef __rtems__
uio.uio_offset = IDX_TO_OFF(pages[0]->pindex); uio.uio_offset = IDX_TO_OFF(pages[0]->pindex);
#else /* __rtems__*/
uio.uio_offset = 0;
#endif /* __rtems__*/
uio.uio_resid = count; uio.uio_resid = count;
uio.uio_segflg = UIO_SYSSPACE; uio.uio_segflg = UIO_SYSSPACE;
uio.uio_rw = UIO_READ; uio.uio_rw = UIO_READ;
uio.uio_td = td; uio.uio_td = td;
error = ncl_readrpc(vp, &uio, cred); error = ncl_readrpc(vp, &uio, cred);
#ifndef __rtems__
pmap_qremove(kva, npages); pmap_qremove(kva, npages);
#endif /* __rtems__*/
relpbuf(bp, &ncl_pbuf_freecnt); relpbuf(bp, &ncl_pbuf_freecnt);
@ -221,6 +235,7 @@ ncl_getpages(struct vop_getpages_args *ap)
for (i = 0, toff = 0; i < npages; i++, toff = nextoff) { for (i = 0, toff = 0; i < npages; i++, toff = nextoff) {
vm_page_t m; vm_page_t m;
nextoff = toff + PAGE_SIZE; nextoff = toff + PAGE_SIZE;
#ifndef __rtems__
m = pages[i]; m = pages[i];
if (nextoff <= size) { if (nextoff <= size) {
@ -250,8 +265,11 @@ ncl_getpages(struct vop_getpages_args *ap)
*/ */
; ;
} }
#endif /* __rtems__*/
} }
#ifndef __rtems__
out: out:
#endif /* __rtems__ */
VM_OBJECT_WUNLOCK(object); VM_OBJECT_WUNLOCK(object);
if (ap->a_rbehind) if (ap->a_rbehind)
*ap->a_rbehind = 0; *ap->a_rbehind = 0;
@ -291,7 +309,11 @@ ncl_putpages(struct vop_putpages_args *ap)
count = ap->a_count; count = ap->a_count;
rtvals = ap->a_rtvals; rtvals = ap->a_rtvals;
npages = btoc(count); npages = btoc(count);
#ifndef __rtems__
offset = IDX_TO_OFF(pages[0]->pindex); offset = IDX_TO_OFF(pages[0]->pindex);
#else /* __rtems__*/
offset = 0;
#endif /* __rtems__*/
mtx_lock(&nmp->nm_mtx); mtx_lock(&nmp->nm_mtx);
if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
@ -334,14 +356,20 @@ ncl_putpages(struct vop_putpages_args *ap)
uio.uio_rw = UIO_WRITE; uio.uio_rw = UIO_WRITE;
uio.uio_td = td; uio.uio_td = td;
#ifndef __rtems__
error = VOP_WRITE(vp, &uio, vnode_pager_putpages_ioflags(ap->a_sync), error = VOP_WRITE(vp, &uio, vnode_pager_putpages_ioflags(ap->a_sync),
cred); cred);
#else /* __rtems__*/
error = VOP_WRITE(vp, &uio, 0, cred);
#endif /* __rtems__*/
crfree(cred); crfree(cred);
#ifndef __rtems__
if (error == 0 || !nfs_keep_dirty_on_error) { if (error == 0 || !nfs_keep_dirty_on_error) {
vnode_pager_undirty_pages(pages, rtvals, count - uio.uio_resid, vnode_pager_undirty_pages(pages, rtvals, count - uio.uio_resid,
np->n_size - offset, npages * PAGE_SIZE); np->n_size - offset, npages * PAGE_SIZE);
} }
#endif /* __rtems__*/
return (rtvals[0]); return (rtvals[0]);
} }
@ -709,6 +737,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
return (error); return (error);
} }
#ifdef __rtems__
/* /*
* The NFS write path cannot handle iovecs with len > 1. So we need to * The NFS write path cannot handle iovecs with len > 1. So we need to
* break up iovecs accordingly (restricting them to wsize). * break up iovecs accordingly (restricting them to wsize).
@ -855,6 +884,7 @@ err_free:
} }
return (0); return (0);
} }
#endif /* __rtems__ */
/* /*
* Vnode op for write using bio * Vnode op for write using bio
@ -1044,7 +1074,9 @@ again:
NFSLOCKNODE(np); NFSLOCKNODE(np);
np->n_size = uio->uio_offset + n; np->n_size = uio->uio_offset + n;
np->n_flag |= NMODIFIED; np->n_flag |= NMODIFIED;
#ifndef __rtems__
vnode_pager_setsize(vp, np->n_size); vnode_pager_setsize(vp, np->n_size);
#endif /* __rems__ */
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
save = bp->b_flags & B_CACHE; save = bp->b_flags & B_CACHE;
@ -1073,7 +1105,9 @@ again:
if (uio->uio_offset + n > np->n_size) { if (uio->uio_offset + n > np->n_size) {
np->n_size = uio->uio_offset + n; np->n_size = uio->uio_offset + n;
np->n_flag |= NMODIFIED; np->n_flag |= NMODIFIED;
#ifndef __rtems__
vnode_pager_setsize(vp, np->n_size); vnode_pager_setsize(vp, np->n_size);
#endif /* __rems__ */
} }
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
} }
@ -1265,6 +1299,7 @@ again:
return (error); return (error);
} }
#ifdef __rtems__
/* /*
* Get an nfs cache block. * Get an nfs cache block.
* *
@ -1309,6 +1344,7 @@ nfs_getcacheblk(struct vnode *vp, daddr_t bn, int size, struct thread *td)
bp->b_blkno = bn * (vp->v_bufobj.bo_bsize / DEV_BSIZE); bp->b_blkno = bn * (vp->v_bufobj.bo_bsize / DEV_BSIZE);
return (bp); return (bp);
} }
#endif /* __rtems__ */
/* /*
* Flush and invalidate all dirty buffers. If another process is already * Flush and invalidate all dirty buffers. If another process is already
@ -1345,9 +1381,11 @@ ncl_vinvalbuf(struct vnode *vp, int flags, struct thread *td, int intrflg)
*/ */
if ((flags & (V_SAVE | V_VMIO)) == V_SAVE && if ((flags & (V_SAVE | V_VMIO)) == V_SAVE &&
vp->v_bufobj.bo_object != NULL) { vp->v_bufobj.bo_object != NULL) {
#ifndef __rtems__
VM_OBJECT_WLOCK(vp->v_bufobj.bo_object); VM_OBJECT_WLOCK(vp->v_bufobj.bo_object);
vm_object_page_clean(vp->v_bufobj.bo_object, 0, 0, OBJPC_SYNC); vm_object_page_clean(vp->v_bufobj.bo_object, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(vp->v_bufobj.bo_object); VM_OBJECT_WUNLOCK(vp->v_bufobj.bo_object);
#endif /* __rtems__*/
/* /*
* If the page clean was interrupted, fail the invalidation. * If the page clean was interrupted, fail the invalidation.
* Not doing so, we run the risk of losing dirty pages in the * Not doing so, we run the risk of losing dirty pages in the
@ -1392,6 +1430,9 @@ out:
int int
ncl_asyncio(struct nfsmount *nmp, struct buf *bp, struct ucred *cred, struct thread *td) ncl_asyncio(struct nfsmount *nmp, struct buf *bp, struct ucred *cred, struct thread *td)
{ {
#ifdef __rtems__
return (EOPNOTSUPP);
#else /* __rtems__ */
int iod; int iod;
int gotiod; int gotiod;
int slpflag = 0; int slpflag = 0;
@ -1533,12 +1574,16 @@ again:
* force the caller to process the i/o synchronously. * force the caller to process the i/o synchronously.
*/ */
NFS_DPF(ASYNCIO, ("ncl_asyncio: no iods available, i/o is synchronous\n")); NFS_DPF(ASYNCIO, ("ncl_asyncio: no iods available, i/o is synchronous\n"));
#endif /* __rtems__ */
return (EIO); return (EIO);
} }
void void
ncl_doio_directwrite(struct buf *bp) ncl_doio_directwrite(struct buf *bp)
{ {
#ifdef __rtems__
panic("not supported in RTEMS");
#else /* __rtems__ */
int iomode, must_commit; int iomode, must_commit;
struct uio *uiop = (struct uio *)bp->b_caller1; struct uio *uiop = (struct uio *)bp->b_caller1;
char *iov_base = uiop->uio_iov->iov_base; char *iov_base = uiop->uio_iov->iov_base;
@ -1572,6 +1617,7 @@ ncl_doio_directwrite(struct buf *bp)
} }
bp->b_vp = NULL; bp->b_vp = NULL;
relpbuf(bp, &ncl_pbuf_freecnt); relpbuf(bp, &ncl_pbuf_freecnt);
#endif /* __rtems__ */
} }
/* /*
@ -1643,9 +1689,13 @@ ncl_doio(struct vnode *vp, struct buf *bp, struct ucred *cr, struct thread *td,
NFSLOCKNODE(np); NFSLOCKNODE(np);
if (NFS_TIMESPEC_COMPARE(&np->n_mtime, &np->n_vattr.na_mtime)) { if (NFS_TIMESPEC_COMPARE(&np->n_mtime, &np->n_vattr.na_mtime)) {
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
#ifndef __rtems__
PROC_LOCK(p); PROC_LOCK(p);
killproc(p, "text file modification"); killproc(p, "text file modification");
PROC_UNLOCK(p); PROC_UNLOCK(p);
#else /* __rtems__ */
panic("nfsclient: text file modification: want to killproc");
#endif /* _-rtems__ */
} else } else
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
} }
@ -1867,8 +1917,9 @@ ncl_meta_setsize(struct vnode *vp, struct thread *td, u_quad_t nsize)
bp->b_flags |= B_RELBUF; /* don't leave garbage around */ bp->b_flags |= B_RELBUF; /* don't leave garbage around */
brelse(bp); brelse(bp);
} else { } else {
#ifndef __rtems__
vnode_pager_setsize(vp, nsize); vnode_pager_setsize(vp, nsize);
#endif /* __rtems__ */
} }
return(error); return(error);
} }

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
* *
@ -29,6 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#ifndef __rtems__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
@ -585,3 +588,4 @@ MODULE_DEPEND(dtnfscl, dtrace, 1, 1, 1);
MODULE_DEPEND(dtnfscl, opensolaris, 1, 1, 1); MODULE_DEPEND(dtnfscl, opensolaris, 1, 1, 1);
MODULE_DEPEND(dtnfscl, nfscl, 1, 1, 1); MODULE_DEPEND(dtnfscl, nfscl, 1, 1, 1);
MODULE_DEPEND(dtnfscl, nfscommon, 1, 1, 1); MODULE_DEPEND(dtnfscl, nfscommon, 1, 1, 1);
#endif /* __rtems__ */

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -36,7 +38,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include "opt_kgssapi.h" #include <rtems/bsd/local/opt_kgssapi.h>
#include <fs/nfs/nfsport.h> #include <fs/nfs/nfsport.h>
@ -296,4 +298,3 @@ nfsrvd_cbinit(int terminating)
NFSD_LOCK(); NFSD_LOCK();
} }
} }

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -55,10 +57,12 @@ __FBSDID("$FreeBSD$");
#include <sys/domain.h> #include <sys/domain.h>
#include <sys/protosw.h> #include <sys/protosw.h>
#include <sys/namei.h> #include <sys/namei.h>
#include <sys/unistd.h> #include <rtems/bsd/sys/unistd.h>
#include <sys/kthread.h> #include <sys/kthread.h>
#include <sys/fcntl.h> #include <sys/fcntl.h>
#ifndef __rtems__
#include <sys/lockf.h> #include <sys/lockf.h>
#endif /* __rtems__ */
#include <sys/mutex.h> #include <sys/mutex.h>
#include <sys/taskqueue.h> #include <sys/taskqueue.h>

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -142,7 +144,11 @@ ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize, struct nfsnode **npp,
* destroy the mutex (in the case of the loser, or if hash_insert * destroy the mutex (in the case of the loser, or if hash_insert
* happened to return an error no special casing is needed). * happened to return an error no special casing is needed).
*/ */
#ifndef __rtems__
mtx_init(&np->n_mtx, "NEWNFSnode lock", NULL, MTX_DEF | MTX_DUPOK); mtx_init(&np->n_mtx, "NEWNFSnode lock", NULL, MTX_DEF | MTX_DUPOK);
#else /* __rtems__ */
mtx_init(&np->n_mtx, "NEWNFSnode lock", NULL, MTX_DEF | MTX_DUPOK | MTX_RECURSE);
#endif /* __rtems__ */
lockinit(&np->n_excl, PVFS, "nfsupg", VLKTIMEOUT, LK_NOSHARE | lockinit(&np->n_excl, PVFS, "nfsupg", VLKTIMEOUT, LK_NOSHARE |
LK_CANRECURSE); LK_CANRECURSE);
@ -250,8 +256,10 @@ ncl_inactive(struct vop_inactive_args *ap)
*/ */
if (vp->v_object != NULL) { if (vp->v_object != NULL) {
VM_OBJECT_WLOCK(vp->v_object); VM_OBJECT_WLOCK(vp->v_object);
#ifndef __rtems__
retv = vm_object_page_clean(vp->v_object, 0, 0, retv = vm_object_page_clean(vp->v_object, 0, 0,
OBJPC_SYNC); OBJPC_SYNC);
#endif /* __rtems__ */
VM_OBJECT_WUNLOCK(vp->v_object); VM_OBJECT_WUNLOCK(vp->v_object);
} else } else
retv = TRUE; retv = TRUE;
@ -301,7 +309,9 @@ ncl_reclaim(struct vop_reclaim_args *ap)
/* /*
* Destroy the vm object and flush associated pages. * Destroy the vm object and flush associated pages.
*/ */
#ifndef __rtems__
vnode_destroy_vobject(vp); vnode_destroy_vobject(vp);
#endif /* __rtems__ */
if (NFS_ISV4(vp) && vp->v_type == VREG) if (NFS_ISV4(vp) && vp->v_type == VREG)
/* /*

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -36,8 +38,8 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include "opt_inet.h" #include <rtems/bsd/local/opt_inet.h>
#include "opt_inet6.h" #include <rtems/bsd/local/opt_inet6.h>
#include <sys/capsicum.h> #include <sys/capsicum.h>
@ -232,7 +234,11 @@ nfscl_nget(struct mount *mntp, struct vnode *dvp, struct nfsfh *nfhp,
* destroy the mutex (in the case of the loser, or if hash_insert * destroy the mutex (in the case of the loser, or if hash_insert
* happened to return an error no special casing is needed). * happened to return an error no special casing is needed).
*/ */
#ifndef __rtems__
mtx_init(&np->n_mtx, "NEWNFSnode lock", NULL, MTX_DEF | MTX_DUPOK); mtx_init(&np->n_mtx, "NEWNFSnode lock", NULL, MTX_DEF | MTX_DUPOK);
#else /* __rtems__ */
mtx_init(&np->n_mtx, "NEWNFSnode lock", NULL, MTX_DEF | MTX_DUPOK | MTX_RECURSE);
#endif /* __rtems__ */
lockinit(&np->n_excl, PVFS, "nfsupg", VLKTIMEOUT, LK_NOSHARE | lockinit(&np->n_excl, PVFS, "nfsupg", VLKTIMEOUT, LK_NOSHARE |
LK_CANRECURSE); LK_CANRECURSE);
@ -432,7 +438,11 @@ nfscl_loadattrcache(struct vnode **vpp, struct nfsvattr *nap, void *nvaper,
if (vp->v_type != nvap->va_type) { if (vp->v_type != nvap->va_type) {
vp->v_type = nvap->va_type; vp->v_type = nvap->va_type;
if (vp->v_type == VFIFO) if (vp->v_type == VFIFO)
#ifndef __rtems__
vp->v_op = &newnfs_fifoops; vp->v_op = &newnfs_fifoops;
#else /* __rtems__ */
panic("no newnfs_fifoops");
#endif /* __rtems__ */
np->n_mtime = nvap->va_mtime; np->n_mtime = nvap->va_mtime;
} }
nmp = VFSTONFS(vp->v_mount); nmp = VFSTONFS(vp->v_mount);
@ -596,16 +606,20 @@ ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep)
object = vp->v_object; object = vp->v_object;
setnsize = false; setnsize = false;
#ifndef __rtems__
if (object != NULL && nsize != object->un_pager.vnp.vnp_size) { if (object != NULL && nsize != object->un_pager.vnp.vnp_size) {
if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
setnsize = true; setnsize = true;
else else
np->n_flag |= NVNSETSZSKIP; np->n_flag |= NVNSETSZSKIP;
} }
#endif /* __rtems__ */
if (nsizep == NULL) { if (nsizep == NULL) {
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
#ifndef __rtems__
if (setnsize) if (setnsize)
vnode_pager_setsize(vp, nsize); vnode_pager_setsize(vp, nsize);
#endif /* __rtems__ */
setnsize = false; setnsize = false;
} else { } else {
*nsizep = nsize; *nsizep = nsize;
@ -678,12 +692,20 @@ nfscl_filllockowner(void *id, u_int8_t *cp, int flags)
*cp++ = tl.cval[1]; *cp++ = tl.cval[1];
*cp++ = tl.cval[2]; *cp++ = tl.cval[2];
*cp++ = tl.cval[3]; *cp++ = tl.cval[3];
#ifndef __rtems__
tl.lval = p->p_stats->p_start.tv_sec; tl.lval = p->p_stats->p_start.tv_sec;
#else /* __rtems__ */
tl.lval = 0;
#endif /* __rtems__ */
*cp++ = tl.cval[0]; *cp++ = tl.cval[0];
*cp++ = tl.cval[1]; *cp++ = tl.cval[1];
*cp++ = tl.cval[2]; *cp++ = tl.cval[2];
*cp++ = tl.cval[3]; *cp++ = tl.cval[3];
#ifndef __rtems__
tl.lval = p->p_stats->p_start.tv_usec; tl.lval = p->p_stats->p_start.tv_usec;
#else /* __rtems__ */
tl.lval = 0;
#endif /* __rtems__ */
*cp++ = tl.cval[0]; *cp++ = tl.cval[0];
*cp++ = tl.cval[1]; *cp++ = tl.cval[1];
*cp++ = tl.cval[2]; *cp++ = tl.cval[2];
@ -705,6 +727,7 @@ nfscl_filllockowner(void *id, u_int8_t *cp, int flags)
NFSPROC_T * NFSPROC_T *
nfscl_getparent(struct thread *td) nfscl_getparent(struct thread *td)
{ {
#ifndef __rtems__
struct proc *p; struct proc *p;
struct thread *ptd; struct thread *ptd;
@ -718,6 +741,9 @@ nfscl_getparent(struct thread *td)
return (NULL); return (NULL);
ptd = TAILQ_FIRST(&p->p_threads); ptd = TAILQ_FIRST(&p->p_threads);
return (ptd); return (ptd);
#else /* __rtems__ */
return (NULL);
#endif /* __rtems__ */
} }
/* /*
@ -730,7 +756,11 @@ start_nfscl(void *arg)
struct thread *td; struct thread *td;
clp = (struct nfsclclient *)arg; clp = (struct nfsclclient *)arg;
#ifndef __rtems__
td = TAILQ_FIRST(&clp->nfsc_renewthread->p_threads); td = TAILQ_FIRST(&clp->nfsc_renewthread->p_threads);
#else /* __rtems__ */
td = rtems_bsd_get_curthread_or_wait_forever();
#endif /* __rtems__ */
nfscl_renewthread(clp, td); nfscl_renewthread(clp, td);
kproc_exit(0); kproc_exit(0);
} }
@ -971,7 +1001,11 @@ nfscl_getmyip(struct nfsmount *nmp, struct in6_addr *paddr, int *isinet6p)
#if defined(INET6) || defined(INET) #if defined(INET6) || defined(INET)
int error, fibnum; int error, fibnum;
#ifndef __rtems__
fibnum = curthread->td_proc->p_fibnum; fibnum = curthread->td_proc->p_fibnum;
#else /* __rtems__ */
fibnum = 0;
#endif /* __rtems__ */
#endif #endif
#ifdef INET #ifdef INET
if (nmp->nm_nam->sa_family == AF_INET) { if (nmp->nm_nam->sa_family == AF_INET) {
@ -1052,6 +1086,9 @@ nfscl_init(void)
inited = 1; inited = 1;
nfscl_inited = 1; nfscl_inited = 1;
ncl_pbuf_freecnt = nswbuf / 2 + 1; ncl_pbuf_freecnt = nswbuf / 2 + 1;
#ifdef __rtems__
ncl_pbuf_zone = pbuf_zsecond_create("nfspbuf", ncl_pbuf_freecnt);
#endif /* __rtems__ */
} }
/* /*
@ -1173,6 +1210,7 @@ nfscl_procdoesntexist(u_int8_t *own)
pid_t pid; pid_t pid;
int i, ret = 0; int i, ret = 0;
#ifndef __rtems__
/* For the single open_owner of all 0 bytes, just return 0. */ /* For the single open_owner of all 0 bytes, just return 0. */
for (i = 0; i < NFSV4CL_LOCKNAMELEN; i++) for (i = 0; i < NFSV4CL_LOCKNAMELEN; i++)
if (own[i] != 0) if (own[i] != 0)
@ -1207,6 +1245,7 @@ nfscl_procdoesntexist(u_int8_t *own)
ret = 1; ret = 1;
} }
PROC_UNLOCK(p); PROC_UNLOCK(p);
#endif /* __rtems__ */
return (ret); return (ret);
} }
@ -1243,10 +1282,12 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *uap)
cap_rights_init(&rights, CAP_SOCK_CLIENT), &fp); cap_rights_init(&rights, CAP_SOCK_CLIENT), &fp);
if (error) if (error)
return (error); return (error);
#ifndef __rtems__
if (fp->f_type != DTYPE_SOCKET) { if (fp->f_type != DTYPE_SOCKET) {
fdrop(fp, td); fdrop(fp, td);
return (EPERM); return (EPERM);
} }
#endif /* __rtems__ */
error = nfscbd_addsock(fp); error = nfscbd_addsock(fp);
fdrop(fp, td); fdrop(fp, td);
if (!error && nfscl_enablecallb == 0) { if (!error && nfscl_enablecallb == 0) {
@ -1411,4 +1452,3 @@ MODULE_DEPEND(nfscl, nfscommon, 1, 1, 1);
MODULE_DEPEND(nfscl, krpc, 1, 1, 1); MODULE_DEPEND(nfscl, krpc, 1, 1, 1);
MODULE_DEPEND(nfscl, nfssvc, 1, 1, 1); MODULE_DEPEND(nfscl, nfssvc, 1, 1, 1);
MODULE_DEPEND(nfscl, nfslock, 1, 1, 1); MODULE_DEPEND(nfscl, nfslock, 1, 1, 1);

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -45,7 +47,7 @@ __FBSDID("$FreeBSD$");
*/ */
#ifndef APPLEKEXT #ifndef APPLEKEXT
#include "opt_inet6.h" #include <rtems/bsd/local/opt_inet6.h>
#include <fs/nfs/nfsport.h> #include <fs/nfs/nfsport.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
@ -2959,41 +2961,57 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
return (error); return (error);
nd->nd_mrep = NULL; nd->nd_mrep = NULL;
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
#ifndef __rtems__
dp->d_pad0 = dp->d_pad1 = 0; dp->d_pad0 = dp->d_pad1 = 0;
#endif /* __rtems__ */
dp->d_off = 0; dp->d_off = 0;
dp->d_type = DT_DIR; dp->d_type = DT_DIR;
dp->d_fileno = dotfileid; dp->d_fileno = dotfileid;
dp->d_namlen = 1; dp->d_namlen = 1;
#ifndef __rtems__
*((uint64_t *)dp->d_name) = 0; /* Zero pad it. */ *((uint64_t *)dp->d_name) = 0; /* Zero pad it. */
#else /* __rtems__ */
dp->d_name[1] = '\0';
#endif /* __rtems__ */
dp->d_name[0] = '.'; dp->d_name[0] = '.';
dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER; dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER;
/* /*
* Just make these offset cookie 0. * Just make these offset cookie 0.
*/ */
#ifndef __rtems__
tl = (u_int32_t *)&dp->d_name[8]; tl = (u_int32_t *)&dp->d_name[8];
*tl++ = 0; *tl++ = 0;
*tl = 0; *tl = 0;
#endif /* __rtems__ */
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
uio_uio_resid_add(uiop, -(dp->d_reclen)); uio_uio_resid_add(uiop, -(dp->d_reclen));
uiop->uio_offset += dp->d_reclen; uiop->uio_offset += dp->d_reclen;
uio_iov_base_add(uiop, dp->d_reclen); uio_iov_base_add(uiop, dp->d_reclen);
uio_iov_len_add(uiop, -(dp->d_reclen)); uio_iov_len_add(uiop, -(dp->d_reclen));
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
#ifndef __rtems__
dp->d_pad0 = dp->d_pad1 = 0; dp->d_pad0 = dp->d_pad1 = 0;
#endif /* __rtems__ */
dp->d_off = 0; dp->d_off = 0;
dp->d_type = DT_DIR; dp->d_type = DT_DIR;
dp->d_fileno = dotdotfileid; dp->d_fileno = dotdotfileid;
dp->d_namlen = 2; dp->d_namlen = 2;
#ifndef __rtems__
*((uint64_t *)dp->d_name) = 0; *((uint64_t *)dp->d_name) = 0;
#else __rtems__
dp->d_name[2] = '\0';
#endif /* __rtems__ */
dp->d_name[0] = '.'; dp->d_name[0] = '.';
dp->d_name[1] = '.'; dp->d_name[1] = '.';
dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER; dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER;
/* /*
* Just make these offset cookie 0. * Just make these offset cookie 0.
*/ */
#ifndef __rtems__
tl = (u_int32_t *)&dp->d_name[8]; tl = (u_int32_t *)&dp->d_name[8];
*tl++ = 0; *tl++ = 0;
*tl = 0; *tl = 0;
#endif /* __rtems__ */
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
uio_uio_resid_add(uiop, -(dp->d_reclen)); uio_uio_resid_add(uiop, -(dp->d_reclen));
uiop->uio_offset += dp->d_reclen; uiop->uio_offset += dp->d_reclen;
@ -3106,7 +3124,9 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
bigenough = 0; bigenough = 0;
if (bigenough) { if (bigenough) {
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
#ifndef __rtems__
dp->d_pad0 = dp->d_pad1 = 0; dp->d_pad0 = dp->d_pad1 = 0;
#endif /* __rtems__ */
dp->d_off = 0; dp->d_off = 0;
dp->d_namlen = len; dp->d_namlen = len;
dp->d_reclen = _GENERIC_DIRLEN(len) + dp->d_reclen = _GENERIC_DIRLEN(len) +
@ -3127,6 +3147,10 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
NFSBZERO(cp, tlen); NFSBZERO(cp, tlen);
cp += tlen; /* points to cookie storage */ cp += tlen; /* points to cookie storage */
tl2 = (u_int32_t *)cp; tl2 = (u_int32_t *)cp;
#ifdef __rtems__
tlen = dp->d_reclen -
(((char*) uio_iov_base(uiop) - (char*) dp) + NFSX_HYPER);
#endif /* __rtems__ */
uio_iov_base_add(uiop, (tlen + NFSX_HYPER)); uio_iov_base_add(uiop, (tlen + NFSX_HYPER));
uio_iov_len_add(uiop, -(tlen + NFSX_HYPER)); uio_iov_len_add(uiop, -(tlen + NFSX_HYPER));
uio_uio_resid_add(uiop, -(tlen + NFSX_HYPER)); uio_uio_resid_add(uiop, -(tlen + NFSX_HYPER));
@ -3242,9 +3266,14 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
NFSBZERO(dp, DIRBLKSIZ); NFSBZERO(dp, DIRBLKSIZ);
dp->d_type = DT_UNKNOWN; dp->d_type = DT_UNKNOWN;
#ifndef __rtems__
tl = (u_int32_t *)&dp->d_name[4]; tl = (u_int32_t *)&dp->d_name[4];
*tl++ = cookie.lval[0]; *tl++ = cookie.lval[0];
*tl = cookie.lval[1]; *tl = cookie.lval[1];
#else /* __rtems__ */
memcpy(&dp->d_name[8], &cookie.lval[0], sizeof(u_int32_t));
memcpy(&dp->d_name[8 + sizeof(u_int32_t)], &cookie.lval[1], sizeof(u_int32_t));
#endif /* __rtems__ */
dp->d_reclen = DIRBLKSIZ; dp->d_reclen = DIRBLKSIZ;
uio_iov_base_add(uiop, DIRBLKSIZ); uio_iov_base_add(uiop, DIRBLKSIZ);
uio_iov_len_add(uiop, -(DIRBLKSIZ)); uio_iov_len_add(uiop, -(DIRBLKSIZ));
@ -3396,41 +3425,61 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
return (error); return (error);
nd->nd_mrep = NULL; nd->nd_mrep = NULL;
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
#ifndef __rtems__
dp->d_pad0 = dp->d_pad1 = 0; dp->d_pad0 = dp->d_pad1 = 0;
#endif /* __rtems__ */
dp->d_off = 0; dp->d_off = 0;
dp->d_type = DT_DIR; dp->d_type = DT_DIR;
dp->d_fileno = dotfileid; dp->d_fileno = dotfileid;
dp->d_namlen = 1; dp->d_namlen = 1;
#ifndef __rtems__
*((uint64_t *)dp->d_name) = 0; /* Zero pad it. */ *((uint64_t *)dp->d_name) = 0; /* Zero pad it. */
#else /* __rtems__ */
dp->d_name[0] = dp->d_name[1] = dp->d_name[2] = dp->d_name[3] = '\0';
#endif /* __rtems__ */
dp->d_name[0] = '.'; dp->d_name[0] = '.';
dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER; dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER;
/* /*
* Just make these offset cookie 0. * Just make these offset cookie 0.
*/ */
#ifndef __rtems__
tl = (u_int32_t *)&dp->d_name[8]; tl = (u_int32_t *)&dp->d_name[8];
*tl++ = 0; *tl++ = 0;
*tl = 0; *tl = 0;
#else /* __rtems__ */
memset(&dp->d_name[8], 0, 2 * sizeof(u_int32_t));
#endif /* __rtems__ */
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
uio_uio_resid_add(uiop, -(dp->d_reclen)); uio_uio_resid_add(uiop, -(dp->d_reclen));
uiop->uio_offset += dp->d_reclen; uiop->uio_offset += dp->d_reclen;
uio_iov_base_add(uiop, dp->d_reclen); uio_iov_base_add(uiop, dp->d_reclen);
uio_iov_len_add(uiop, -(dp->d_reclen)); uio_iov_len_add(uiop, -(dp->d_reclen));
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
#ifndef __rtems__
dp->d_pad0 = dp->d_pad1 = 0; dp->d_pad0 = dp->d_pad1 = 0;
#endif /* __rtems__ */
dp->d_off = 0; dp->d_off = 0;
dp->d_type = DT_DIR; dp->d_type = DT_DIR;
dp->d_fileno = dotdotfileid; dp->d_fileno = dotdotfileid;
dp->d_namlen = 2; dp->d_namlen = 2;
#ifndef __rtems__
*((uint64_t *)dp->d_name) = 0; *((uint64_t *)dp->d_name) = 0;
#else /* __rtems__ */
dp->d_name[0] = dp->d_name[1] = dp->d_name[2] = dp->d_name[3] = '\0';
#endif /* __rtems__ */
dp->d_name[0] = '.'; dp->d_name[0] = '.';
dp->d_name[1] = '.'; dp->d_name[1] = '.';
dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER; dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER;
/* /*
* Just make these offset cookie 0. * Just make these offset cookie 0.
*/ */
#ifndef __rtems__
tl = (u_int32_t *)&dp->d_name[8]; tl = (u_int32_t *)&dp->d_name[8];
*tl++ = 0; *tl++ = 0;
*tl = 0; *tl = 0;
#else /* __rtems__ */
memset(&dp->d_name[8], 0, 2 * sizeof(u_int32_t));
#endif /* __rtems__ */
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
uio_uio_resid_add(uiop, -(dp->d_reclen)); uio_uio_resid_add(uiop, -(dp->d_reclen));
uiop->uio_offset += dp->d_reclen; uiop->uio_offset += dp->d_reclen;
@ -3524,7 +3573,9 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
bigenough = 0; bigenough = 0;
if (bigenough) { if (bigenough) {
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
#ifndef __rtems__
dp->d_pad0 = dp->d_pad1 = 0; dp->d_pad0 = dp->d_pad1 = 0;
#endif /* __rtems__ */
dp->d_off = 0; dp->d_off = 0;
dp->d_namlen = len; dp->d_namlen = len;
dp->d_reclen = _GENERIC_DIRLEN(len) + dp->d_reclen = _GENERIC_DIRLEN(len) +
@ -3745,9 +3796,14 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
NFSBZERO(dp, DIRBLKSIZ); NFSBZERO(dp, DIRBLKSIZ);
dp->d_type = DT_UNKNOWN; dp->d_type = DT_UNKNOWN;
#ifndef __rtems__
tl = (u_int32_t *)&dp->d_name[4]; tl = (u_int32_t *)&dp->d_name[4];
*tl++ = cookie.lval[0]; *tl++ = cookie.lval[0];
*tl = cookie.lval[1]; *tl = cookie.lval[1];
#else /* __rtems__ */
memcpy(&dp->d_name[8], &cookie.lval[0], sizeof(u_int32_t));
memcpy(&dp->d_name[8 + sizeof(u_int32_t)], &cookie.lval[1], sizeof(u_int32_t));
#endif /* __rtems__ */
dp->d_reclen = DIRBLKSIZ; dp->d_reclen = DIRBLKSIZ;
uio_iov_base_add(uiop, DIRBLKSIZ); uio_iov_base_add(uiop, DIRBLKSIZ);
uio_iov_len_add(uiop, -(DIRBLKSIZ)); uio_iov_len_add(uiop, -(DIRBLKSIZ));
@ -4670,8 +4726,16 @@ nfsrpc_exchangeid(struct nfsmount *nmp, struct nfsclclient *clp,
/* Set the implementation id4 */ /* Set the implementation id4 */
*tl = txdr_unsigned(1); *tl = txdr_unsigned(1);
#ifndef __rtems__
(void) nfsm_strtom(nd, "freebsd.org", strlen("freebsd.org")); (void) nfsm_strtom(nd, "freebsd.org", strlen("freebsd.org"));
(void) nfsm_strtom(nd, version, strlen(version)); (void) nfsm_strtom(nd, version, strlen(version));
#else /* __rtems__ */
{
const char* rv = rtems_version();
(void) nfsm_strtom(nd, "rtems.org", strlen("rtems.org"));
(void) nfsm_strtom(nd, rv, strlen(rv));
}
#endif /* __rtems__ */
NFSM_BUILD(tl, uint32_t *, NFSX_V4TIME); NFSM_BUILD(tl, uint32_t *, NFSX_V4TIME);
verstime.tv_sec = 1293840000; /* Jan 1, 2011 */ verstime.tv_sec = 1293840000; /* Jan 1, 2011 */
verstime.tv_nsec = 0; verstime.tv_nsec = 0;
@ -7663,4 +7727,3 @@ out:
} }
return (laystat); return (laystat);
} }

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
* *
@ -5455,4 +5457,3 @@ tryagain:
NFSUNLOCKCLSTATE(); NFSUNLOCKCLSTATE();
return (0); return (0);
} }

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -57,7 +59,9 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/sysent.h> #include <sys/sysent.h>
#ifndef __rtems__
#include <sys/syscall.h> #include <sys/syscall.h>
#endif /* __rtems__ */
#include <sys/sysproto.h> #include <sys/sysproto.h>
#include <sys/taskqueue.h> #include <sys/taskqueue.h>
@ -256,8 +260,10 @@ ncl_getattrcache(struct vnode *vp, struct vattr *vaper)
vaper->va_mtime = np->n_mtim; vaper->va_mtime = np->n_mtim;
} }
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
#ifndef __rtems__
if (setnsize) if (setnsize)
vnode_pager_setsize(vp, nsize); vnode_pager_setsize(vp, nsize);
#endif /* __rtems__ */
KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap); KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap);
return (0); return (0);
} }
@ -388,4 +394,3 @@ ncl_init(struct vfsconf *vfsp)
return (0); return (0);
} }

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -38,8 +40,8 @@
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include "opt_bootp.h" #include <rtems/bsd/local/opt_bootp.h>
#include "opt_nfsroot.h" #include <rtems/bsd/local/opt_nfsroot.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -49,7 +51,9 @@ __FBSDID("$FreeBSD$");
#include <sys/clock.h> #include <sys/clock.h>
#include <sys/jail.h> #include <sys/jail.h>
#include <sys/limits.h> #include <sys/limits.h>
#ifndef __rtems__
#include <sys/lock.h> #include <sys/lock.h>
#endif /* __rtems__ */
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <sys/module.h> #include <sys/module.h>
@ -446,6 +450,7 @@ nfs_mountroot(struct mount *mp)
error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, td); error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, td);
if (error) if (error)
panic("nfs_mountroot: SIOCAIFADDR: %d", error); panic("nfs_mountroot: SIOCAIFADDR: %d", error);
#ifndef __rtems__
if ((cp = kern_getenv("boot.netif.mtu")) != NULL) { if ((cp = kern_getenv("boot.netif.mtu")) != NULL) {
ir.ifr_mtu = strtol(cp, NULL, 10); ir.ifr_mtu = strtol(cp, NULL, 10);
bcopy(nd->myif.ifra_name, ir.ifr_name, IFNAMSIZ); bcopy(nd->myif.ifra_name, ir.ifr_name, IFNAMSIZ);
@ -454,6 +459,7 @@ nfs_mountroot(struct mount *mp)
if (error) if (error)
printf("nfs_mountroot: SIOCSIFMTU: %d", error); printf("nfs_mountroot: SIOCSIFMTU: %d", error);
} }
#endif /* __rtems__ */
soclose(so); soclose(so);
/* /*
@ -506,7 +512,9 @@ nfs_mountroot(struct mount *mp)
strlcpy(prison0.pr_hostname, nd->my_hostnam, strlcpy(prison0.pr_hostname, nd->my_hostnam,
sizeof(prison0.pr_hostname)); sizeof(prison0.pr_hostname));
mtx_unlock(&prison0.pr_mtx); mtx_unlock(&prison0.pr_mtx);
#ifndef __rtems__
inittodr(ntohl(nd->root_time)); inittodr(ntohl(nd->root_time));
#endif /* __rtems__ */
return (0); return (0);
} }
@ -1178,7 +1186,11 @@ nfs_mount(struct mount *mp)
* "nfsreq". * "nfsreq".
*/ */
if (args.sotype == SOCK_DGRAM && nmp->nm_sotype == SOCK_STREAM) if (args.sotype == SOCK_DGRAM && nmp->nm_sotype == SOCK_STREAM)
#ifndef __rtems__
tprintf(td->td_proc, LOG_WARNING, tprintf(td->td_proc, LOG_WARNING,
#else /* __rtems__ */
printf(
#endif /* __rtems__ */
"Warning: mount -u that changes TCP->UDP can result in hung threads\n"); "Warning: mount -u that changes TCP->UDP can result in hung threads\n");
/* /*
@ -2048,4 +2060,3 @@ void nfscl_retopts(struct nfsmount *nmp, char *buffer, size_t buflen)
nfscl_printoptval(nmp, nmp->nm_timeo, ",timeout", &buf, &blen); nfscl_printoptval(nmp, nmp->nm_timeo, ",timeout", &buf, &blen);
nfscl_printoptval(nmp, nmp->nm_retry, ",retrans", &buf, &blen); nfscl_printoptval(nmp, nmp->nm_retry, ",retrans", &buf, &blen);
} }

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -41,7 +43,7 @@ __FBSDID("$FreeBSD$");
* vnode op calls for Sun NFS version 2, 3 and 4 * vnode op calls for Sun NFS version 2, 3 and 4
*/ */
#include "opt_inet.h" #include <rtems/bsd/local/opt_inet.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/kernel.h> #include <sys/kernel.h>
@ -59,7 +61,9 @@ __FBSDID("$FreeBSD$");
#include <sys/vnode.h> #include <sys/vnode.h>
#include <sys/dirent.h> #include <sys/dirent.h>
#include <sys/fcntl.h> #include <sys/fcntl.h>
#ifndef __rtems__
#include <sys/lockf.h> #include <sys/lockf.h>
#endif /* __rtems__ */
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <sys/signalvar.h> #include <sys/signalvar.h>
@ -334,7 +338,9 @@ nfs_lock(struct vop_lock1_args *ap)
np->n_flag &= ~NVNSETSZSKIP; np->n_flag &= ~NVNSETSZSKIP;
nsize = np->n_size; nsize = np->n_size;
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
#ifndef __rtems__
vnode_pager_setsize(vp, nsize); vnode_pager_setsize(vp, nsize);
#endif /* __rtems__ */
downgrade: downgrade:
if (lktype == LK_SHARED) { if (lktype == LK_SHARED) {
ap->a_flags &= ~(LK_TYPE_MASK | LK_INTERLOCK); ap->a_flags &= ~(LK_TYPE_MASK | LK_INTERLOCK);
@ -683,7 +689,9 @@ nfs_open(struct vop_open_args *ap)
if (cred != NULL) if (cred != NULL)
crfree(cred); crfree(cred);
#ifndef __rtems__
vnode_create_vobject(vp, vattr.va_size, ap->a_td); vnode_create_vobject(vp, vattr.va_size, ap->a_td);
#endif /* __rtems__ */
/* /*
* If the text file has been mmap'd, flush any dirty pages to the * If the text file has been mmap'd, flush any dirty pages to the
@ -694,12 +702,14 @@ nfs_open(struct vop_open_args *ap)
* executing the text file to be terminated. * executing the text file to be terminated.
*/ */
if (vp->v_writecount <= -1) { if (vp->v_writecount <= -1) {
#ifndef __rtems__
if ((obj = vp->v_object) != NULL && if ((obj = vp->v_object) != NULL &&
(obj->flags & OBJ_MIGHTBEDIRTY) != 0) { (obj->flags & OBJ_MIGHTBEDIRTY) != 0) {
VM_OBJECT_WLOCK(obj); VM_OBJECT_WLOCK(obj);
vm_object_page_clean(obj, 0, 0, OBJPC_SYNC); vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(obj); VM_OBJECT_WUNLOCK(obj);
} }
#endif /* __rtems__ */
/* Now, flush the buffer cache. */ /* Now, flush the buffer cache. */
ncl_flush(vp, MNT_WAIT, curthread, 0, 0); ncl_flush(vp, MNT_WAIT, curthread, 0, 0);
@ -778,11 +788,13 @@ nfs_close(struct vop_close_args *ap)
* close, regardless of whether they were dirtied by * close, regardless of whether they were dirtied by
* mmap'ed writes or via write(). * mmap'ed writes or via write().
*/ */
#ifndef __rtems__
if (nfs_clean_pages_on_close && vp->v_object) { if (nfs_clean_pages_on_close && vp->v_object) {
VM_OBJECT_WLOCK(vp->v_object); VM_OBJECT_WLOCK(vp->v_object);
vm_object_page_clean(vp->v_object, 0, 0, 0); vm_object_page_clean(vp->v_object, 0, 0, 0);
VM_OBJECT_WUNLOCK(vp->v_object); VM_OBJECT_WUNLOCK(vp->v_object);
} }
#endif /* __rtems__ */
NFSLOCKNODE(np); NFSLOCKNODE(np);
if (np->n_flag & NMODIFIED) { if (np->n_flag & NMODIFIED) {
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
@ -805,7 +817,7 @@ nfs_close(struct vop_close_args *ap)
int cm = newnfs_commit_on_close ? 1 : 0; int cm = newnfs_commit_on_close ? 1 : 0;
error = ncl_flush(vp, MNT_WAIT, ap->a_td, cm, 0); error = ncl_flush(vp, MNT_WAIT, ap->a_td, cm, 0);
/* np->n_flag &= ~NMODIFIED; */ /* np->n_flag &= ~NMODIFIED; */
} else if (NFS_ISV4(vp)) { } else if (NFS_ISV4(vp)) {
if (nfscl_mustflush(vp) != 0) { if (nfscl_mustflush(vp) != 0) {
int cm = newnfs_commit_on_close ? 1 : 0; int cm = newnfs_commit_on_close ? 1 : 0;
error = ncl_flush(vp, MNT_WAIT, ap->a_td, error = ncl_flush(vp, MNT_WAIT, ap->a_td,
@ -821,10 +833,10 @@ nfs_close(struct vop_close_args *ap)
} }
NFSLOCKNODE(np); NFSLOCKNODE(np);
} }
/* /*
* Invalidate the attribute cache in all cases. * Invalidate the attribute cache in all cases.
* An open is going to fetch fresh attrs any way, other procs * An open is going to fetch fresh attrs any way, other procs
* on this node that have file open will be forced to do an * on this node that have file open will be forced to do an
* otw attr fetch, but this is safe. * otw attr fetch, but this is safe.
* --> A user found that their RPC count dropped by 20% when * --> A user found that their RPC count dropped by 20% when
* this was commented out and I can't see any requirement * this was commented out and I can't see any requirement
@ -879,7 +891,7 @@ nfs_close(struct vop_close_args *ap)
np->n_directio_asyncwr)); np->n_directio_asyncwr));
if (newnfs_directio_enable && (fmode & O_DIRECT) && (vp->v_type == VREG)) { if (newnfs_directio_enable && (fmode & O_DIRECT) && (vp->v_type == VREG)) {
NFSLOCKNODE(np); NFSLOCKNODE(np);
KASSERT((np->n_directio_opens > 0), KASSERT((np->n_directio_opens > 0),
("nfs_close: unexpectedly value (0) of n_directio_opens\n")); ("nfs_close: unexpectedly value (0) of n_directio_opens\n"));
np->n_directio_opens--; np->n_directio_opens--;
if (np->n_directio_opens == 0) if (np->n_directio_opens == 0)
@ -1009,7 +1021,7 @@ nfs_setattr(struct vop_setattr_args *ap)
vap->va_mode == (mode_t)VNOVAL && vap->va_mode == (mode_t)VNOVAL &&
vap->va_uid == (uid_t)VNOVAL && vap->va_uid == (uid_t)VNOVAL &&
vap->va_gid == (gid_t)VNOVAL) vap->va_gid == (gid_t)VNOVAL)
return (0); return (0);
vap->va_size = VNOVAL; vap->va_size = VNOVAL;
break; break;
default: default:
@ -1036,7 +1048,9 @@ nfs_setattr(struct vop_setattr_args *ap)
error = ncl_vinvalbuf(vp, vap->va_size == 0 ? error = ncl_vinvalbuf(vp, vap->va_size == 0 ?
0 : V_SAVE, td, 1); 0 : V_SAVE, td, 1);
if (error != 0) { if (error != 0) {
#ifndef __rtems__
vnode_pager_setsize(vp, tsize); vnode_pager_setsize(vp, tsize);
#endif /* __rtems__ */
return (error); return (error);
} }
/* /*
@ -1058,7 +1072,7 @@ nfs_setattr(struct vop_setattr_args *ap)
} }
} else { } else {
NFSLOCKNODE(np); NFSLOCKNODE(np);
if ((vap->va_mtime.tv_sec != VNOVAL || vap->va_atime.tv_sec != VNOVAL) && if ((vap->va_mtime.tv_sec != VNOVAL || vap->va_atime.tv_sec != VNOVAL) &&
(np->n_flag & NMODIFIED) && vp->v_type == VREG) { (np->n_flag & NMODIFIED) && vp->v_type == VREG) {
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
error = ncl_vinvalbuf(vp, V_SAVE, td, 1); error = ncl_vinvalbuf(vp, V_SAVE, td, 1);
@ -1071,7 +1085,9 @@ nfs_setattr(struct vop_setattr_args *ap)
if (error && vap->va_size != VNOVAL) { if (error && vap->va_size != VNOVAL) {
NFSLOCKNODE(np); NFSLOCKNODE(np);
np->n_size = np->n_vattr.na_size = tsize; np->n_size = np->n_vattr.na_size = tsize;
#ifndef __rtems__
vnode_pager_setsize(vp, tsize); vnode_pager_setsize(vp, tsize);
#endif /* __rtems__ */
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
} }
return (error); return (error);
@ -1130,7 +1146,7 @@ nfs_lookup(struct vop_lookup_args *ap)
struct nfsvattr dnfsva, nfsva; struct nfsvattr dnfsva, nfsva;
struct vattr vattr; struct vattr vattr;
struct timespec nctime; struct timespec nctime;
*vpp = NULLVP; *vpp = NULLVP;
if ((flags & ISLASTCN) && (mp->mnt_flag & MNT_RDONLY) && if ((flags & ISLASTCN) && (mp->mnt_flag & MNT_RDONLY) &&
(cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
@ -1207,7 +1223,7 @@ nfs_lookup(struct vop_lookup_args *ap)
cache_purge(newvp); cache_purge(newvp);
if (dvp != newvp) if (dvp != newvp)
vput(newvp); vput(newvp);
else else
vrele(newvp); vrele(newvp);
*vpp = NULLVP; *vpp = NULLVP;
} else if (error == ENOENT) { } else if (error == ENOENT) {
@ -1363,7 +1379,7 @@ nfs_lookup(struct vop_lookup_args *ap)
(void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL,
0, 1); 0, 1);
else if ((flags & (ISLASTCN | ISOPEN)) == (ISLASTCN | ISOPEN) && else if ((flags & (ISLASTCN | ISOPEN)) == (ISLASTCN | ISOPEN) &&
!(np->n_flag & NMODIFIED)) { !(np->n_flag & NMODIFIED)) {
/* /*
* Flush the attribute cache when opening a * Flush the attribute cache when opening a
* leaf node to ensure that fresh attributes * leaf node to ensure that fresh attributes
@ -1695,7 +1711,7 @@ again:
/* try again without setting uid/gid */ /* try again without setting uid/gid */
vap->va_uid = (uid_t)VNOVAL; vap->va_uid = (uid_t)VNOVAL;
vap->va_gid = (uid_t)VNOVAL; vap->va_gid = (uid_t)VNOVAL;
error = nfsrpc_setattr(newvp, vap, NULL, error = nfsrpc_setattr(newvp, vap, NULL,
cnp->cn_cred, cnp->cn_thread, &nfsva, cnp->cn_cred, cnp->cn_thread, &nfsva,
&attrflag, NULL); &attrflag, NULL);
} }
@ -1883,7 +1899,7 @@ nfs_rename(struct vop_rename_args *ap)
* under NFSV3. NFSV2 does not have this problem because * under NFSV3. NFSV2 does not have this problem because
* ( as far as I can tell ) it flushes dirty buffers more * ( as far as I can tell ) it flushes dirty buffers more
* often. * often.
* *
* Skip the rename operation if the fsync fails, this can happen * Skip the rename operation if the fsync fails, this can happen
* due to the server's volume being full, when we pushed out data * due to the server's volume being full, when we pushed out data
* that was written back to our cache earlier. Not checking for * that was written back to our cache earlier. Not checking for
@ -2295,10 +2311,10 @@ nfs_readdir(struct vop_readdir_args *ap)
ssize_t tresid, left; ssize_t tresid, left;
int error = 0; int error = 0;
struct vattr vattr; struct vattr vattr;
if (ap->a_eofflag != NULL) if (ap->a_eofflag != NULL)
*ap->a_eofflag = 0; *ap->a_eofflag = 0;
if (vp->v_type != VDIR) if (vp->v_type != VDIR)
return(EPERM); return(EPERM);
/* /*
@ -2342,7 +2358,7 @@ nfs_readdir(struct vop_readdir_args *ap)
if (ap->a_eofflag != NULL) if (ap->a_eofflag != NULL)
*ap->a_eofflag = 1; *ap->a_eofflag = 1;
} }
/* Add the partial DIRBLKSIZ (left) back in. */ /* Add the partial DIRBLKSIZ (left) back in. */
uio->uio_resid += left; uio->uio_resid += left;
return (error); return (error);
@ -2376,7 +2392,7 @@ ncl_readdirrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred,
cookie = *cookiep; cookie = *cookiep;
ncl_dircookie_unlock(dnp); ncl_dircookie_unlock(dnp);
} else { } else {
ncl_dircookie_unlock(dnp); ncl_dircookie_unlock(dnp);
return (NFSERR_BAD_COOKIE); return (NFSERR_BAD_COOKIE);
} }
@ -2494,18 +2510,22 @@ nfs_sillyrename(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
sp->s_dvp = dvp; sp->s_dvp = dvp;
VREF(dvp); VREF(dvp);
/* /*
* Fudge together a funny name. * Fudge together a funny name.
* Changing the format of the funny name to accommodate more * Changing the format of the funny name to accommodate more
* sillynames per directory. * sillynames per directory.
* The name is now changed to .nfs.<ticks>.<pid>.4, where ticks is * The name is now changed to .nfs.<ticks>.<pid>.4, where ticks is
* CPU ticks since boot. * CPU ticks since boot.
*/ */
#ifndef __rtems__
pid = cnp->cn_thread->td_proc->p_pid; pid = cnp->cn_thread->td_proc->p_pid;
#else /* __rtems__ */
pid = 1;
#endif /* __rtems__ */
lticks = (unsigned int)ticks; lticks = (unsigned int)ticks;
for ( ; ; ) { for ( ; ; ) {
sp->s_namlen = sprintf(sp->s_name, sp->s_namlen = sprintf(sp->s_name,
".nfs.%08x.%04x4.4", lticks, ".nfs.%08x.%04x4.4", lticks,
pid); pid);
if (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, if (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred,
cnp->cn_thread, NULL)) cnp->cn_thread, NULL))
@ -3041,12 +3061,12 @@ loop:
while (np->n_directio_asyncwr > 0) { while (np->n_directio_asyncwr > 0) {
np->n_flag |= NFSYNCWAIT; np->n_flag |= NFSYNCWAIT;
error = newnfs_msleep(td, &np->n_directio_asyncwr, error = newnfs_msleep(td, &np->n_directio_asyncwr,
&np->n_mtx, slpflag | (PRIBIO + 1), &np->n_mtx, slpflag | (PRIBIO + 1),
"nfsfsync", 0); "nfsfsync", 0);
if (error) { if (error) {
if (newnfs_sigintr(nmp, td)) { if (newnfs_sigintr(nmp, td)) {
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
error = EINTR; error = EINTR;
goto done; goto done;
} }
} }
@ -3106,7 +3126,7 @@ nfs_advlock(struct vop_advlock_args *ap)
struct vattr va; struct vattr va;
int ret, error = EOPNOTSUPP; int ret, error = EOPNOTSUPP;
u_quad_t size; u_quad_t size;
ret = NFSVOPLOCK(vp, LK_SHARED); ret = NFSVOPLOCK(vp, LK_SHARED);
if (ret != 0) if (ret != 0)
return (EBADF); return (EBADF);
@ -3115,9 +3135,11 @@ nfs_advlock(struct vop_advlock_args *ap)
NFSVOPUNLOCK(vp, 0); NFSVOPUNLOCK(vp, 0);
return (EINVAL); return (EINVAL);
} }
#ifndef __rtems__
if ((ap->a_flags & F_POSIX) != 0) if ((ap->a_flags & F_POSIX) != 0)
cred = p->p_ucred; cred = p->p_ucred;
else else
#endif /* __rtems__ */
cred = td->td_ucred; cred = td->td_ucred;
NFSVOPLOCK(vp, LK_UPGRADE | LK_RETRY); NFSVOPLOCK(vp, LK_UPGRADE | LK_RETRY);
if (vp->v_iflag & VI_DOOMED) { if (vp->v_iflag & VI_DOOMED) {
@ -3198,6 +3220,7 @@ nfs_advlock(struct vop_advlock_args *ap)
NFSVOPUNLOCK(vp, 0); NFSVOPUNLOCK(vp, 0);
return (0); return (0);
} else if (!NFS_ISV4(vp)) { } else if (!NFS_ISV4(vp)) {
#ifndef __rtems__
if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) { if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) {
size = VTONFS(vp)->n_size; size = VTONFS(vp)->n_size;
NFSVOPUNLOCK(vp, 0); NFSVOPUNLOCK(vp, 0);
@ -3220,6 +3243,10 @@ nfs_advlock(struct vop_advlock_args *ap)
NFSVOPUNLOCK(vp, 0); NFSVOPUNLOCK(vp, 0);
} }
} }
#else /* __rtems__ */
NFSVOPUNLOCK(vp, 0);
return (0);
#endif /* __rtems__ */
} else } else
NFSVOPUNLOCK(vp, 0); NFSVOPUNLOCK(vp, 0);
return (error); return (error);
@ -3234,7 +3261,7 @@ nfs_advlockasync(struct vop_advlockasync_args *ap)
struct vnode *vp = ap->a_vp; struct vnode *vp = ap->a_vp;
u_quad_t size; u_quad_t size;
int error; int error;
if (NFS_ISV4(vp)) if (NFS_ISV4(vp))
return (EOPNOTSUPP); return (EOPNOTSUPP);
error = NFSVOPLOCK(vp, LK_SHARED); error = NFSVOPLOCK(vp, LK_SHARED);
@ -3243,7 +3270,9 @@ nfs_advlockasync(struct vop_advlockasync_args *ap)
if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) { if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) {
size = VTONFS(vp)->n_size; size = VTONFS(vp)->n_size;
NFSVOPUNLOCK(vp, 0); NFSVOPUNLOCK(vp, 0);
#ifndef __rtems__
error = lf_advlockasync(ap, &(vp->v_lockf), size); error = lf_advlockasync(ap, &(vp->v_lockf), size);
#endif /* __rtems__ */
} else { } else {
NFSVOPUNLOCK(vp, 0); NFSVOPUNLOCK(vp, 0);
error = EOPNOTSUPP; error = EOPNOTSUPP;
@ -3262,8 +3291,10 @@ nfs_print(struct vop_print_args *ap)
printf("\tfileid %jd fsid 0x%jx", (uintmax_t)np->n_vattr.na_fileid, printf("\tfileid %jd fsid 0x%jx", (uintmax_t)np->n_vattr.na_fileid,
(uintmax_t)np->n_vattr.na_fsid); (uintmax_t)np->n_vattr.na_fsid);
#ifndef __rtems__
if (vp->v_type == VFIFO) if (vp->v_type == VFIFO)
fifo_printinfo(vp); fifo_printinfo(vp);
#endif /* __rtems__ */
printf("\n"); printf("\n");
return (0); return (0);
} }
@ -3296,7 +3327,9 @@ ncl_writebp(struct buf *bp, int force __unused, struct thread *td)
bp->b_iocmd = BIO_WRITE; bp->b_iocmd = BIO_WRITE;
bufobj_wref(bp->b_bufobj); bufobj_wref(bp->b_bufobj);
#ifndef __rtems__
curthread->td_ru.ru_oublock++; curthread->td_ru.ru_oublock++;
#endif /* __rtems__ */
/* /*
* Note: to avoid loopback deadlocks, we do not * Note: to avoid loopback deadlocks, we do not
@ -3364,6 +3397,7 @@ out:
static int static int
nfsfifo_read(struct vop_read_args *ap) nfsfifo_read(struct vop_read_args *ap)
{ {
#ifndef __rtems__
struct nfsnode *np = VTONFS(ap->a_vp); struct nfsnode *np = VTONFS(ap->a_vp);
int error; int error;
@ -3375,7 +3409,10 @@ nfsfifo_read(struct vop_read_args *ap)
vfs_timestamp(&np->n_atim); vfs_timestamp(&np->n_atim);
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
error = fifo_specops.vop_read(ap); error = fifo_specops.vop_read(ap);
return error; return error;
#else /* __rtems__ */
return (EINVAL);
#endif /* __rtems__ */
} }
/* /*
@ -3384,6 +3421,7 @@ nfsfifo_read(struct vop_read_args *ap)
static int static int
nfsfifo_write(struct vop_write_args *ap) nfsfifo_write(struct vop_write_args *ap)
{ {
#ifndef __rtems__
struct nfsnode *np = VTONFS(ap->a_vp); struct nfsnode *np = VTONFS(ap->a_vp);
/* /*
@ -3394,6 +3432,9 @@ nfsfifo_write(struct vop_write_args *ap)
vfs_timestamp(&np->n_mtim); vfs_timestamp(&np->n_mtim);
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
return(fifo_specops.vop_write(ap)); return(fifo_specops.vop_write(ap));
#else /* __rtems__ */
return (EINVAL);
#endif /* __rtems__ */
} }
/* /*
@ -3404,6 +3445,7 @@ nfsfifo_write(struct vop_write_args *ap)
static int static int
nfsfifo_close(struct vop_close_args *ap) nfsfifo_close(struct vop_close_args *ap)
{ {
#ifndef __rtems__
struct vnode *vp = ap->a_vp; struct vnode *vp = ap->a_vp;
struct nfsnode *np = VTONFS(vp); struct nfsnode *np = VTONFS(vp);
struct vattr vattr; struct vattr vattr;
@ -3432,6 +3474,9 @@ nfsfifo_close(struct vop_close_args *ap)
NFSUNLOCKNODE(np); NFSUNLOCKNODE(np);
out: out:
return (fifo_specops.vop_close(ap)); return (fifo_specops.vop_close(ap));
#else /* __rtems__ */
return (EINVAL);
#endif /* __rtems__ */
} }
/* /*
@ -3601,4 +3646,3 @@ nfs_pathconf(struct vop_pathconf_args *ap)
} }
return (error); return (error);
} }

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-4-Clause * SPDX-License-Identifier: BSD-4-Clause
* *
@ -45,9 +47,9 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include "opt_bootp.h" #include <rtems/bsd/local/opt_bootp.h>
#include "opt_nfs.h" #include <rtems/bsd/local/opt_nfs.h>
#include "opt_rootdevname.h" #include <rtems/bsd/local/opt_rootdevname.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/* $NetBSD: krpc_subr.c,v 1.12.4.1 1996/06/07 00:52:26 cgd Exp $ */ /* $NetBSD: krpc_subr.c,v 1.12.4.1 1996/06/07 00:52:26 cgd Exp $ */
/*- /*-

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
* *

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -41,7 +43,9 @@ __FBSDID("$FreeBSD$");
#include <sys/limits.h> #include <sys/limits.h>
#include <sys/lock.h> #include <sys/lock.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#ifndef __rtems__
#include <sys/lockf.h> /* for hz */ /* Must come after sys/malloc.h */ #include <sys/lockf.h> /* for hz */ /* Must come after sys/malloc.h */
#endif /* __rtems__ */
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/namei.h> #include <sys/namei.h>
@ -50,7 +54,7 @@ __FBSDID("$FreeBSD$");
#include <sys/resourcevar.h> #include <sys/resourcevar.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/unistd.h> #include <rtems/bsd/sys/unistd.h>
#include <sys/vnode.h> #include <sys/vnode.h>
#include <net/if.h> #include <net/if.h>
@ -286,7 +290,9 @@ nfs_dolock(struct vop_advlock_args *ap)
if (p->p_nlminfo == NULL) { if (p->p_nlminfo == NULL) {
p->p_nlminfo = malloc(sizeof(struct nlminfo), p->p_nlminfo = malloc(sizeof(struct nlminfo),
M_NLMINFO, M_WAITOK | M_ZERO); M_NLMINFO, M_WAITOK | M_ZERO);
#ifndef __rtems__
p->p_nlminfo->pid_start = p->p_stats->p_start; p->p_nlminfo->pid_start = p->p_stats->p_start;
#endif /* __rtems__ */
getboottime(&boottime); getboottime(&boottime);
timevaladd(&p->p_nlminfo->pid_start, &boottime); timevaladd(&p->p_nlminfo->pid_start, &boottime);
} }
@ -337,7 +343,9 @@ nfs_dolock(struct vop_advlock_args *ap)
if (msg.lm_getlk && p->p_nlminfo->retcode == 0) { if (msg.lm_getlk && p->p_nlminfo->retcode == 0) {
if (p->p_nlminfo->set_getlk_pid) { if (p->p_nlminfo->set_getlk_pid) {
#ifndef __rtems__
fl->l_sysid = 0; /* XXX */ fl->l_sysid = 0; /* XXX */
#endif /* __rtems__ */
fl->l_pid = p->p_nlminfo->getlk_pid; fl->l_pid = p->p_nlminfo->getlk_pid;
} else { } else {
fl->l_type = F_UNLCK; fl->l_type = F_UNLCK;
@ -364,9 +372,13 @@ nfslockdans(struct thread *td, struct lockd_ans *ansp)
if (ansp->la_vers != LOCKD_ANS_VERSION) if (ansp->la_vers != LOCKD_ANS_VERSION)
return (EINVAL); return (EINVAL);
#ifndef __rtems__
/* Find the process, set its return errno and wake it up. */ /* Find the process, set its return errno and wake it up. */
if ((targetp = pfind(ansp->la_msg_ident.pid)) == NULL) if ((targetp = pfind(ansp->la_msg_ident.pid)) == NULL)
return (ESRCH); return (ESRCH);
#else /* __rtems__ */
targetp = td->td_proc;
#endif /* __rtems__ */
/* verify the pid hasn't been reused (if we can), and it isn't waiting /* verify the pid hasn't been reused (if we can), and it isn't waiting
* for an answer from a more recent request. We return an EPIPE if * for an answer from a more recent request. We return an EPIPE if

View File

@ -1,3 +1,5 @@
#include <machine/rtems-bsd-kernel-space.h>
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
@ -36,7 +38,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include "opt_nfs.h" #include <rtems/bsd/local/opt_nfs.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -49,17 +51,21 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h> #include <sys/mutex.h>
#include <sys/module.h> #include <sys/module.h>
#include <sys/sysent.h> #include <sys/sysent.h>
#ifndef __rtems__
#include <sys/syscall.h> #include <sys/syscall.h>
#endif /* __rtems__ */
#include <sys/sysproto.h> #include <sys/sysproto.h>
#include <security/audit/audit.h> #include <security/audit/audit.h>
#include <nfs/nfssvc.h> #include <nfs/nfssvc.h>
#ifndef __rtems__
static struct syscall_helper_data nfssvc_syscalls[] = { static struct syscall_helper_data nfssvc_syscalls[] = {
SYSCALL_INIT_HELPER(nfssvc), SYSCALL_INIT_HELPER(nfssvc),
SYSCALL_INIT_LAST SYSCALL_INIT_LAST
}; };
#endif /* __rtems__ */
/* /*
* This tiny module simply handles the nfssvc() system call. The other * This tiny module simply handles the nfssvc() system call. The other
@ -124,8 +130,10 @@ nfssvc_modevent(module_t mod, int type, void *data)
switch (type) { switch (type) {
case MOD_LOAD: case MOD_LOAD:
#ifndef __rtems__
error = syscall_helper_register(nfssvc_syscalls, error = syscall_helper_register(nfssvc_syscalls,
SY_THR_STATIC_KLD); SY_THR_STATIC_KLD);
#endif /* __rtems__ */
break; break;
case MOD_UNLOAD: case MOD_UNLOAD:
@ -134,7 +142,9 @@ nfssvc_modevent(module_t mod, int type, void *data)
error = EBUSY; error = EBUSY;
break; break;
} }
#ifndef __rtems__
syscall_helper_unregister(nfssvc_syscalls); syscall_helper_unregister(nfssvc_syscalls);
#endif /* __rtems__ */
break; break;
default: default:
error = EOPNOTSUPP; error = EOPNOTSUPP;
@ -151,4 +161,3 @@ DECLARE_MODULE(nfssvc, nfssvc_mod, SI_SUB_VFS, SI_ORDER_ANY);
/* So that loader and kldload(2) can find us, wherever we are.. */ /* So that loader and kldload(2) can find us, wherever we are.. */
MODULE_VERSION(nfssvc, 1); MODULE_VERSION(nfssvc, 1);

View File

@ -39,7 +39,7 @@
#define _NFSCLIENT_NFS_H_ #define _NFSCLIENT_NFS_H_
#ifdef _KERNEL #ifdef _KERNEL
#include "opt_nfs.h" #include <rtems/bsd/local/opt_nfs.h>
#endif #endif
#include <nfsclient/nfsargs.h> #include <nfsclient/nfsargs.h>

View File

@ -102,13 +102,17 @@ struct nfsnode {
u_quad_t n_size; /* Current size of file */ u_quad_t n_size; /* Current size of file */
u_quad_t n_brev; /* Modify rev when cached */ u_quad_t n_brev; /* Modify rev when cached */
u_quad_t n_lrev; /* Modify rev for lease */ u_quad_t n_lrev; /* Modify rev for lease */
#ifndef __rtems__
struct vattr n_vattr; /* Vnode attribute cache */ struct vattr n_vattr; /* Vnode attribute cache */
#endif /* __rtems__ */
time_t n_attrstamp; /* Attr. cache timestamp */ time_t n_attrstamp; /* Attr. cache timestamp */
struct nfs_accesscache n_accesscache[NFS_ACCESSCACHESIZE]; struct nfs_accesscache n_accesscache[NFS_ACCESSCACHESIZE];
struct timespec n_mtime; /* Prev modify time. */ struct timespec n_mtime; /* Prev modify time. */
nfsfh_t *n_fhp; /* NFS File Handle */ nfsfh_t *n_fhp; /* NFS File Handle */
#ifndef __rtems__
struct vnode *n_vnode; /* associated vnode */ struct vnode *n_vnode; /* associated vnode */
struct vnode *n_dvp; /* parent vnode */ struct vnode *n_dvp; /* parent vnode */
#endif /* __rtems__ */
int n_error; /* Save write error value */ int n_error; /* Save write error value */
union { union {
struct timespec nf_atim; /* Special file times */ struct timespec nf_atim; /* Special file times */

138
libbsd.py
View File

@ -2884,6 +2884,138 @@ class rpc(builder.Module):
mm.generator['source']() mm.generator['source']()
) )
#
# NFS
#
class nfs(builder.Module):
def __init__(self, manager):
super(nfs, self).__init__(manager, type(self).__name__)
def generate(self):
mm = self.manager
self.addDependency('rpc')
self.addKernelSpaceHeaderFiles(
[
'sys/nfs/krpc.h',
'sys/nfs/nfs_common.h',
'sys/nfs/nfs_fha.h',
'sys/nfs/nfs_kdtrace.h',
'sys/nfs/nfs_lock.h',
'sys/nfs/nfs_mountcommon.h',
'sys/nfs/nfsdiskless.h',
'sys/nfs/nfsproto.h',
'sys/nfs/nfssvc.h',
'sys/nfs/xdr_subs.h',
'sys/nfsclient/nfs.h',
'sys/nfsclient/nfsargs.h',
'sys/nfsclient/nfsm_subs.h',
'sys/nfsclient/nfsmount.h',
'sys/nfsclient/nfsnode.h',
'sys/nfsclient/nfsstats.h',
'sys/nfsclient/nlminfo.h',
]
)
self.addKernelSpaceSourceFiles(
[
'sys/nfs/bootp_subr.c',
'sys/nfs/krpc_subr.c',
'sys/nfs/nfs_fha.c',
'sys/nfs/nfs_lock.c',
'sys/nfs/nfs_nfssvc.c',
],
mm.generator['source']()
)
#
# File System NFS
#
class fs_nfs(builder.Module):
def __init__(self, manager):
super(fs_nfs, self).__init__(manager, type(self).__name__)
def generate(self):
mm = self.manager
self.addDependency('rpc')
self.addDependency('nfs')
self.addKernelSpaceHeaderFiles(
[
'sys/fs/nfs/nfs.h',
'sys/fs/nfs/nfs_var.h',
'sys/fs/nfs/nfscl.h',
'sys/fs/nfs/nfsclstate.h',
'sys/fs/nfs/nfsdport.h',
'sys/fs/nfs/nfskpiport.h',
'sys/fs/nfs/nfsm_subs.h',
'sys/fs/nfs/nfsport.h',
'sys/fs/nfs/nfsproto.h',
'sys/fs/nfs/nfsrvcache.h',
'sys/fs/nfs/nfsrvstate.h',
'sys/fs/nfs/nfsv4_errstr.h',
'sys/fs/nfs/rpcv2.h',
'sys/fs/nfs/xdr_subs.h',
]
)
fs_nfs_cflags = ['-DEBADRPC=72',
'-DPVFS=10']
self.addKernelSpaceSourceFiles(
[
'sys/fs/nfs/nfs_commonacl.c',
'sys/fs/nfs/nfs_commonkrpc.c',
'sys/fs/nfs/nfs_commonport.c',
'sys/fs/nfs/nfs_commonsubs.c',
],
mm.generator['source']()
)
#
# File System NFS Client
#
class fs_nfsclient(builder.Module):
def __init__(self, manager):
super(fs_nfsclient, self).__init__(manager, type(self).__name__)
def generate(self):
mm = self.manager
self.addDependency('rpc')
self.addDependency('nfs')
self.addDependency('fs_nfs')
self.addKernelSpaceHeaderFiles(
[
'sys/fs/nfsclient/nfs.h',
'sys/fs/nfsclient/nfsmount.h',
'sys/fs/nfsclient/nfsnode.h',
'sys/fs/nfsclient/nlminfo.h',
'sys/fs/nfsclient/nfs_kdtrace.h',
]
)
self.addKernelSpaceSourceFiles(
[
'sys/fs/nfsclient/nfs_clbio.c',
'sys/fs/nfsclient/nfs_clcomsubs.c',
'sys/fs/nfsclient/nfs_clkdtrace.c',
'sys/fs/nfsclient/nfs_clkrpc.c',
'sys/fs/nfsclient/nfs_clnfsiod.c',
'sys/fs/nfsclient/nfs_clnode.c',
'sys/fs/nfsclient/nfs_clport.c',
'sys/fs/nfsclient/nfs_clrpcops.c',
'sys/fs/nfsclient/nfs_clstate.c',
'sys/fs/nfsclient/nfs_clsubs.c',
'sys/fs/nfsclient/nfs_clvfsops.c',
'sys/fs/nfsclient/nfs_clvnops.c',
],
mm.generator['source'](['-DDIRBLKSIZ=512'])
)
self.addRTEMSUserSourceFiles(
[
'fs/nfsclient/nfs.c'
],
mm.generator['source']()
)
# #
# PCI # PCI
# #
@ -5312,7 +5444,8 @@ class tests(builder.Module):
self.addTest(mm.generator['test']('ttcpshell01', ['test_main'], netTest = True, runTest = False)) self.addTest(mm.generator['test']('ttcpshell01', ['test_main'], netTest = True, runTest = False))
self.addTest(mm.generator['test']('epoch01', ['test_main'], extraLibs = ['rtemstest'])) self.addTest(mm.generator['test']('epoch01', ['test_main'], extraLibs = ['rtemstest']))
self.addTest(mm.generator['test']('nfs01', ['test_main'], self.addTest(mm.generator['test']('nfs01', ['test_main'],
netTest = True, modules = ['nfsv2'])) netTest = True, modules = ['nfsv2', 'fs_nfsclient'],
extraLibs = ['telnetd']))
self.addTest(mm.generator['test']('foobarclient', ['test_main'], self.addTest(mm.generator['test']('foobarclient', ['test_main'],
runTest = False, netTest = True)) runTest = False, netTest = True))
self.addTest(mm.generator['test']('foobarserver', ['test_main'], self.addTest(mm.generator['test']('foobarserver', ['test_main'],
@ -5447,6 +5580,9 @@ def load(mm):
mm.addModule(nfsv2(mm)) mm.addModule(nfsv2(mm))
mm.addModule(rpc(mm)) mm.addModule(rpc(mm))
mm.addModule(nfs(mm))
mm.addModule(fs_nfs(mm))
mm.addModule(fs_nfsclient(mm))
# Add PCI # Add PCI
mm.addModule(pci(mm)) mm.addModule(pci(mm))

223
rtemsbsd/fs/nfsclient/nfs.c Normal file
View File

@ -0,0 +1,223 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup NFSClient
*
* @brief RTEMS bindings to the NFS client
*
*/
/*
* Copyright (C) 2021 Chris Johns <chris@contemporary.software>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/rtems-bsd-kernel-space.h>
#include <machine/rtems-bsd-libio.h>
#include <machine/rtems-bsd-vfs.h>
#include <sys/buf.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/kernel.h>
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/syscallsubr.h>
#include <sys/sysproto.h>
#include <sys/time.h>
#include <sys/vnode.h>
#include <fs/nfsclient/nfs.h>
#include <nfs/nfsproto.h>
#include <nfsclient/nfs.h>
#include <rtems/bsd/rootfs.h>
#include <stdio.h>
SYSINIT_MODULE_REFERENCE(rootfs);
SYSINIT_MODULE_REFERENCE(nfs);
#ifndef RTEMS_DEBUG
#define RTEMS_DEBUG 0
#endif
#if RTEMS_DEBUG
extern int nfscl_debuglevel;
#endif
int
rtems_nfs_initialize(
rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
{
struct thread *td = curthread;
const char *fspath = NULL;
char options[64];
char *at;
int error;
if (RTEMS_DEBUG) {
printf("nfsv4: mount: %s -> %s", mt_entry->type, mt_entry->dev,
mt_entry->target);
if (data != NULL) {
printf(" (%s)", (const char *)data);
}
printf("\n");
#ifdef RTEMS_NFSCL_DEBUGLEVEL
nfscl_debuglevel = RTEMS_NFSCL_DEBUGLEVEL;
#endif
}
if (td == NULL) {
if (RTEMS_DEBUG)
printf("nfsv4: mount: no current thread\n");
error = ENOMEM;
goto out;
}
at = strchr(mt_entry->dev, '@');
if (at != NULL) {
if (RTEMS_DEBUG)
printf(
"nfsv4: mount: user/group name in path not supported\n");
error = EINVAL;
goto out;
}
if (data != NULL) {
size_t opts_len = strnlen((const char *)data, sizeof(options));
if (opts_len >= sizeof(options)) {
if (RTEMS_DEBUG)
printf(
"nfsv4: mount: options string too long\n");
error = EINVAL;
goto out;
}
}
rtems_bsd_vfs_mount_init(mt_entry);
fspath = mt_entry->target;
if (*fspath == '/') {
++fspath;
}
if (strchr(fspath, '/') != 0) {
error = EINVAL;
goto out;
}
rtems_bsd_libio_loc_set_vnode(&mt_entry->mt_fs_root->location, NULL);
rtems_bsd_libio_loc_set_vnode_dir(
&mt_entry->mt_fs_root->location, NULL);
/*
* Make the mount point in the BSD root file system, mount the NFS
* export then find the vnode and hold it. Make sure we find the root
* node of the NFS share and the not the root file system's mount node.
*/
error = rtems_bsd_rootfs_mkdir(fspath);
if (error == 0) {
struct mntarg *ma = NULL;
char errmsg[255];
ma = mount_arg(
ma, "fstype", RTEMS_DECONST(char *, mt_entry->type), -1);
ma = mount_arg(ma, "fspath", RTEMS_DECONST(char *, fspath), -1);
ma = mount_arg(
ma, "from", RTEMS_DECONST(char *, mt_entry->dev), -1);
if (mt_entry->writeable) {
ma = mount_arg(ma, "rw", NULL, 0);
} else {
ma = mount_arg(ma, "ro", NULL, 0);
}
if (data != NULL) {
char *opts;
/*
* See `man mount_nfs` and the list of options.
*/
strlcpy(options, (const char *)data, sizeof(options));
opts = &options[0];
while (opts != NULL) {
char *delimiter = strchr(opts, ',');
char *opt = opts;
if (delimiter != NULL) {
*delimiter = '\0';
opts = delimiter + 1;
} else {
opts = NULL;
}
delimiter = strchr(opt, '=');
if (delimiter != NULL) {
*delimiter = '\0';
ma = mount_arg(
ma, opt, delimiter + 1, -1);
} else {
ma = mount_arg(ma, opt, NULL, 0);
}
}
}
memset(errmsg, 0, sizeof(errmsg));
ma = mount_arg(ma, "errmsg", errmsg, sizeof(errmsg) - 1);
error = kernel_mount(ma, MNT_VERIFIED);
if (error == 0) {
struct nameidata nd;
vhold(rootvnode);
NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE,
fspath, rootvnode, td);
error = namei(&nd);
if (error == 0) {
rtems_bsd_libio_loc_set_vnode(
&mt_entry->mt_fs_root->location, nd.ni_vp);
rtems_bsd_vfs_clonenode(
&mt_entry->mt_fs_root->location);
NDFREE(&nd, NDF_NO_VP_RELE);
} else {
NDFREE(&nd, 0);
rtems_bsd_libio_loc_set_vnode(
&mt_entry->mt_fs_root->location, NULL);
rtems_bsd_vfs_freenode(
&mt_entry->mt_fs_root->location);
rtems_bsd_rootfs_rmdir(fspath);
}
} else {
if (RTEMS_DEBUG)
printf("nfsv4: mount: error: %s\n", errmsg);
}
}
rtems_bsd_libio_loc_set_vnode_dir(
&mt_entry->mt_fs_root->location, NULL);
out:
if (RTEMS_DEBUG)
printf("nfsv4: mount: (%d) %s\n", error, strerror(error));
if (error != 0) {
if (fspath != NULL) {
rtems_bsd_rootfs_rmdir(fspath);
}
}
return error;
}

View File

@ -142,7 +142,7 @@ rtems_bsd_libio_loc_set_vnode(
old_new_hc = old->v_holdcnt; old_new_hc = old->v_holdcnt;
old_new_rc = vrefcnt(old); old_new_rc = vrefcnt(old);
} }
if (RTEMS_BSD_DESCRIP_TRACE || true) if (RTEMS_BSD_DESCRIP_TRACE)
printf( printf(
"bsd: lio: set-vode loc=%p vn=%p (%d/%d)->(%d/%d) old=%p (%d/%d)->(%d/%d)\n", "bsd: lio: set-vode loc=%p vn=%p (%d/%d)->(%d/%d) old=%p (%d/%d)->(%d/%d)\n",
loc, vp, hc, rc, new_hc, new_rc, old, old_hc, old_rc, loc, vp, hc, rc, new_hc, new_rc, old, old_hc, old_rc,

View File

@ -64,4 +64,7 @@
#define NET_CFG_GATEWAY_IP "@NET_CFG_GATEWAY_IP@" #define NET_CFG_GATEWAY_IP "@NET_CFG_GATEWAY_IP@"
#define NET_CFG_NFS_MOUNT_PATH "@NET_CFG_NFS_MOUNT_PATH@"
#define NET_CFG_NFS_MOUNT_OPTIONS "@NET_CFG_NFS_MOUNT_OPTIONS@"
#endif /* _RTEMS_BSD_TEST_NETWORK_CONFIG_H_ */ #endif /* _RTEMS_BSD_TEST_NETWORK_CONFIG_H_ */

View File

@ -5,6 +5,7 @@
*/ */
/* /*
* Copyright (c) 2021 Chris Johns <chrisj@rtems.org> All rights reserved.
* Copyright (c) 2016 embedded brains GmbH. All rights reserved. * Copyright (c) 2016 embedded brains GmbH. All rights reserved.
* *
* embedded brains GmbH * embedded brains GmbH
@ -36,38 +37,363 @@
*/ */
#include <assert.h> #include <assert.h>
#include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <rtems.h> #include <rtems.h>
#include <rtems/libio.h> #include <rtems/libio.h>
#include <rtems/console.h>
#include <rtems/shell.h>
#include <rtems/telnetd.h>
#include <librtemsNfs.h> #include <librtemsNfs.h>
#include <rtems/bsd/test/network-config.h> #include <rtems/bsd/test/network-config.h>
#define TEST_NAME "LIBBSD NFS 1" #define TEST_NAME "LIBBSD NFS 1"
#define TEST_WAIT_FOR_LINK NET_CFG_INTERFACE_0
#define TEST_STATE_USER_INPUT 1 #define TEST_STATE_USER_INPUT 1
static const char *test_top = "test-nfs01";
#define rtems_test_errno_assert(__exp) \
do { \
if (!(__exp)) { \
printf( "%s: %d errno:%d:%s %s\n", __FILE__, __LINE__, errno, strerror(errno), #__exp ); \
assert(1 == 0); \
} \
} while (0)
typedef struct test_dir_entry
{
struct test_dir_entry *next;
char name[4];
} test_dir_entry;
typedef struct test_dir
{
struct test_dir *parent;
struct test_dir_entry *dirs;
struct test_dir_entry *indir;
const char *name;
int depth;
int num;
} test_dir;
/*
* Non-recursive directory tree walk
*/
typedef enum {
walk_tree_dir_start,
walk_tree_dir_end,
walk_tree_dir_entry
} walk_tree_dir;
typedef bool (*walk_tree_callout)(walk_tree_dir state,
test_dir *dir,
struct dirent *entry,
struct stat* stat,
void *data);
static char
test_stat_label(struct stat *s)
{
if (S_ISBLK(s->st_mode)) {
return 'b';
}
if (S_ISCHR(s->st_mode)) {
return 'c';
}
if (S_ISDIR(s->st_mode)) {
return 'd';
}
if (S_ISFIFO(s->st_mode)) {
return 'F';
}
if (S_ISLNK(s->st_mode)) {
return 'l';
}
if (S_ISREG(s->st_mode)) {
return 'f';
}
if (S_ISSOCK(s->st_mode)) {
return 's';
}
return 'X';
}
static void
test_walk_tree(const char *start, walk_tree_callout callout, void *data)
{
test_dir top = {
.parent = NULL,
.dirs = NULL,
.indir = NULL,
.name = start,
.depth = 0,
.num = 0
};
test_dir *dir = &top;
bool active = true;
rtems_test_errno_assert(chdir(start) == 0);
active = callout(walk_tree_dir_start, dir, NULL, NULL, data);
while (dir != NULL && active) {
test_dir *tmp_dir;
if (active && dir->dirs == NULL && dir->indir == NULL) {
struct DIR *ddir;
rtems_test_errno_assert((ddir = opendir(".")) != NULL);
while (active) {
struct dirent *dp;
struct stat s;
char t;
bool current_or_parent;
++dir->num;
dp = readdir(ddir);
if (dp == NULL) {
rtems_test_errno_assert(closedir(ddir) == 0);
break;
}
rtems_test_errno_assert(stat(dp->d_name, &s) == 0);
if ((dp->d_namlen == 1 && dp->d_name[0] == '.') ||
(dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')) {
current_or_parent = true;
} else {
current_or_parent = false;
}
t = test_stat_label(&s);
active = callout(walk_tree_dir_entry, dir, dp, &s, data);
if (active && !current_or_parent && t == 'd') {
test_dir_entry *dent;
assert((dent = malloc(sizeof(test_dir_entry) + dp->d_namlen)) != NULL);
dent->next = dir->dirs;
dir->dirs = dent;
strlcpy(&dent->name[0], dp->d_name, dp->d_namlen + sizeof(dent->name));
}
}
}
if (dir->dirs != NULL) {
free(dir->indir);
dir->indir = dir->dirs;
dir->dirs = dir->indir->next;
if (active && dir->indir != NULL) {
assert((tmp_dir = malloc(sizeof(test_dir))) != NULL);
tmp_dir->parent = dir;
tmp_dir->dirs = NULL;
tmp_dir->indir = NULL;
tmp_dir->name = dir->indir->name;
tmp_dir->depth = dir->depth + 1;
tmp_dir->num = 0;
dir = tmp_dir;
active = callout(walk_tree_dir_start, dir, NULL, NULL, data);
if (active) {
rtems_test_errno_assert(chdir(dir->name) == 0);
}
}
} else {
rtems_test_errno_assert(chdir("..") == 0);
if (active) {
active = callout(walk_tree_dir_end, dir, NULL, NULL, data);
}
free(dir->indir);
tmp_dir = dir;
dir = dir->parent;
if (tmp_dir != &top) {
free(tmp_dir);
}
}
}
}
typedef struct test_printer_data {
char path[MAXPATHLEN];
int count;
} test_printer_data;
static bool
test_walk_tree_printer(walk_tree_dir state,
test_dir *dir,
struct dirent *entry,
struct stat* stat,
void *data)
{
test_printer_data *pd = (test_printer_data*) data;
int len;
switch (state) {
case walk_tree_dir_start:
strlcat(pd->path, dir->name, MAXPATHLEN);
strlcat(pd->path, "/", MAXPATHLEN);
break;
case walk_tree_dir_entry:
++pd->count;
printf("%8d %3d %6d %c 0%o %10lld %s%s\n",
pd->count, dir->depth, dir->num, test_stat_label(stat),
stat->st_mode & 0777, stat->st_size,
pd->path, &entry->d_name[0]);
break;
case walk_tree_dir_end:
len = strlen(pd->path) - 1;
while (len > 0) {
len--;
if (pd->path[len] == '/') {
if (len < 1) {
break;
}
if (pd->path[len - 1] != '\\') {
break;
}
len -= 2;
}
}
pd->path[len + 1] = '\0';
break;
default:
break;
}
return true;
}
static bool
test_walk_tree_unlink(walk_tree_dir state,
test_dir *dir,
struct dirent *entry,
struct stat* stat,
void *data)
{
if (state == walk_tree_dir_entry) {
char type = test_stat_label(stat);
if (type != 'd') {
printf("unlink: %s\n", entry->d_name);
rtems_test_errno_assert(unlink(entry->d_name) == 0);
}
} else if (state == walk_tree_dir_end) {
printf("rmdir: %s\n", dir->name);
rtems_test_errno_assert(unlink(dir->name) == 0);
}
return true;
}
static void
test_setup(const char *base)
{
printf("test: nfs: setup\n");
printf("test: nfs: chdir: %s\n", base);
rtems_test_errno_assert(chdir(base) == 0);
printf("test: nfs: mkdir: %s\n", test_top);
rtems_test_errno_assert(mkdir(test_top, 0777) == 0);
printf("test: nfs: chdir: %s\n", test_top);
rtems_test_errno_assert(chdir(test_top) == 0);
}
static void
test_cleanup(const char *base)
{
printf("test: nfs: cleanup\n");
printf("test: nfs: chdir: %s\n", base);
rtems_test_errno_assert(chdir(base) == 0);
test_walk_tree(test_top, test_walk_tree_unlink, NULL);
}
static void
test_path_eval(const char *base, int depth)
{
char path[MAXPATHLEN];
int l;
printf("test path eval\n");
test_setup(base);
for (l = 1; l <= depth; ++l) {
snprintf(path, sizeof(path), "%d", l);
printf("test: nfs: mkdir: %s\n", path);
rtems_test_errno_assert(mkdir(path, 0777) == 0);
printf("test: nfs: chdir: %s\n", path);
rtems_test_errno_assert(chdir(path) == 0);
printf("test: nfs: getcwd: %s\n", path);
assert(getcwd(path, sizeof(path)) != NULL);
printf("test: nfs: getcwd: %s\n", path);
}
test_cleanup(base);
}
static void
test_nfs(const char *base)
{
test_printer_data pd;
test_path_eval(base, 5);
memset(&pd, 0, sizeof(pd));
test_walk_tree(base, test_walk_tree_printer, &pd);
}
static void
telnet_shell(char *name, void *arg)
{
rtems_shell_env_t env;
rtems_shell_dup_current_env(&env);
env.devname = name;
env.taskname = "TLNT";
env.login_check = NULL;
env.forever = false;
rtems_shell_main_loop(&env);
}
rtems_telnetd_config_table rtems_telnetd_config = {
.command = telnet_shell,
.arg = NULL,
.priority = 0,
.stack_size = 0,
.login_check = NULL,
.keep_stdio = false
};
static void static void
test_main(void) test_main(void)
{ {
static const char remote_target[] = const char remote_target[] = NET_CFG_NFS_MOUNT_PATH;
"1000.100@" NET_CFG_PEER_IP " :/srv/nfs"; const char *options = NET_CFG_NFS_MOUNT_OPTIONS;
const char *mount_options = NULL;
const char* mount_point = "/nfs";
int retries = 0;
int rv; int rv;
assert(rtems_telnetd_initialize() == RTEMS_SUCCESSFUL);
if (strlen(options) != 0) {
mount_options = options;
}
printf("mount: %s -> %s options:%s\n",
remote_target, mount_point, mount_options);
do { do {
sleep(1); sleep(1);
rv = mount_and_make_target_path(&remote_target[0], mount_point,
rv = mount_and_make_target_path(&remote_target[0], "/nfs",
RTEMS_FILESYSTEM_TYPE_NFS, RTEMS_FILESYSTEM_READ_WRITE, RTEMS_FILESYSTEM_TYPE_NFS, RTEMS_FILESYSTEM_READ_WRITE,
NULL); mount_options);
} while (rv != 0); if (rv < 0) {
printf("mount: %d: %s\n", errno, strerror(errno));
}
} while (rv != 0 && retries++ < 5);
if (rv != 0) {
printf("error: NFS mount failed\n");
exit(rv);
}
test_nfs(mount_point);
rtems_task_delete(RTEMS_SELF); rtems_task_delete(RTEMS_SELF);
assert(0); assert(0);
} }
#define CONFIGURE_SHELL_COMMANDS_ALL
#define DEFAULT_NETWORK_SHELL #define DEFAULT_NETWORK_SHELL
#define CONFIGURE_FILESYSTEM_NFS #define CONFIGURE_FILESYSTEM_NFS

View File

@ -289,7 +289,8 @@ class Builder(builder.ModuleManager):
(bld.env.NET_CONFIG)) (bld.env.NET_CONFIG))
tags = [ tags = [
'NET_CFG_INTERFACE_0', 'NET_CFG_SELF_IP', 'NET_CFG_NETMASK', 'NET_CFG_INTERFACE_0', 'NET_CFG_SELF_IP', 'NET_CFG_NETMASK',
'NET_CFG_PEER_IP', 'NET_CFG_GATEWAY_IP' 'NET_CFG_PEER_IP', 'NET_CFG_GATEWAY_IP', 'NET_CFG_NFS_MOUNT_PATH',
'NET_CFG_NFS_MOUNT_OPTIONS'
] ]
try: try:
net_cfg_lines = open(bld.env.NET_CONFIG).readlines() net_cfg_lines = open(bld.env.NET_CONFIG).readlines()
@ -307,9 +308,19 @@ class Builder(builder.ModuleManager):
'parse error: %d: %s' % (bld.env.NET_CONFIG, lc, l)) 'parse error: %d: %s' % (bld.env.NET_CONFIG, lc, l))
lhs = ls[0].strip() lhs = ls[0].strip()
rhs = ls[1].strip() rhs = ls[1].strip()
for t in tags: for tag in tags:
if lhs == t: if lhs == tag:
sed += "-e 's/@%s@/%s/' " % (t, rhs) transpose = [(':', '\:'), ('/', '\/')]
trhs = ''
for c in rhs:
for t in transpose:
if c == t[0]:
trhs += t[1]
c = None
break
if c is not None:
trhs += c
sed += "-e 's/@%s@/%s/' " % (tag, trhs)
bld(target="testsuite/include/rtems/bsd/test/network-config.h", bld(target="testsuite/include/rtems/bsd/test/network-config.h",
source="testsuite/include/rtems/bsd/test/network-config.h.in", source="testsuite/include/rtems/bsd/test/network-config.h.in",
rule=sed + " < ${SRC} > ${TGT}", rule=sed + " < ${SRC} > ${TGT}",
@ -585,11 +596,14 @@ class Builder(builder.ModuleManager):
test_source = [] test_source = []
libs = ['bsd', 'm', 'z', 'rtemstest'] libs = ['bsd', 'm', 'z', 'rtemstest']
for cfg in test: for cfg in test:
build_test = True if len(test[cfg]['modules']) == 0:
for mod in test[cfg]['modules']: build_test = True
if mod not in enabled_modules: else:
build_test = False build_test = False
break for mod in test[cfg]['modules']:
if mod in enabled_modules:
build_test = True
break
if build_test and cfg != 'default': if build_test and cfg != 'default':
for c in cfg.split(' '): for c in cfg.split(' '):
if not bld.env['HAVE_%s' % (c)]: if not bld.env['HAVE_%s' % (c)]: