mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-06-05 17:00:21 +08:00
sys/kern: Add VFS support
- Refactor the libio interface - Move syscalls into an rtemsbsd location - Provide a root directory mount point Update #4475
This commit is contained in:
parent
ac4db4cec5
commit
6514d56158
@ -104,6 +104,9 @@ UseTab: Always
|
||||
SpaceAfterCStyleCast: false
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^\<machine/rtems-bsd-kernel-space.h>$'
|
||||
Priority: 1
|
||||
SortPriority: 10
|
||||
- Regex: '^\"opt_.*\.h\"'
|
||||
Priority: 1
|
||||
SortPriority: 10
|
||||
|
19
README.md
19
README.md
@ -216,7 +216,7 @@ An example to turn on a verbose kernel boot, verbose sysinit and bus debugging
|
||||
configure with:
|
||||
|
||||
```
|
||||
--freebsd-options=bootverbose,verbose_sysinit,bus_debug
|
||||
--freebsd-options=bootverbose,verbose_sysinit,bus_debug,debug_locks,ktr,ktr_verbose
|
||||
```
|
||||
|
||||
The LibBSD Waf support splits the options and converts them to uppercase and
|
||||
@ -224,12 +224,17 @@ adds them -D options on the compiler command line.
|
||||
|
||||
The list is:
|
||||
|
||||
bootverbose: Verbose boot of the kernel
|
||||
verbose_sysinit: Verbose printing of all the SYSINIT calls
|
||||
bus_debug: Bus debugging support
|
||||
ktr: Kernel trace
|
||||
ktr_verbose: Verbose kernel trace
|
||||
invariants: Invariants build of the kernel
|
||||
bootverbose: Verbose boot of the kernel
|
||||
verbose_sysinit: Verbose printing of all the SYSINIT calls
|
||||
bus_debug: Bus debugging support
|
||||
ktr: Kernel trace
|
||||
ktr_verbose: Verbose kernel trace
|
||||
debug_locks: FreeBSD locks debugging
|
||||
invariants: Invariants build of the kernel
|
||||
invariant_support: Support for Invariants (needed with invariants)
|
||||
rtems_bsd_descrip_trace: RTEMS BSD descriptor maping trace
|
||||
rtems_bsd_syscall_trace: RTEMS BSD system call trace
|
||||
rtems_bsd_vfs_trace RTEMS VFS to libio trace
|
||||
|
||||
SMP Requirements
|
||||
----------------
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -31,7 +33,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_pseudofs.h"
|
||||
#include <rtems/bsd/local/opt_pseudofs.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -54,7 +54,11 @@ struct vnode;
|
||||
*/
|
||||
#define PFS_NAMELEN 128
|
||||
#define PFS_FSNAMELEN 16 /* equal to MFSNAMELEN */
|
||||
#ifndef __rtems__
|
||||
#define PFS_DELEN (offsetof(struct dirent, d_name) + PFS_NAMELEN)
|
||||
#else /* __rtems__ */
|
||||
#define PFS_DELEN (offsetof(struct dirent, d_name) + PFS_NAMELEN + 2)
|
||||
#endif /* __rtems__ */
|
||||
|
||||
typedef enum {
|
||||
pfstype_none = 0,
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -31,7 +33,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_pseudofs.h"
|
||||
#include <rtems/bsd/local/opt_pseudofs.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -31,7 +33,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_pseudofs.h"
|
||||
#include <rtems/bsd/local/opt_pseudofs.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -31,7 +33,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_pseudofs.h"
|
||||
#include <rtems/bsd/local/opt_pseudofs.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -95,6 +97,7 @@ pfs_visible_proc(struct thread *td, struct pfs_node *pn, struct proc *proc)
|
||||
|
||||
PROC_LOCK_ASSERT(proc, MA_OWNED);
|
||||
|
||||
#ifndef __rtems__
|
||||
visible = ((proc->p_flag & P_WEXIT) == 0);
|
||||
if (visible)
|
||||
visible = (p_cansee(td, proc) == 0);
|
||||
@ -102,6 +105,7 @@ pfs_visible_proc(struct thread *td, struct pfs_node *pn, struct proc *proc)
|
||||
visible = pn_vis(td, proc, pn);
|
||||
if (!visible)
|
||||
return (0);
|
||||
#endif /* __rtems__ */
|
||||
return (1);
|
||||
}
|
||||
|
||||
@ -118,7 +122,11 @@ pfs_visible(struct thread *td, struct pfs_node *pn, pid_t pid,
|
||||
*p = NULL;
|
||||
if (pid == NO_PID)
|
||||
PFS_RETURN (1);
|
||||
#ifndef __rtems__
|
||||
proc = allproc_locked ? pfind_locked(pid) : pfind(pid);
|
||||
#else /* __rtems__ */
|
||||
proc = &proc0;
|
||||
#endif /* __rtems__ */
|
||||
if (proc == NULL)
|
||||
PFS_RETURN (0);
|
||||
if (pfs_visible_proc(td, pn, proc)) {
|
||||
@ -177,7 +185,11 @@ pfs_close(struct vop_close_args *va)
|
||||
PFS_RETURN (0);
|
||||
|
||||
if (pvd->pvd_pid != NO_PID) {
|
||||
#ifndef __rtems__
|
||||
proc = pfind(pvd->pvd_pid);
|
||||
#else /* __rtems__ */
|
||||
proc = &proc0;
|
||||
#endif /* __rtems__ */
|
||||
} else {
|
||||
proc = NULL;
|
||||
}
|
||||
@ -241,13 +253,17 @@ pfs_getattr(struct vop_getattr_args *va)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
if (proc != NULL) {
|
||||
vap->va_uid = proc->p_ucred->cr_ruid;
|
||||
vap->va_gid = proc->p_ucred->cr_rgid;
|
||||
} else {
|
||||
#endif /* __rtems__ */
|
||||
vap->va_uid = 0;
|
||||
vap->va_gid = 0;
|
||||
#ifndef __rtems__
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
if (pn->pn_attr != NULL)
|
||||
error = pn_attr(curthread, proc, pn, vap);
|
||||
@ -713,10 +729,14 @@ pfs_iterate(struct thread *td, struct proc *proc, struct pfs_node *pd,
|
||||
}
|
||||
if (*pn != NULL && (*pn)->pn_type == pfstype_procdir) {
|
||||
/* next process */
|
||||
#ifndef __rtems__
|
||||
if (*p == NULL)
|
||||
*p = LIST_FIRST(&allproc);
|
||||
else
|
||||
*p = LIST_NEXT(*p, p_list);
|
||||
#else /* __rtems__ */
|
||||
*p = &proc0;
|
||||
#endif /* __rtems__ */
|
||||
/* out of processes: next node */
|
||||
if (*p == NULL)
|
||||
*pn = (*pn)->pn_next;
|
||||
@ -895,6 +915,7 @@ pfs_readlink(struct vop_readlink_args *va)
|
||||
if (pn->pn_fill == NULL)
|
||||
PFS_RETURN (EIO);
|
||||
|
||||
#ifndef __rtems__
|
||||
if (pvd->pvd_pid != NO_PID) {
|
||||
if ((proc = pfind(pvd->pvd_pid)) == NULL)
|
||||
PFS_RETURN (EIO);
|
||||
@ -905,6 +926,7 @@ pfs_readlink(struct vop_readlink_args *va)
|
||||
_PHOLD(proc);
|
||||
PROC_UNLOCK(proc);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
vhold(vn);
|
||||
locked = VOP_ISLOCKED(vn);
|
||||
VOP_UNLOCK(vn, 0);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -39,9 +41,9 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_capsicum.h"
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_ktrace.h"
|
||||
#include <rtems/bsd/local/opt_capsicum.h>
|
||||
#include <rtems/bsd/local/opt_ddb.h>
|
||||
#include <rtems/bsd/local/opt_ktrace.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -74,7 +76,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/syscallsubr.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <rtems/bsd/sys/unistd.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/vnode.h>
|
||||
#ifdef KTRACE
|
||||
@ -360,6 +362,7 @@ sys_getdtablesize(struct thread *td, struct getdtablesize_args *uap)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Duplicate a file descriptor to a particular value.
|
||||
*
|
||||
@ -480,6 +483,7 @@ kern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg)
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
||||
@ -502,6 +506,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
||||
AUDIT_ARG_FD(cmd);
|
||||
AUDIT_ARG_CMD(cmd);
|
||||
switch (cmd) {
|
||||
#ifndef __rtems__
|
||||
case F_DUPFD:
|
||||
tmp = arg;
|
||||
error = kern_dup(td, FDDUP_FCNTL, 0, fd, tmp);
|
||||
@ -521,6 +526,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
||||
tmp = arg;
|
||||
error = kern_dup(td, FDDUP_FIXED, FDDUP_FLAG_CLOEXEC, fd, tmp);
|
||||
break;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
case F_GETFD:
|
||||
error = EBADF;
|
||||
@ -581,6 +587,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
||||
fdrop(fp, td);
|
||||
break;
|
||||
|
||||
#ifndef __rtems__
|
||||
case F_GETOWN:
|
||||
error = fget_fcntl(td, fd, &cap_fcntl_rights, F_GETOWN, &fp);
|
||||
if (error != 0)
|
||||
@ -797,6 +804,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
||||
VOP_UNLOCK(vp, 0);
|
||||
fdrop(fp, td);
|
||||
break;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
default:
|
||||
error = EINVAL;
|
||||
@ -812,6 +820,7 @@ getmaxfd(struct thread *td)
|
||||
return (min((int)lim_cur(td, RLIMIT_NOFILE), maxfilesperproc));
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Common code for dup, dup2, fcntl(F_DUPFD) and fcntl(F_DUP2FD).
|
||||
*/
|
||||
@ -1173,6 +1182,7 @@ fgetown(struct sigio **sigiop)
|
||||
SIGIO_UNLOCK();
|
||||
return (pgid);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Function drops the filedesc lock on return.
|
||||
@ -1263,6 +1273,7 @@ kern_close(struct thread *td, int fd)
|
||||
return (closefp(fdp, fd, fp, td, 1));
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Close open file descriptors.
|
||||
*/
|
||||
@ -1298,6 +1309,7 @@ sys_closefrom(struct thread *td, struct closefrom_args *uap)
|
||||
FILEDESC_SUNLOCK(fdp);
|
||||
return (0);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#if defined(COMPAT_43)
|
||||
/*
|
||||
@ -1424,6 +1436,7 @@ freebsd11_nfstat(struct thread *td, struct freebsd11_nfstat_args *uap)
|
||||
}
|
||||
#endif /* COMPAT_FREEBSD11 */
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Return pathconf information about a file descriptor.
|
||||
*/
|
||||
@ -1480,6 +1493,7 @@ out:
|
||||
fdrop(fp, td);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Initialize filecaps structure.
|
||||
@ -1614,6 +1628,7 @@ static void
|
||||
filecaps_validate(const struct filecaps *fcaps, const char *func)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
KASSERT(cap_rights_is_valid(&fcaps->fc_rights),
|
||||
("%s: invalid rights", func));
|
||||
KASSERT((fcaps->fc_fcntls & ~CAP_FCNTL_ALL) == 0,
|
||||
@ -1627,6 +1642,7 @@ filecaps_validate(const struct filecaps *fcaps, const char *func)
|
||||
KASSERT(fcaps->fc_nioctls == 0 ||
|
||||
cap_rights_is_set(&fcaps->fc_rights, CAP_IOCTL),
|
||||
("%s: ioctls without CAP_IOCTL", func));
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1875,10 +1891,12 @@ falloc_noinstall(struct thread *td, struct file **resultfp)
|
||||
priv_check(td, PRIV_MAXFILES) != 0) ||
|
||||
openfiles_new >= maxfiles) {
|
||||
atomic_subtract_int(&openfiles, 1);
|
||||
#ifndef __rtems__
|
||||
if (ppsratecheck(&lastfail, &curfail, 1)) {
|
||||
printf("kern.maxfiles limit exceeded by uid %i, (%s) "
|
||||
"please see tuning(7).\n", td->td_ucred->cr_ruid, td->td_proc->p_comm);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
return (ENFILE);
|
||||
}
|
||||
fp = uma_zalloc(file_zone, M_WAITOK);
|
||||
@ -2032,6 +2050,7 @@ fdshare(struct filedesc *fdp)
|
||||
return (fdp);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Unshare a filedesc structure, if necessary by making a copy
|
||||
*/
|
||||
@ -2385,6 +2404,7 @@ fdsetugidsafety(struct thread *td)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* If a specific file object occupies a specific file descriptor, close the
|
||||
@ -2407,6 +2427,7 @@ fdclose(struct thread *td, struct file *fp, int idx)
|
||||
FILEDESC_XUNLOCK(fdp);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Close any files on exec?
|
||||
*/
|
||||
@ -2432,6 +2453,7 @@ fdcloseexec(struct thread *td)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* It is unsafe for set[ug]id processes to be started with file
|
||||
@ -2500,6 +2522,7 @@ closef(struct file *fp, struct thread *td)
|
||||
*/
|
||||
if (fp->f_type == DTYPE_VNODE && td != NULL) {
|
||||
vp = fp->f_vnode;
|
||||
#ifndef __rtems__
|
||||
if ((td->td_proc->p_leader->p_flag & P_ADVLOCK) != 0) {
|
||||
lf.l_whence = SEEK_SET;
|
||||
lf.l_start = 0;
|
||||
@ -2508,6 +2531,7 @@ closef(struct file *fp, struct thread *td)
|
||||
(void) VOP_ADVLOCK(vp, (caddr_t)td->td_proc->p_leader,
|
||||
F_UNLCK, &lf, F_POSIX);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
fdtol = td->td_proc->p_fdtol;
|
||||
if (fdtol != NULL) {
|
||||
/*
|
||||
@ -2519,8 +2543,10 @@ closef(struct file *fp, struct thread *td)
|
||||
for (fdtol = fdtol->fdl_next;
|
||||
fdtol != td->td_proc->p_fdtol;
|
||||
fdtol = fdtol->fdl_next) {
|
||||
#ifndef __rtems__
|
||||
if ((fdtol->fdl_leader->p_flag &
|
||||
P_ADVLOCK) == 0)
|
||||
#endif /* __rtems__ */
|
||||
continue;
|
||||
fdtol->fdl_holdcount++;
|
||||
FILEDESC_XUNLOCK(fdp);
|
||||
@ -2720,6 +2746,18 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
|
||||
*seqp = seq;
|
||||
#endif
|
||||
}
|
||||
#ifdef __rtems__
|
||||
if (fp->f_io != NULL) {
|
||||
rtems_libio_iop_hold(fp->f_io);
|
||||
if (RTEMS_BSD_DESCRIP_TRACE)
|
||||
printf("bsd: fb: fget_unlocked: iop=%p %d (%d) fp=%p (%d) by %p\n",
|
||||
fp->f_io, fp->f_io->data0, fp->f_io->flags >> 12,
|
||||
fp, fp->f_count, __builtin_return_address(0));
|
||||
} else if (RTEMS_BSD_DESCRIP_TRACE) {
|
||||
printf("bsd: fb: fget_unlocked: iop=NULL -1 (0) fp=%p (%d) by %p\n",
|
||||
fp, fp->f_count, __builtin_return_address(0));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -2764,11 +2802,13 @@ _fget(struct thread *td, int fd, struct file **fpp, int flags,
|
||||
if ((fp->f_flag & flags) == 0)
|
||||
error = EBADF;
|
||||
break;
|
||||
#ifndef __rtems__
|
||||
case FEXEC:
|
||||
if ((fp->f_flag & (FREAD | FEXEC)) == 0 ||
|
||||
((fp->f_flag & FWRITE) != 0))
|
||||
error = EBADF;
|
||||
break;
|
||||
#endif /* __rtems__ */
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
@ -2791,6 +2831,7 @@ fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp)
|
||||
return (_fget(td, fd, fpp, 0, rightsp, NULL));
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp, u_char *maxprotp,
|
||||
struct file **fpp)
|
||||
@ -2825,6 +2866,7 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp, u_char *maxprotp,
|
||||
#endif
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
fget_read(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp)
|
||||
@ -2944,12 +2986,14 @@ fgetvp_read(struct thread *td, int fd, cap_rights_t *rightsp, struct vnode **vpp
|
||||
return (_fgetvp(td, fd, FREAD, rightsp, vpp));
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
fgetvp_exec(struct thread *td, int fd, cap_rights_t *rightsp, struct vnode **vpp)
|
||||
{
|
||||
|
||||
return (_fgetvp(td, fd, FEXEC, rightsp, vpp));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef notyet
|
||||
int
|
||||
@ -2977,12 +3021,15 @@ _fdrop(struct file *fp, struct thread *td)
|
||||
error = fo_close(fp, td);
|
||||
atomic_subtract_int(&openfiles, 1);
|
||||
crfree(fp->f_cred);
|
||||
#ifndef __rtems__
|
||||
free(fp->f_advice, M_FADVISE);
|
||||
#endif /* __rtems__ */
|
||||
uma_zfree(file_zone, fp);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Apply an advisory lock on a file descriptor.
|
||||
*
|
||||
@ -3201,6 +3248,7 @@ pwd_chroot(struct thread *td, struct vnode *vp)
|
||||
vrele(oldvp);
|
||||
return (0);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
void
|
||||
pwd_chdir(struct thread *td, struct vnode *vp)
|
||||
@ -3225,6 +3273,7 @@ pwd_chdir(struct thread *td, struct vnode *vp)
|
||||
void
|
||||
mountcheckdirs(struct vnode *olddp, struct vnode *newdp)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct filedesc *fdp;
|
||||
struct prison *pr;
|
||||
struct proc *p;
|
||||
@ -3285,6 +3334,7 @@ mountcheckdirs(struct vnode *olddp, struct vnode *newdp)
|
||||
sx_sunlock(&allprison_lock);
|
||||
while (nrele--)
|
||||
vrele(olddp);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
struct filedesc_to_leader *
|
||||
@ -3312,6 +3362,7 @@ filedesc_to_leader_alloc(struct filedesc_to_leader *old, struct filedesc *fdp, s
|
||||
return (fdtol);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
sysctl_kern_proc_nfds(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
@ -3810,6 +3861,7 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC_OFILEDESC, ofiledesc,
|
||||
CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_ofiledesc,
|
||||
"Process ofiledesc entries");
|
||||
#endif /* COMPAT_FREEBSD7 */
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
vntype_to_kinfo(int vtype)
|
||||
@ -3840,6 +3892,7 @@ vntype_to_kinfo(int vtype)
|
||||
return (KF_VTYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
static SYSCTL_NODE(_kern_proc, KERN_PROC_FILEDESC, filedesc,
|
||||
CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_filedesc,
|
||||
"Process filedesc entries");
|
||||
@ -3911,6 +3964,7 @@ sysctl_kern_proc_cwd(SYSCTL_HANDLER_ARGS)
|
||||
|
||||
static SYSCTL_NODE(_kern_proc, KERN_PROC_CWD, cwd, CTLFLAG_RD|CTLFLAG_MPSAFE,
|
||||
sysctl_kern_proc_cwd, "Process current working directory");
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef DDB
|
||||
/*
|
||||
@ -4059,7 +4113,11 @@ filelistinit(void *dummy)
|
||||
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
|
||||
mtx_init(&sigio_lock, "sigio lock", NULL, MTX_DEF);
|
||||
}
|
||||
#ifndef __rtems__
|
||||
SYSINIT(select, SI_SUB_LOCK, SI_ORDER_FIRST, filelistinit, NULL);
|
||||
#else /* __rtems__ */
|
||||
SYSINIT(select_sub_lock, SI_SUB_LOCK, SI_ORDER_FIRST, filelistinit, NULL);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
@ -4228,6 +4286,7 @@ invfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
@ -4281,3 +4340,4 @@ fildesc_drvinit(void *unused)
|
||||
}
|
||||
|
||||
SYSINIT(fildescdev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, fildesc_drvinit, NULL);
|
||||
#endif /* __rtems__ */
|
||||
|
@ -81,8 +81,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <vm/uma.h>
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-syscall-api.h>
|
||||
|
||||
/* Maintain a global kqueue list on RTEMS */
|
||||
static struct kqlist fd_kqlist;
|
||||
#endif /* __rtems__ */
|
||||
@ -131,7 +129,6 @@ static int kern_kevent_generic(struct thread *td,
|
||||
struct g_kevent_args *uap,
|
||||
struct kevent_copyops *k_ops, const char *struct_name);
|
||||
|
||||
#ifndef __rtems__
|
||||
static fo_rdwr_t kqueue_read;
|
||||
static fo_rdwr_t kqueue_write;
|
||||
static fo_truncate_t kqueue_truncate;
|
||||
@ -156,9 +153,6 @@ static struct fileops kqueueops = {
|
||||
.fo_sendfile = invfo_sendfile,
|
||||
.fo_fill_kinfo = kqueue_fill_kinfo,
|
||||
};
|
||||
#else /* __rtems__ */
|
||||
static const rtems_filesystem_file_handlers_r kqueueops;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int knote_attach(struct knote *kn, struct kqueue *kq);
|
||||
static void knote_drop(struct knote *kn, struct thread *td);
|
||||
@ -399,14 +393,27 @@ static int
|
||||
filt_fileattach(struct knote *kn)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
return (fo_kqfilter(kn->kn_fp, kn));
|
||||
#else /* __rtems__ */
|
||||
if ((kn->kn_status & KN_FP_IS_IOP) == 0) {
|
||||
return (fo_kqfilter(kn->kn_fp, kn));
|
||||
} else {
|
||||
rtems_libio_t* iop = (rtems_libio_t*) kn->kn_fp;
|
||||
return ((*iop->pathinfo.handlers->kqfilter_h)(iop, kn));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
kqueue_kqfilter(struct file *fp, struct knote *kn)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct kqueue *kq = kn->kn_fp->f_data;
|
||||
#else /* __rtems__ */
|
||||
struct kqueue *kq = rtems_bsd_libio_knote_to_kq(kn);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
if (kn->kn_filter != EVFILT_READ)
|
||||
return (EINVAL);
|
||||
@ -417,20 +424,15 @@ kqueue_kqfilter(struct file *fp, struct knote *kn)
|
||||
|
||||
return (0);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_kqueue_kqfilter(rtems_libio_t *iop, struct knote *kn)
|
||||
{
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
|
||||
return kqueue_kqfilter(fp, kn);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void
|
||||
filt_kqdetach(struct knote *kn)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct kqueue *kq = kn->kn_fp->f_data;
|
||||
#else /* __rtems__ */
|
||||
struct kqueue *kq = rtems_bsd_libio_knote_to_kq(kn);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
knlist_remove(&kq->kq_sel.si_note, kn, 0);
|
||||
}
|
||||
@ -439,7 +441,11 @@ filt_kqdetach(struct knote *kn)
|
||||
static int
|
||||
filt_kqueue(struct knote *kn, long hint)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct kqueue *kq = kn->kn_fp->f_data;
|
||||
#else /* __rtems__ */
|
||||
struct kqueue *kq = rtems_bsd_libio_knote_to_kq(kn);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
kn->kn_data = kq->kq_count;
|
||||
return (kn->kn_data > 0);
|
||||
@ -991,12 +997,6 @@ filt_usertouch(struct knote *kn, struct kevent *kev, u_long type)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps);
|
||||
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_kqueue(struct thread *td, struct kqueue_args *uap)
|
||||
{
|
||||
@ -1023,15 +1023,10 @@ kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps)
|
||||
struct ucred *cred;
|
||||
int fd, error;
|
||||
|
||||
#ifndef __rtems__
|
||||
fdp = td->td_proc->p_fd;
|
||||
cred = td->td_ucred;
|
||||
if (!chgkqcnt(cred->cr_ruidinfo, 1, lim_cur(td, RLIMIT_KQUEUES)))
|
||||
return (ENOMEM);
|
||||
#else /* __rtems__ */
|
||||
(void)fdp;
|
||||
(void)cred;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
error = falloc_caps(td, &fp, &fd, flags, fcaps);
|
||||
if (error != 0) {
|
||||
@ -1042,50 +1037,19 @@ kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps)
|
||||
/* An extra reference on `fp' has been held for us by falloc(). */
|
||||
kq = malloc(sizeof *kq, M_KQUEUE, M_WAITOK | M_ZERO);
|
||||
kqueue_init(kq);
|
||||
#ifndef __rtems__
|
||||
kq->kq_fdp = fdp;
|
||||
kq->kq_cred = crhold(cred);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
FILEDESC_XLOCK(fdp);
|
||||
TAILQ_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list);
|
||||
FILEDESC_XUNLOCK(fdp);
|
||||
#else /* __rtems__ */
|
||||
rtems_libio_lock();
|
||||
TAILQ_INSERT_HEAD(&fd_kqlist, kq, kq_list);
|
||||
rtems_libio_unlock();
|
||||
#endif /* __rtems__ */
|
||||
|
||||
finit(fp, FREAD | FWRITE, DTYPE_KQUEUE, kq, &kqueueops);
|
||||
#ifndef __rtems__
|
||||
fdrop(fp, td);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
td->td_retval[0] = fd;
|
||||
return (0);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
kqueue(void)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct kqueue_args ua;
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_kqueue(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
struct g_kevent_args {
|
||||
int fd;
|
||||
@ -1096,15 +1060,6 @@ struct g_kevent_args {
|
||||
const struct timespec *timeout;
|
||||
};
|
||||
|
||||
#ifdef __rtems__
|
||||
static int kern_kevent(struct thread *td, int fd, int nchanges, int nevents,
|
||||
struct kevent_copyops *k_ops, const struct timespec *timeout);
|
||||
|
||||
static int kern_kevent_fp(struct thread *td, struct file *fp, int nchanges,
|
||||
int nevents, struct kevent_copyops *k_ops, const struct timespec *timeout);
|
||||
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_kevent(struct thread *td, struct kevent_args *uap)
|
||||
{
|
||||
@ -1161,38 +1116,6 @@ kern_kevent_generic(struct thread *td, struct g_kevent_args *uap,
|
||||
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
__weak_reference(kevent, _kevent);
|
||||
|
||||
int
|
||||
kevent(int kq, const struct kevent *changelist, int nchanges,
|
||||
struct kevent *eventlist, int nevents,
|
||||
const struct timespec *timeout)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct kevent_args ua = {
|
||||
.fd = kq,
|
||||
.changelist = changelist,
|
||||
.nchanges = nchanges,
|
||||
.eventlist = eventlist,
|
||||
.nevents = nevents,
|
||||
.timeout = timeout
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_kevent(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Copy 'count' items into the destination list pointed to by uap->eventlist.
|
||||
@ -1503,6 +1426,9 @@ kqueue_register(struct kqueue *kq, struct kevent *kev, struct thread *td,
|
||||
{
|
||||
struct filterops *fops;
|
||||
struct file *fp;
|
||||
#ifdef __rtems__
|
||||
rtems_libio_t* iop = NULL;
|
||||
#endif /* __rtems__ */
|
||||
struct knote *kn, *tkn;
|
||||
struct knlist *knl;
|
||||
int error, filt, event;
|
||||
@ -1540,15 +1466,39 @@ findkn:
|
||||
if (kev->ident > INT_MAX)
|
||||
error = EBADF;
|
||||
else
|
||||
#ifndef __rtems__
|
||||
error = fget(td, kev->ident, &cap_event_rights, &fp);
|
||||
#else /* __rtems__ */
|
||||
{
|
||||
int ffd = rtems_bsd_libio_iop_hold(kev->ident, &iop);
|
||||
if (ffd < 0)
|
||||
error = EBADF;
|
||||
else {
|
||||
if (iop == NULL)
|
||||
error = fget(td, ffd, &cap_event_rights, &fp);
|
||||
else
|
||||
fp = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
if (error)
|
||||
goto done;
|
||||
|
||||
if ((kev->flags & EV_ADD) == EV_ADD && kqueue_expand(kq, fops,
|
||||
kev->ident, M_NOWAIT) != 0) {
|
||||
#ifndef __rtems__
|
||||
/* try again */
|
||||
fdrop(fp, td);
|
||||
fp = NULL;
|
||||
#else /* __rtems__ */
|
||||
if (fp != NULL) {
|
||||
fdrop(fp, td);
|
||||
fp = NULL;
|
||||
} else if (iop != NULL) {
|
||||
rtems_libio_iop_drop(iop);
|
||||
iop = NULL;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
error = kqueue_expand(kq, fops, kev->ident, mflag);
|
||||
if (error)
|
||||
goto done;
|
||||
@ -1558,7 +1508,7 @@ findkn:
|
||||
#ifndef __rtems__
|
||||
if (fp->f_type == DTYPE_KQUEUE) {
|
||||
#else /* __rtems__ */
|
||||
if (fp->f_io.pathinfo.handlers == &kqueueops) {
|
||||
if (fp != NULL && fp->f_type == DTYPE_KQUEUE) {
|
||||
#endif /* __rtems__ */
|
||||
/*
|
||||
* If we add some intelligence about what we are doing,
|
||||
@ -1632,6 +1582,12 @@ findkn:
|
||||
fdrop(fp, td);
|
||||
fp = NULL;
|
||||
}
|
||||
#ifdef __rtems__
|
||||
if (iop != NULL) {
|
||||
rtems_libio_iop_drop(iop);
|
||||
iop = NULL;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
goto findkn;
|
||||
}
|
||||
|
||||
@ -1647,7 +1603,17 @@ findkn:
|
||||
error = ENOMEM;
|
||||
goto done;
|
||||
}
|
||||
#ifndef __rtems__
|
||||
kn->kn_fp = fp;
|
||||
#else /* __rtems__ */
|
||||
if (fp != NULL) {
|
||||
kn->kn_fp = fp;
|
||||
kn->kn_status = 0;
|
||||
} else if (iop != NULL) {
|
||||
rtems_bsd_libio_iop_to_knote(kn, iop);
|
||||
kn->kn_status = KN_FP_IS_IOP;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
kn->kn_kq = kq;
|
||||
kn->kn_fop = fops;
|
||||
/*
|
||||
@ -1656,6 +1622,9 @@ findkn:
|
||||
*/
|
||||
fops = NULL;
|
||||
fp = NULL;
|
||||
#ifdef __rtems__
|
||||
iop = NULL;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
kn->kn_sfflags = kev->fflags;
|
||||
kn->kn_sdata = kev->data;
|
||||
@ -1664,7 +1633,11 @@ findkn:
|
||||
kn->kn_kevent = *kev;
|
||||
kn->kn_kevent.flags &= ~(EV_ADD | EV_DELETE |
|
||||
EV_ENABLE | EV_DISABLE | EV_FORCEONESHOT);
|
||||
#ifndef __rtems__
|
||||
kn->kn_status = KN_DETACHED;
|
||||
#else /* __rtems__ */
|
||||
kn->kn_status |= KN_DETACHED;
|
||||
#endif /* __rtems__ */
|
||||
if ((kev->flags & EV_DISABLE) != 0)
|
||||
kn->kn_status |= KN_DISABLED;
|
||||
kn_enter_flux(kn);
|
||||
@ -1757,6 +1730,10 @@ done:
|
||||
FILEDESC_XUNLOCK(td->td_proc->p_fd);
|
||||
if (fp != NULL)
|
||||
fdrop(fp, td);
|
||||
#ifdef __rtems__
|
||||
if (iop != NULL)
|
||||
rtems_libio_iop_drop(iop);
|
||||
#endif /* __rtems__ */
|
||||
knote_free(tkn);
|
||||
if (fops != NULL)
|
||||
kqueue_fo_release(filt);
|
||||
@ -1772,11 +1749,7 @@ kqueue_acquire(struct file *fp, struct kqueue **kqp)
|
||||
error = 0;
|
||||
|
||||
kq = fp->f_data;
|
||||
#ifndef __rtems__
|
||||
if (fp->f_type != DTYPE_KQUEUE || kq == NULL)
|
||||
#else /* __rtems__ */
|
||||
if (fp->f_io.pathinfo.handlers != &kqueueops || kq == NULL)
|
||||
#endif /* __rtems__ */
|
||||
return (EBADF);
|
||||
*kqp = kq;
|
||||
KQ_LOCK(kq);
|
||||
@ -2117,7 +2090,6 @@ done_nl:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
kqueue_ioctl(struct file *fp, u_long cmd, void *data,
|
||||
@ -2165,7 +2137,6 @@ kqueue_ioctl(struct file *fp, u_long cmd, void *data,
|
||||
|
||||
return (ENOTTY);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
@ -2193,39 +2164,14 @@ kqueue_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
KQ_UNLOCK(kq);
|
||||
return (revents);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_kqueue_poll(rtems_libio_t *iop, int events)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = kqueue_poll(fp, events, NULL, td);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*ARGSUSED*/
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
kqueue_stat(struct file *fp, struct stat *st, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
|
||||
bzero((void *)st, sizeof *st);
|
||||
#else /* __rtems__ */
|
||||
static int
|
||||
rtems_bsd_kqueue_stat(const rtems_filesystem_location_info_t *loc,
|
||||
struct stat *st)
|
||||
{
|
||||
(void) loc;
|
||||
#endif /* __rtems__ */
|
||||
/*
|
||||
* We no longer return kq_count because the unlocked value is useless.
|
||||
* If you spent all this time getting the count, why not spend your
|
||||
@ -2304,10 +2250,8 @@ static void
|
||||
kqueue_destroy(struct kqueue *kq)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
KASSERT(kq->kq_fdp == NULL,
|
||||
("kqueue still attached to a file descriptor"));
|
||||
#endif /* __rtems__ */
|
||||
seldrain(&kq->kq_sel);
|
||||
knlist_destroy(&kq->kq_sel.si_note);
|
||||
mtx_destroy(&kq->kq_lock);
|
||||
@ -2333,7 +2277,6 @@ kqueue_close(struct file *fp, struct thread *td)
|
||||
return error;
|
||||
kqueue_drain(kq, td);
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* We could be called due to the knote_drop() doing fdrop(),
|
||||
* called from kqueue_register(). In this case the global
|
||||
@ -2350,12 +2293,6 @@ kqueue_close(struct file *fp, struct thread *td)
|
||||
TAILQ_REMOVE(&fdp->fd_kqlist, kq, kq_list);
|
||||
if (filedesc_unlock)
|
||||
FILEDESC_XUNLOCK(fdp);
|
||||
#else /* __rtems__ */
|
||||
(void)filedesc_unlock;
|
||||
rtems_libio_lock();
|
||||
TAILQ_REMOVE(&fd_kqlist, kq, kq_list);
|
||||
rtems_libio_unlock();
|
||||
#endif /* __rtems__ */
|
||||
|
||||
kqueue_destroy(kq);
|
||||
chgkqcnt(kq->kq_cred->cr_ruidinfo, -1, 0);
|
||||
@ -2365,25 +2302,7 @@ kqueue_close(struct file *fp, struct thread *td)
|
||||
|
||||
return (0);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_kqueue_close(rtems_libio_t *iop)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = kqueue_close(fp, td);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
kqueue_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
|
||||
{
|
||||
@ -2391,7 +2310,6 @@ kqueue_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
|
||||
kif->kf_type = KF_TYPE_KQUEUE;
|
||||
return (0);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void
|
||||
kqueue_wakeup(struct kqueue *kq)
|
||||
@ -2756,28 +2674,18 @@ again: /* need to reacquire lock since we have dropped it */
|
||||
void
|
||||
knote_fdclose(struct thread *td, int fd)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct filedesc *fdp = td->td_proc->p_fd;
|
||||
#endif /* __rtems__ */
|
||||
struct kqueue *kq;
|
||||
struct knote *kn;
|
||||
int influx;
|
||||
|
||||
#ifndef __rtems__
|
||||
FILEDESC_XLOCK_ASSERT(fdp);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* We shouldn't have to worry about new kevents appearing on fd
|
||||
* since filedesc is locked.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
TAILQ_FOREACH(kq, &fdp->fd_kqlist, kq_list) {
|
||||
#else /* __rtems__ */
|
||||
/* FIXME: Use separate lock? */
|
||||
rtems_libio_lock();
|
||||
TAILQ_FOREACH(kq, &fd_kqlist, kq_list) {
|
||||
#endif /* __rtems__ */
|
||||
KQ_LOCK(kq);
|
||||
|
||||
again:
|
||||
@ -2800,9 +2708,6 @@ again:
|
||||
}
|
||||
KQ_UNLOCK_FLUX(kq);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
rtems_libio_unlock();
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static int
|
||||
@ -2865,7 +2770,14 @@ knote_drop_detached(struct knote *kn, struct thread *td)
|
||||
KQ_UNLOCK_FLUX(kq);
|
||||
|
||||
if (kn->kn_fop->f_isfd) {
|
||||
#ifndef __rtems__
|
||||
fdrop(kn->kn_fp, td);
|
||||
#else /* __rtems__ */
|
||||
if ((kn->kn_status & KN_FP_IS_IOP) == 0)
|
||||
fdrop(kn->kn_fp, td);
|
||||
else
|
||||
rtems_libio_iop_drop((rtems_libio_t*) kn->kn_fp);
|
||||
#endif /* __rtems__ */
|
||||
kn->kn_fp = NULL;
|
||||
}
|
||||
kqueue_fo_release(kn->kn_kevent.filter);
|
||||
@ -2947,23 +2859,3 @@ noacquire:
|
||||
fdrop(fp, td);
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static const rtems_filesystem_file_handlers_r kqueueops = {
|
||||
.open_h = rtems_filesystem_default_open,
|
||||
.close_h = rtems_bsd_kqueue_close,
|
||||
.read_h = rtems_filesystem_default_read,
|
||||
.write_h = rtems_filesystem_default_write,
|
||||
.ioctl_h = rtems_filesystem_default_ioctl,
|
||||
.lseek_h = rtems_filesystem_default_lseek,
|
||||
.fstat_h = rtems_bsd_kqueue_stat,
|
||||
.ftruncate_h = rtems_filesystem_default_ftruncate,
|
||||
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
|
||||
.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
|
||||
.fcntl_h = rtems_filesystem_default_fcntl,
|
||||
.poll_h = rtems_bsd_kqueue_poll,
|
||||
.kqfilter_h = rtems_bsd_kqueue_kqfilter,
|
||||
.readv_h = rtems_filesystem_default_readv,
|
||||
.writev_h = rtems_filesystem_default_writev,
|
||||
.mmap_h = rtems_filesystem_default_mmap
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
|
@ -71,10 +71,8 @@ SYSCTL_ROOT_NODE(CTL_KERN, kern, CTLFLAG_RW|CTLFLAG_CAPRD, 0,
|
||||
"High kernel, proc, limits &c");
|
||||
SYSCTL_ROOT_NODE(CTL_VM, vm, CTLFLAG_RW, 0,
|
||||
"Virtual memory");
|
||||
#ifndef __rtems__
|
||||
SYSCTL_ROOT_NODE(CTL_VFS, vfs, CTLFLAG_RW, 0,
|
||||
"File system");
|
||||
#endif /* __rtems__ */
|
||||
SYSCTL_ROOT_NODE(CTL_NET, net, CTLFLAG_RW, 0,
|
||||
"Network, (see socket.h)");
|
||||
SYSCTL_ROOT_NODE(CTL_DEBUG, debug, CTLFLAG_RW, 0,
|
||||
|
@ -1773,11 +1773,7 @@ sysctl_new_kernel(struct sysctl_req *req, void *p, size_t l)
|
||||
|
||||
int
|
||||
kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
|
||||
#ifndef __rtems__
|
||||
size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags)
|
||||
#else /* __rtems__ */
|
||||
size_t *oldlenp, const void *new, size_t newlen, size_t *retval, int flags)
|
||||
#endif /* __rtems__ */
|
||||
{
|
||||
int error = 0;
|
||||
struct sysctl_req req;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
@ -49,7 +51,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include <rtems/bsd/local/opt_ddb.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -296,7 +296,6 @@ out:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Wrapper for uiomove() that validates the arguments against a known-good
|
||||
* kernel buffer. Currently, uiomove accepts a signed (n) argument, which
|
||||
@ -319,6 +318,7 @@ uiomove_frombuf(void *buf, int buflen, struct uio *uio)
|
||||
return (uiomove((char *)buf + offset, n, uio));
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Give next character to user as result of read.
|
||||
*/
|
||||
|
@ -77,12 +77,6 @@ __FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#include <security/audit/audit.h>
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-syscall-api.h>
|
||||
|
||||
static int kern_select(struct thread *, int, fd_set *, fd_set *,
|
||||
fd_set *, struct timeval *, int);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* The following macro defines how many bytes will be allocated from
|
||||
@ -98,7 +92,6 @@ static int kern_select(struct thread *, int, fd_set *, fd_set *,
|
||||
#define SYS_IOCTL_SMALL_SIZE 128 /* bytes */
|
||||
#define SYS_IOCTL_SMALL_ALIGN 8 /* bytes */
|
||||
|
||||
#ifndef __rtems__
|
||||
#ifdef __LP64__
|
||||
static int iosize_max_clamp = 0;
|
||||
SYSCTL_INT(_debug, OID_AUTO, iosize_max_clamp, CTLFLAG_RW,
|
||||
@ -108,6 +101,7 @@ SYSCTL_INT(_debug, OID_AUTO, devfs_iosize_max_clamp, CTLFLAG_RW,
|
||||
&devfs_iosize_max_clamp, 0, "Clamp max i/o size to INT_MAX for devices");
|
||||
#endif
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Assert that the return value of read(2) and write(2) syscalls fits
|
||||
* into a register. If not, an architecture will need to provide the
|
||||
@ -130,12 +124,10 @@ static int selscan(struct thread *, fd_mask **, fd_mask **, int);
|
||||
static int selrescan(struct thread *, fd_mask **, fd_mask **);
|
||||
static void selfdalloc(struct thread *, void *);
|
||||
static void selfdfree(struct seltd *, struct selfd *);
|
||||
#ifndef __rtems__
|
||||
static int dofileread(struct thread *, int, struct file *, struct uio *,
|
||||
off_t, int);
|
||||
static int dofilewrite(struct thread *, int, struct file *, struct uio *,
|
||||
off_t, int);
|
||||
#endif /* __rtems__ */
|
||||
static void doselwakeup(struct selinfo *, int);
|
||||
static void seltdinit(struct thread *);
|
||||
static int seltdwait(struct thread *, sbintime_t, sbintime_t);
|
||||
@ -176,7 +168,6 @@ struct selfd {
|
||||
static uma_zone_t selfd_zone;
|
||||
static struct mtx_pool *mtxpool_select;
|
||||
|
||||
#ifndef __rtems__
|
||||
#ifdef __LP64__
|
||||
size_t
|
||||
devfs_iosize_max(void)
|
||||
@ -221,6 +212,7 @@ sys_read(struct thread *td, struct read_args *uap)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Positioned read system call
|
||||
*/
|
||||
@ -267,6 +259,7 @@ freebsd6_pread(struct thread *td, struct freebsd6_pread_args *uap)
|
||||
return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
|
||||
}
|
||||
#endif
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Scatter read system call.
|
||||
@ -306,6 +299,7 @@ kern_readv(struct thread *td, int fd, struct uio *auio)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Scatter positioned read system call.
|
||||
*/
|
||||
@ -350,6 +344,7 @@ kern_preadv(struct thread *td, int fd, struct uio *auio, off_t offset)
|
||||
fdrop(fp, td);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Common code for readv and preadv that reads data in
|
||||
@ -422,6 +417,7 @@ sys_write(struct thread *td, struct write_args *uap)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Positioned write system call.
|
||||
*/
|
||||
@ -469,6 +465,7 @@ freebsd6_pwrite(struct thread *td, struct freebsd6_pwrite_args *uap)
|
||||
return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
|
||||
}
|
||||
#endif
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Gather write system call.
|
||||
@ -508,6 +505,7 @@ kern_writev(struct thread *td, int fd, struct uio *auio)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Gather positioned write system call.
|
||||
*/
|
||||
@ -552,6 +550,7 @@ kern_pwritev(struct thread *td, int fd, struct uio *auio, off_t offset)
|
||||
fdrop(fp, td);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Common code for writev and pwritev that writes data to
|
||||
@ -583,12 +582,14 @@ dofilewrite(struct thread *td, int fd, struct file *fp, struct uio *auio,
|
||||
if (auio->uio_resid != cnt && (error == ERESTART ||
|
||||
error == EINTR || error == EWOULDBLOCK))
|
||||
error = 0;
|
||||
#ifndef __rtems__
|
||||
/* Socket layer is responsible for issuing SIGPIPE. */
|
||||
if (fp->f_type != DTYPE_SOCKET && error == EPIPE) {
|
||||
PROC_LOCK(td->td_proc);
|
||||
tdsignal(td, SIGPIPE);
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
cnt -= auio->uio_resid;
|
||||
#ifdef KTRACE
|
||||
@ -678,7 +679,11 @@ sys_ioctl(struct thread *td, struct ioctl_args *uap)
|
||||
if (uap->com > 0xffffffff) {
|
||||
printf(
|
||||
"WARNING pid %d (%s): ioctl sign-extension ioctl %lx\n",
|
||||
#ifndef __rtems__
|
||||
td->td_proc->p_pid, td->td_name, uap->com);
|
||||
#else /* __rtems__ */
|
||||
1, "BSD", uap->com);
|
||||
#endif /* __rtems__ */
|
||||
uap->com &= 0xffffffff;
|
||||
}
|
||||
com = uap->com;
|
||||
@ -706,7 +711,11 @@ sys_ioctl(struct thread *td, struct ioctl_args *uap)
|
||||
size = 0;
|
||||
} else {
|
||||
if (size > SYS_IOCTL_SMALL_SIZE)
|
||||
#ifndef __rtems__
|
||||
data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
|
||||
#else /* __rtems__ */
|
||||
panic("libbsd: ioctl size too big");
|
||||
#endif /* __rtems__ */
|
||||
else
|
||||
data = smalldata;
|
||||
}
|
||||
@ -730,8 +739,10 @@ sys_ioctl(struct thread *td, struct ioctl_args *uap)
|
||||
error = copyout(data, uap->data, (u_int)size);
|
||||
|
||||
out:
|
||||
#ifndef __rtems__
|
||||
if (size > SYS_IOCTL_SMALL_SIZE)
|
||||
free(data, M_IOCTLOPS);
|
||||
#endif /* __rtems__ */
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -835,7 +846,6 @@ out:
|
||||
fdrop(fp, td);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
poll_no_poll(int events)
|
||||
@ -853,7 +863,6 @@ poll_no_poll(int events)
|
||||
return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
sys_pselect(struct thread *td, struct pselect_args *uap)
|
||||
{
|
||||
@ -887,6 +896,7 @@ kern_pselect(struct thread *td, int nd, fd_set *in, fd_set *ou, fd_set *ex,
|
||||
{
|
||||
int error;
|
||||
|
||||
#ifndef __rtems__
|
||||
if (uset != NULL) {
|
||||
error = kern_sigprocmask(td, SIG_SETMASK, uset,
|
||||
&td->td_oldsigmask, 0);
|
||||
@ -902,6 +912,7 @@ kern_pselect(struct thread *td, int nd, fd_set *in, fd_set *ou, fd_set *ex,
|
||||
td->td_flags |= TDF_ASTPENDING;
|
||||
thread_unlock(td);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
error = kern_select(td, nd, in, ou, ex, tvp, abi_nfdbits);
|
||||
return (error);
|
||||
}
|
||||
@ -930,7 +941,6 @@ sys_select(struct thread *td, struct select_args *uap)
|
||||
return (kern_select(td, uap->nd, uap->in, uap->ou, uap->ex, tvp,
|
||||
NFDBITS));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* In the unlikely case when user specified n greater then the last
|
||||
@ -1000,14 +1010,11 @@ kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
|
||||
|
||||
if (nd < 0)
|
||||
return (EINVAL);
|
||||
#ifndef __rtems__
|
||||
fdp = td->td_proc->p_fd;
|
||||
#endif /* __rtems__ */
|
||||
ndu = nd;
|
||||
#ifndef __rtems__
|
||||
lf = fdp->fd_lastfile;
|
||||
#else /* __rtems__ */
|
||||
(void) fdp;
|
||||
lf = rtems_libio_number_iops;
|
||||
#endif /* __rtems__ */
|
||||
if (nd > lf + 1)
|
||||
@ -1162,65 +1169,6 @@ done:
|
||||
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds,
|
||||
struct timeval *timeout)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = kern_select(td, nfds, readfds, writefds, errorfds,
|
||||
timeout, NFDBITS);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds,
|
||||
const struct timespec *timeout, const sigset_t *set)
|
||||
{
|
||||
struct thread *td;
|
||||
int error;
|
||||
|
||||
if (set != NULL) {
|
||||
rtems_set_errno_and_return_minus_one(ENOSYS);
|
||||
}
|
||||
|
||||
td = rtems_bsd_get_curthread_or_null();
|
||||
|
||||
if (td != NULL) {
|
||||
struct timeval tv;
|
||||
struct timeval *tvp;
|
||||
|
||||
if (timeout != NULL) {
|
||||
TIMESPEC_TO_TIMEVAL(&tv, timeout);
|
||||
tvp = &tv;
|
||||
} else {
|
||||
tvp = NULL;
|
||||
}
|
||||
|
||||
error = kern_select(td, nfds, readfds, writefds, errorfds,
|
||||
tvp, NFDBITS);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Convert a select bit set to poll flags.
|
||||
@ -1291,6 +1239,17 @@ selsetbits(fd_mask **ibits, fd_mask **obits, int idx, fd_mask bit, int events)
|
||||
static __inline int
|
||||
getselfd_cap(struct filedesc *fdp, int fd, struct file **fpp)
|
||||
{
|
||||
#ifdef __rtems__
|
||||
rtems_libio_t *iop;
|
||||
int ffd = rtems_bsd_libio_iop_hold(fd, &iop);
|
||||
if (ffd < 0)
|
||||
return EBADF;
|
||||
if (iop != NULL) {
|
||||
*fpp = NULL;
|
||||
return 0;
|
||||
}
|
||||
fd = ffd;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
return (fget_unlocked(fdp, fd, &cap_event_rights, fpp, NULL));
|
||||
}
|
||||
@ -1312,11 +1271,7 @@ selrescan(struct thread *td, fd_mask **ibits, fd_mask **obits)
|
||||
int fd, ev, n, idx;
|
||||
int error;
|
||||
|
||||
#ifndef __rtems__
|
||||
fdp = td->td_proc->p_fd;
|
||||
#else /* __rtems__ */
|
||||
fdp = NULL;
|
||||
#endif /* __rtems__ */
|
||||
stp = td->td_sel;
|
||||
n = 0;
|
||||
STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) {
|
||||
@ -1331,8 +1286,15 @@ selrescan(struct thread *td, fd_mask **ibits, fd_mask **obits)
|
||||
return (error);
|
||||
idx = fd / NFDBITS;
|
||||
bit = (fd_mask)1 << (fd % NFDBITS);
|
||||
#ifndef __rtems__
|
||||
ev = fo_poll(fp, selflags(ibits, idx, bit), td->td_ucred, td);
|
||||
fdrop(fp, td);
|
||||
#else /* __rtems__ */
|
||||
ev = rtems_bsd_libio_fo_poll(fd, fp, selflags(ibits, idx, bit),
|
||||
td->td_ucred, td);
|
||||
if (fp != NULL)
|
||||
fdrop(fp, td);
|
||||
#endif /* __rtems__ */
|
||||
if (ev != 0)
|
||||
n += selsetbits(ibits, obits, idx, bit, ev);
|
||||
}
|
||||
@ -1355,11 +1317,7 @@ selscan(struct thread *td, fd_mask **ibits, fd_mask **obits, int nfd)
|
||||
int n, idx;
|
||||
int error;
|
||||
|
||||
#ifndef __rtems__
|
||||
fdp = td->td_proc->p_fd;
|
||||
#else /* __rtems__ */
|
||||
fdp = NULL;
|
||||
#endif /* __rtems__ */
|
||||
n = 0;
|
||||
for (idx = 0, fd = 0; fd < nfd; idx++) {
|
||||
end = imin(fd + NFDBITS, nfd);
|
||||
@ -1372,8 +1330,16 @@ selscan(struct thread *td, fd_mask **ibits, fd_mask **obits, int nfd)
|
||||
if (error)
|
||||
return (error);
|
||||
selfdalloc(td, (void *)(uintptr_t)fd);
|
||||
#ifndef __rtems__
|
||||
ev = fo_poll(fp, flags, td->td_ucred, td);
|
||||
fdrop(fp, td);
|
||||
#else /* __rtems__ */
|
||||
ev = rtems_bsd_libio_fo_poll(fd, fp,
|
||||
selflags(ibits, idx, bit),
|
||||
td->td_ucred, td);
|
||||
if (fp != NULL)
|
||||
fdrop(fp, td);
|
||||
#endif /* __rtems__ */
|
||||
if (ev != 0)
|
||||
n += selsetbits(ibits, obits, idx, bit, ev);
|
||||
}
|
||||
@ -1383,12 +1349,6 @@ selscan(struct thread *td, fd_mask **ibits, fd_mask **obits, int nfd)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
static int kern_poll(struct thread *td, struct pollfd *fds, u_int nfds,
|
||||
struct timespec *tsp, sigset_t *uset);
|
||||
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_poll(struct thread *td, struct poll_args *uap)
|
||||
{
|
||||
@ -1507,31 +1467,6 @@ out:
|
||||
free(bits, M_TEMP);
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
poll(struct pollfd fds[], nfds_t nfds, int timeout)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct poll_args ua = {
|
||||
.fds = &fds[0],
|
||||
.nfds = nfds,
|
||||
.timeout = timeout
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_poll(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
@ -1577,11 +1512,7 @@ pollrescan(struct thread *td)
|
||||
int n;
|
||||
|
||||
n = 0;
|
||||
#ifndef __rtems__
|
||||
fdp = td->td_proc->p_fd;
|
||||
#else /* __rtems__ */
|
||||
fdp = NULL;
|
||||
#endif /* __rtems__ */
|
||||
stp = td->td_sel;
|
||||
FILEDESC_SLOCK(fdp);
|
||||
STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) {
|
||||
@ -1593,15 +1524,24 @@ pollrescan(struct thread *td)
|
||||
continue;
|
||||
#ifndef __rtems__
|
||||
fp = fdp->fd_ofiles[fd->fd].fde_file;
|
||||
#else /* __rtems__ */
|
||||
fget_unlocked(fdp, fd->fd, NULL, &fp, NULL);
|
||||
#endif /* __rtems__ */
|
||||
#ifdef CAPABILITIES
|
||||
if (fp == NULL ||
|
||||
cap_check(cap_rights(fdp, fd->fd), &cap_event_rights) != 0)
|
||||
#else
|
||||
if (fp == NULL)
|
||||
#endif
|
||||
#else /* __rtems__ */
|
||||
rtems_libio_t* iop;
|
||||
int ffd = rtems_bsd_libio_iop_hold(fd->fd, &iop);
|
||||
if (ffd >= 0) {
|
||||
if (iop == NULL) {
|
||||
fp = fdp->fd_ofiles[ffd].fde_file;
|
||||
} else {
|
||||
fp = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* __rtems__ */
|
||||
{
|
||||
fd->revents = POLLNVAL;
|
||||
n++;
|
||||
@ -1612,9 +1552,10 @@ pollrescan(struct thread *td)
|
||||
* Note: backend also returns POLLHUP and
|
||||
* POLLERR if appropriate.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
fd->revents = fo_poll(fp, fd->events, td->td_ucred, td);
|
||||
#ifdef __rtems__
|
||||
rtems_libio_iop_drop(&fp->f_io);
|
||||
#else /* __rtems__ */
|
||||
fd->revents = rtems_bsd_libio_fo_poll(ffd, fp, fd->events, td->td_ucred, td);
|
||||
#endif /* __rtems__ */
|
||||
if (fd->revents != 0)
|
||||
n++;
|
||||
@ -1650,11 +1591,7 @@ pollout(struct thread *td, struct pollfd *fds, struct pollfd *ufds, u_int nfd)
|
||||
static int
|
||||
pollscan(struct thread *td, struct pollfd *fds, u_int nfd)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct filedesc *fdp = td->td_proc->p_fd;
|
||||
#else /* __rtems__ */
|
||||
struct filedesc *fdp = NULL;
|
||||
#endif /* __rtems__ */
|
||||
struct file *fp;
|
||||
int i, n = 0;
|
||||
|
||||
@ -1663,7 +1600,7 @@ pollscan(struct thread *td, struct pollfd *fds, u_int nfd)
|
||||
#ifndef __rtems__
|
||||
if (fds->fd > fdp->fd_lastfile) {
|
||||
#else /* __rtems__ */
|
||||
if ((uint32_t)fds->fd >= rtems_libio_number_iops) {
|
||||
if (fds->fd >= (int) rtems_libio_number_iops) {
|
||||
#endif /* __rtems__ */
|
||||
fds->revents = POLLNVAL;
|
||||
n++;
|
||||
@ -1672,15 +1609,24 @@ pollscan(struct thread *td, struct pollfd *fds, u_int nfd)
|
||||
} else {
|
||||
#ifndef __rtems__
|
||||
fp = fdp->fd_ofiles[fds->fd].fde_file;
|
||||
#else /* __rtems__ */
|
||||
fget_unlocked(fdp, fds->fd, NULL, &fp, NULL);
|
||||
#endif /* __rtems__ */
|
||||
#ifdef CAPABILITIES
|
||||
if (fp == NULL ||
|
||||
cap_check(cap_rights(fdp, fds->fd), &cap_event_rights) != 0)
|
||||
#else
|
||||
if (fp == NULL)
|
||||
#endif
|
||||
#else /* __rtems__ */
|
||||
rtems_libio_t* iop;
|
||||
int ffd = rtems_bsd_libio_iop_hold(fds->fd, &iop);
|
||||
if (ffd >= 0) {
|
||||
if (iop == NULL) {
|
||||
fp = fdp->fd_ofiles[ffd].fde_file;
|
||||
} else {
|
||||
fp = NULL;
|
||||
}
|
||||
}
|
||||
if (ffd < 0)
|
||||
#endif /* __rtems__ */
|
||||
{
|
||||
fds->revents = POLLNVAL;
|
||||
n++;
|
||||
@ -1690,10 +1636,12 @@ pollscan(struct thread *td, struct pollfd *fds, u_int nfd)
|
||||
* POLLERR if appropriate.
|
||||
*/
|
||||
selfdalloc(td, fds);
|
||||
#ifndef __rtems__
|
||||
fds->revents = fo_poll(fp, fds->events,
|
||||
td->td_ucred, td);
|
||||
#ifdef __rtems__
|
||||
rtems_libio_iop_drop(&fp->f_io);
|
||||
#else /* __rtems__ */
|
||||
fds->revents = rtems_bsd_libio_fo_poll(ffd, fp, fds->events,
|
||||
td->td_ucred, td);
|
||||
#endif /* __rtems__ */
|
||||
/*
|
||||
* POSIX requires POLLOUT to be never
|
||||
@ -2038,6 +1986,8 @@ kern_posix_error(struct thread *td, int error)
|
||||
#include <rtems/score/objectimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <rtems/bsd/util.h>
|
||||
|
||||
static void
|
||||
|
@ -147,7 +147,6 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* interfaces to the outside world
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
static fo_rdwr_t pipe_read;
|
||||
static fo_rdwr_t pipe_write;
|
||||
static fo_truncate_t pipe_truncate;
|
||||
@ -175,52 +174,9 @@ struct fileops pipeops = {
|
||||
.fo_fill_kinfo = pipe_fill_kinfo,
|
||||
.fo_flags = DFLAG_PASSABLE
|
||||
};
|
||||
#else /* __rtems__ */
|
||||
#define PIPE_NODIRECT
|
||||
#define PRIBIO (0)
|
||||
|
||||
static int rtems_bsd_pipe_open(rtems_libio_t *iop, const char *path,
|
||||
int oflag, mode_t mode);
|
||||
static int rtems_bsd_pipe_close(rtems_libio_t *iop);
|
||||
static ssize_t rtems_bsd_pipe_read(rtems_libio_t *iop, void *buffer,
|
||||
size_t count);
|
||||
static ssize_t rtems_bsd_pipe_readv(rtems_libio_t *iop,
|
||||
const struct iovec *iov, int iovcnt, ssize_t total);
|
||||
static ssize_t rtems_bsd_pipe_write(rtems_libio_t *iop, const void *buffer,
|
||||
size_t count);
|
||||
static ssize_t rtems_bsd_pipe_writev(rtems_libio_t *iop,
|
||||
const struct iovec *iov, int iovcnt, ssize_t total);
|
||||
static int rtems_bsd_pipe_ioctl(rtems_libio_t *iop, ioctl_command_t request,
|
||||
void *buffer);
|
||||
static int rtems_bsd_pipe_stat(const rtems_filesystem_location_info_t *loc,
|
||||
struct stat *buf);
|
||||
static int rtems_bsd_pipe_fcntl(rtems_libio_t *iop, int cmd);
|
||||
static int rtems_bsd_pipe_poll(rtems_libio_t *iop, int events);
|
||||
int rtems_bsd_pipe_kqfilter(rtems_libio_t *iop, struct knote *kn);
|
||||
|
||||
static const rtems_filesystem_file_handlers_r pipeops = {
|
||||
.open_h = rtems_bsd_pipe_open,
|
||||
.close_h = rtems_bsd_pipe_close,
|
||||
.read_h = rtems_bsd_pipe_read,
|
||||
.write_h = rtems_bsd_pipe_write,
|
||||
.ioctl_h = rtems_bsd_pipe_ioctl,
|
||||
.lseek_h = rtems_filesystem_default_lseek,
|
||||
.fstat_h = rtems_bsd_pipe_stat,
|
||||
.ftruncate_h = rtems_filesystem_default_ftruncate,
|
||||
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
|
||||
.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
|
||||
.fcntl_h = rtems_bsd_pipe_fcntl,
|
||||
.poll_h = rtems_bsd_pipe_poll,
|
||||
.kqfilter_h = rtems_bsd_pipe_kqfilter,
|
||||
.readv_h = rtems_bsd_pipe_readv,
|
||||
.writev_h = rtems_bsd_pipe_writev,
|
||||
.mmap_h = rtems_filesystem_default_mmap
|
||||
};
|
||||
|
||||
#ifdef __rtems__
|
||||
long maxpipekva; /* Limit on pipe KVA */
|
||||
|
||||
static int kern_pipe(struct thread *, int [2], int, struct filecaps *,
|
||||
struct filecaps *);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void filt_pipedetach(struct knote *kn);
|
||||
@ -297,7 +253,11 @@ static uma_zone_t pipe_zone;
|
||||
static struct unrhdr64 pipeino_unr;
|
||||
static dev_t pipedev_ino;
|
||||
|
||||
#ifndef __rtems__
|
||||
SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_ANY, pipeinit, NULL);
|
||||
#else /* __rtems__ */
|
||||
SYSINIT(vfspip, SI_SUB_VFS, SI_ORDER_ANY, pipeinit, NULL);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void
|
||||
pipeinit(void *dummy __unused)
|
||||
@ -329,11 +289,7 @@ pipe_zone_ctor(void *mem, int size, void *arg, int flags)
|
||||
*/
|
||||
rpipe = &pp->pp_rpipe;
|
||||
bzero(rpipe, sizeof(*rpipe));
|
||||
#ifndef __rtems__
|
||||
vfs_timestamp(&rpipe->pipe_ctime);
|
||||
#else /* __rtems__ */
|
||||
rpipe->pipe_ctime.tv_sec = time(NULL);
|
||||
#endif /* __rtems__ */
|
||||
rpipe->pipe_atime = rpipe->pipe_mtime = rpipe->pipe_ctime;
|
||||
|
||||
wpipe = &pp->pp_wpipe;
|
||||
@ -484,22 +440,16 @@ kern_pipe(struct thread *td, int fildes[2], int flags, struct filecaps *fcaps1,
|
||||
error = falloc_caps(td, &wf, &fd, flags, fcaps2);
|
||||
if (error) {
|
||||
fdclose(td, rf, fildes[0]);
|
||||
#ifndef __rtems__
|
||||
fdrop(rf, td);
|
||||
#endif /* __rtems__ */
|
||||
/* rpipe has been closed by fdrop(). */
|
||||
pipeclose(wpipe);
|
||||
return (error);
|
||||
}
|
||||
/* An extra reference on `wf' has been held for us by falloc_caps(). */
|
||||
finit(wf, fflags, DTYPE_PIPE, wpipe, &pipeops);
|
||||
#ifndef __rtems__
|
||||
fdrop(wf, td);
|
||||
#endif /* __rtems__ */
|
||||
fildes[1] = fd;
|
||||
#ifndef __rtems__
|
||||
fdrop(rf, td);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -523,7 +473,6 @@ freebsd10_pipe(struct thread *td, struct freebsd10_pipe_args *uap __unused)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
sys_pipe2(struct thread *td, struct pipe2_args *uap)
|
||||
{
|
||||
@ -541,28 +490,7 @@ sys_pipe2(struct thread *td, struct pipe2_args *uap)
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
int
|
||||
pipe(int fildes[2])
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = kern_pipe(td, fildes, 0, NULL, NULL);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return error;
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Allocate kva for pipe circular buffer, the space is pageable
|
||||
@ -852,11 +780,7 @@ pipe_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
* Handle non-blocking mode operation or
|
||||
* wait for more data.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if (fp->f_flag & FNONBLOCK) {
|
||||
#else /* __rtems__ */
|
||||
if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FNONBLOCK) {
|
||||
#endif /* __rtems__ */
|
||||
error = EAGAIN;
|
||||
} else {
|
||||
rpipe->pipe_state |= PIPE_WANTR;
|
||||
@ -876,11 +800,7 @@ locked_error:
|
||||
|
||||
/* XXX: should probably do this before getting any locks. */
|
||||
if (error == 0)
|
||||
#ifndef __rtems__
|
||||
vfs_timestamp(&rpipe->pipe_atime);
|
||||
#else /* __rtems__ */
|
||||
rpipe->pipe_atime.tv_sec = time(NULL);
|
||||
#endif /* __rtems__ */
|
||||
unlocked_error:
|
||||
--rpipe->pipe_busy;
|
||||
|
||||
@ -906,70 +826,6 @@ unlocked_error:
|
||||
PIPE_UNLOCK(rpipe);
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static ssize_t
|
||||
rtems_bsd_pipe_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct iovec iov = {
|
||||
.iov_base = buffer,
|
||||
.iov_len = count
|
||||
};
|
||||
struct uio auio = {
|
||||
.uio_iov = &iov,
|
||||
.uio_iovcnt = 1,
|
||||
.uio_offset = 0,
|
||||
.uio_resid = count,
|
||||
.uio_segflg = UIO_USERSPACE,
|
||||
.uio_rw = UIO_READ,
|
||||
.uio_td = td
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = pipe_read(fp, &auio, NULL, 0, NULL);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return (count - auio.uio_resid);
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
rtems_bsd_pipe_readv(rtems_libio_t *iop, const struct iovec *iov,
|
||||
int iovcnt, ssize_t total)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct uio auio = {
|
||||
.uio_iov = __DECONST(struct iovec *, iov),
|
||||
.uio_iovcnt = iovcnt,
|
||||
.uio_offset = 0,
|
||||
.uio_resid = total,
|
||||
.uio_segflg = UIO_USERSPACE,
|
||||
.uio_rw = UIO_READ,
|
||||
.uio_td = td
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = pipe_read(fp, &auio, NULL, 0, NULL);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return (total - auio.uio_resid);
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef PIPE_NODIRECT
|
||||
/*
|
||||
@ -1388,11 +1244,7 @@ pipe_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
/*
|
||||
* don't block on non-blocking I/O
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if (fp->f_flag & FNONBLOCK) {
|
||||
#else /* __rtems__ */
|
||||
if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FNONBLOCK) {
|
||||
#endif /* __rtems__ */
|
||||
error = EAGAIN;
|
||||
pipeunlock(wpipe);
|
||||
break;
|
||||
@ -1440,11 +1292,7 @@ pipe_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
error = 0;
|
||||
|
||||
if (error == 0)
|
||||
#ifndef __rtems__
|
||||
vfs_timestamp(&wpipe->pipe_mtime);
|
||||
#else /* __rtems__ */
|
||||
wpipe->pipe_mtime.tv_sec = time(NULL);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* We have something to offer,
|
||||
@ -1457,73 +1305,8 @@ pipe_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
PIPE_UNLOCK(rpipe);
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static ssize_t
|
||||
rtems_bsd_pipe_write(rtems_libio_t *iop, const void *buffer, size_t count)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct iovec iov = {
|
||||
.iov_base = __DECONST(void *, buffer),
|
||||
.iov_len = count
|
||||
};
|
||||
struct uio auio = {
|
||||
.uio_iov = &iov,
|
||||
.uio_iovcnt = 1,
|
||||
.uio_offset = 0,
|
||||
.uio_resid = count,
|
||||
.uio_segflg = UIO_USERSPACE,
|
||||
.uio_rw = UIO_WRITE,
|
||||
.uio_td = td
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = pipe_write(fp, &auio, NULL, 0, NULL);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return (count - auio.uio_resid);
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
rtems_bsd_pipe_writev(rtems_libio_t *iop, const struct iovec *iov,
|
||||
int iovcnt, ssize_t total)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct uio auio = {
|
||||
.uio_iov = __DECONST(struct iovec *, iov),
|
||||
.uio_iovcnt = iovcnt,
|
||||
.uio_offset = 0,
|
||||
.uio_resid = total,
|
||||
.uio_segflg = UIO_USERSPACE,
|
||||
.uio_rw = UIO_WRITE,
|
||||
.uio_td = td
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = pipe_write(fp, &auio, NULL, 0, NULL);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return (total - auio.uio_resid);
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* ARGSUSED */
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
pipe_truncate(struct file *fp, off_t length, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
@ -1538,7 +1321,6 @@ pipe_truncate(struct file *fp, off_t length, struct ucred *active_cred,
|
||||
error = invfo_truncate(fp, length, active_cred, td);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* we implement a very minimal set of ioctls for compatibility with sockets.
|
||||
@ -1575,11 +1357,7 @@ pipe_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
|
||||
break;
|
||||
|
||||
case FIONREAD:
|
||||
#ifndef __rtems__
|
||||
if (!(fp->f_flag & FREAD)) {
|
||||
#else /* __rtems__ */
|
||||
if (!(rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD)) {
|
||||
#endif /* __rtems__ */
|
||||
*(int *)data = 0;
|
||||
PIPE_UNLOCK(mpipe);
|
||||
return (0);
|
||||
@ -1618,23 +1396,6 @@ pipe_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
|
||||
out_unlocked:
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_pipe_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = pipe_ioctl(fp, request, buffer, NULL, td);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int
|
||||
pipe_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
@ -1656,19 +1417,11 @@ pipe_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
if (error)
|
||||
goto locked_error;
|
||||
#endif
|
||||
#ifndef __rtems__
|
||||
if (fp->f_flag & FREAD && events & (POLLIN | POLLRDNORM))
|
||||
#else /* __rtems__ */
|
||||
if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD && events & (POLLIN | POLLRDNORM))
|
||||
#endif /* __rtems__ */
|
||||
if (rpipe->pipe_map.cnt > 0 || rpipe->pipe_buffer.cnt > 0)
|
||||
revents |= events & (POLLIN | POLLRDNORM);
|
||||
|
||||
#ifndef __rtems__
|
||||
if (fp->f_flag & FWRITE && events & (POLLOUT | POLLWRNORM))
|
||||
#else /* __rtems__ */
|
||||
if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FWRITE && events & (POLLOUT | POLLWRNORM))
|
||||
#endif /* __rtems__ */
|
||||
if (wpipe->pipe_present != PIPE_ACTIVE ||
|
||||
(wpipe->pipe_state & PIPE_EOF) ||
|
||||
((wpipe->pipe_state & PIPE_DIRECTW) == 0 &&
|
||||
@ -1678,12 +1431,8 @@ pipe_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
|
||||
levents = events &
|
||||
(POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND);
|
||||
#ifndef __rtems__
|
||||
if (rpipe->pipe_state & PIPE_NAMED && fp->f_flag & FREAD && levents &&
|
||||
fp->f_pipegen == rpipe->pipe_wgen)
|
||||
#else /* __rtems__ */
|
||||
if (rpipe->pipe_state & PIPE_NAMED && rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD && levents)
|
||||
#endif /* __rtems__ */
|
||||
events |= POLLINIGNEOF;
|
||||
|
||||
if ((events & POLLINIGNEOF) == 0) {
|
||||
@ -1696,21 +1445,13 @@ pipe_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
}
|
||||
|
||||
if (revents == 0) {
|
||||
#ifndef __rtems__
|
||||
if (fp->f_flag & FREAD && events & (POLLIN | POLLRDNORM)) {
|
||||
#else /* __rtems__ */
|
||||
if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD && events & (POLLIN | POLLRDNORM)) {
|
||||
#endif /* __rtems__ */
|
||||
selrecord(td, &rpipe->pipe_sel);
|
||||
if (SEL_WAITING(&rpipe->pipe_sel))
|
||||
rpipe->pipe_state |= PIPE_SEL;
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
if (fp->f_flag & FWRITE && events & (POLLOUT | POLLWRNORM)) {
|
||||
#else /* __rtems__ */
|
||||
if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FWRITE && events & (POLLOUT | POLLWRNORM)) {
|
||||
#endif /* __rtems__ */
|
||||
selrecord(td, &wpipe->pipe_sel);
|
||||
if (SEL_WAITING(&wpipe->pipe_sel))
|
||||
wpipe->pipe_state |= PIPE_SEL;
|
||||
@ -1723,46 +1464,21 @@ locked_error:
|
||||
|
||||
return (revents);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_pipe_poll(rtems_libio_t *iop, int events)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = pipe_poll(fp, events, NULL, td);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* We shouldn't need locks here as we're doing a read and this should
|
||||
* be a natural race.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
struct pipe *pipe;
|
||||
#else /* __rtems__ */
|
||||
static int
|
||||
pipe_stat(struct pipe *pipe, struct stat *ub)
|
||||
{
|
||||
#endif /* __rtems__ */
|
||||
#ifdef MAC
|
||||
int error;
|
||||
#endif
|
||||
|
||||
#ifndef __rtems__
|
||||
pipe = fp->f_data;
|
||||
#endif /* __rtems__ */
|
||||
PIPE_LOCK(pipe);
|
||||
#ifdef MAC
|
||||
error = mac_pipe_check_stat(active_cred, pipe->pipe_pair);
|
||||
@ -1775,18 +1491,12 @@ pipe_stat(struct pipe *pipe, struct stat *ub)
|
||||
/* For named pipes ask the underlying filesystem. */
|
||||
if (pipe->pipe_state & PIPE_NAMED) {
|
||||
PIPE_UNLOCK(pipe);
|
||||
#ifndef __rtems__
|
||||
return (vnops.fo_stat(fp, ub, active_cred, td));
|
||||
#else /* __rtems__ */
|
||||
return (ENXIO);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
PIPE_UNLOCK(pipe);
|
||||
|
||||
#ifndef __rtems__
|
||||
bzero(ub, sizeof(*ub));
|
||||
#endif /* __rtems__ */
|
||||
ub->st_mode = S_IFIFO;
|
||||
ub->st_blksize = PAGE_SIZE;
|
||||
if (pipe->pipe_map.cnt != 0)
|
||||
@ -1813,38 +1523,20 @@ pipe_stat(struct pipe *pipe, struct stat *ub)
|
||||
*/
|
||||
return (0);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_pipe_stat(
|
||||
const rtems_filesystem_location_info_t *loc,
|
||||
struct stat *buf
|
||||
)
|
||||
{
|
||||
struct pipe *pipe = rtems_bsd_loc_to_f_data(loc);
|
||||
int error = pipe_stat(pipe, buf);
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
pipe_close(struct file *fp, struct thread *td)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
if (fp->f_vnode != NULL)
|
||||
return vnops.fo_close(fp, td);
|
||||
fp->f_ops = &badfileops;
|
||||
#else /* __rtems__ */
|
||||
fp->f_io.pathinfo.handlers = &rtems_filesystem_handlers_default;
|
||||
#endif /* __rtems__ */
|
||||
pipe_dtor(fp->f_data);
|
||||
fp->f_data = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
pipe_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
|
||||
{
|
||||
@ -1888,7 +1580,6 @@ pipe_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
|
||||
kif->kf_un.kf_pipe.kf_pipe_buffer_cnt = pi->pipe_buffer.cnt;
|
||||
return (0);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void
|
||||
pipe_free_kmem(struct pipe *cpipe)
|
||||
@ -2007,19 +1698,11 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
|
||||
* descriptor, don't return an error, but also don't ever generate an
|
||||
* event.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if ((kn->kn_filter == EVFILT_READ) && !(fp->f_flag & FREAD)) {
|
||||
#else /* __rtems__ */
|
||||
if ((kn->kn_filter == EVFILT_READ) && !(rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD)) {
|
||||
#endif /* __rtems__ */
|
||||
kn->kn_fop = &pipe_nfiltops;
|
||||
return (0);
|
||||
}
|
||||
#ifndef __rtems__
|
||||
if ((kn->kn_filter == EVFILT_WRITE) && !(fp->f_flag & FWRITE)) {
|
||||
#else /* __rtems__ */
|
||||
if ((kn->kn_filter == EVFILT_WRITE) && !(rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FWRITE)) {
|
||||
#endif /* __rtems__ */
|
||||
kn->kn_fop = &pipe_nfiltops;
|
||||
return (0);
|
||||
}
|
||||
@ -2048,15 +1731,6 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
|
||||
PIPE_UNLOCK(cpipe);
|
||||
return (0);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
rtems_bsd_pipe_kqfilter(rtems_libio_t *iop, struct knote *kn)
|
||||
{
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
|
||||
return pipe_kqfilter(fp, kn);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void
|
||||
filt_pipedetach(struct knote *kn)
|
||||
@ -2129,35 +1803,3 @@ filt_pipenotsup(struct knote *kn, long hint)
|
||||
|
||||
return (0);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_pipe_open(rtems_libio_t *iop, const char *path, int oflag,
|
||||
mode_t mode)
|
||||
{
|
||||
return rtems_bsd_error_to_status_and_errno(ENXIO);
|
||||
}
|
||||
|
||||
static int
|
||||
rtems_bsd_pipe_close(rtems_libio_t *iop)
|
||||
{
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int error = pipe_close(fp, NULL);
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
static int
|
||||
rtems_bsd_pipe_fcntl(rtems_libio_t *iop, int cmd)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
if (cmd == F_SETFL) {
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int nbio = iop->flags & LIBIO_FLAGS_NO_DELAY;
|
||||
|
||||
error = pipe_ioctl(fp, FIONBIO, &nbio, NULL, NULL);
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <vm/pmap.h>
|
||||
#include <vm/vm_extern.h>
|
||||
#include <vm/vm_map.h>
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static SYSCTL_NODE(_kern_ipc, OID_AUTO, aio, CTLFLAG_RD, NULL,
|
||||
"socket AIO stats");
|
||||
@ -119,13 +120,8 @@ struct fileops socketops = {
|
||||
.fo_aio_queue = soo_aio_queue,
|
||||
.fo_flags = DFLAG_PASSABLE
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
int
|
||||
#else /* __rtems__ */
|
||||
static int
|
||||
#endif /* __rtems__ */
|
||||
soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
int flags, struct thread *td)
|
||||
{
|
||||
@ -140,76 +136,8 @@ soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
error = soreceive(so, 0, uio, 0, 0, 0);
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static ssize_t
|
||||
rtems_bsd_soo_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct iovec iov = {
|
||||
.iov_base = buffer,
|
||||
.iov_len = count
|
||||
};
|
||||
struct uio auio = {
|
||||
.uio_iov = &iov,
|
||||
.uio_iovcnt = 1,
|
||||
.uio_offset = 0,
|
||||
.uio_resid = count,
|
||||
.uio_segflg = UIO_USERSPACE,
|
||||
.uio_rw = UIO_READ,
|
||||
.uio_td = td
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = soo_read(fp, &auio, NULL, 0, NULL);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return (count - auio.uio_resid);
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
rtems_bsd_soo_readv(rtems_libio_t *iop, const struct iovec *iov,
|
||||
int iovcnt, ssize_t total)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct uio auio = {
|
||||
.uio_iov = __DECONST(struct iovec *, iov),
|
||||
.uio_iovcnt = iovcnt,
|
||||
.uio_offset = 0,
|
||||
.uio_resid = total,
|
||||
.uio_segflg = UIO_USERSPACE,
|
||||
.uio_rw = UIO_READ,
|
||||
.uio_td = td
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = soo_read(fp, &auio, NULL, 0, NULL);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return (total - auio.uio_resid);
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
int
|
||||
#else /* __rtems__ */
|
||||
static int
|
||||
#endif /* __rtems__ */
|
||||
soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
int flags, struct thread *td)
|
||||
{
|
||||
@ -233,76 +161,8 @@ soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static ssize_t
|
||||
rtems_bsd_soo_write(rtems_libio_t *iop, const void *buffer, size_t count)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct iovec iov = {
|
||||
.iov_base = __DECONST(void *, buffer),
|
||||
.iov_len = count
|
||||
};
|
||||
struct uio auio = {
|
||||
.uio_iov = &iov,
|
||||
.uio_iovcnt = 1,
|
||||
.uio_offset = 0,
|
||||
.uio_resid = count,
|
||||
.uio_segflg = UIO_USERSPACE,
|
||||
.uio_rw = UIO_WRITE,
|
||||
.uio_td = td
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = soo_write(fp, &auio, NULL, 0, NULL);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return (count - auio.uio_resid);
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
rtems_bsd_soo_writev(rtems_libio_t *iop, const struct iovec *iov,
|
||||
int iovcnt, ssize_t total)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct uio auio = {
|
||||
.uio_iov = __DECONST(struct iovec *, iov),
|
||||
.uio_iovcnt = iovcnt,
|
||||
.uio_offset = 0,
|
||||
.uio_resid = total,
|
||||
.uio_segflg = UIO_USERSPACE,
|
||||
.uio_rw = UIO_WRITE,
|
||||
.uio_td = td
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = soo_write(fp, &auio, NULL, 0, NULL);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return (total - auio.uio_resid);
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
int
|
||||
#else /* __rtems__ */
|
||||
static int
|
||||
#endif /* __rtems__ */
|
||||
soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
@ -414,29 +274,8 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
|
||||
static int
|
||||
rtems_bsd_soo_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = soo_ioctl(fp, request, buffer, NULL, td);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
int
|
||||
#else /* __rtems__ */
|
||||
static int
|
||||
#endif /* __rtems__ */
|
||||
soo_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
@ -448,48 +287,19 @@ soo_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
if (error)
|
||||
return (error);
|
||||
#endif
|
||||
#ifndef __rtems__
|
||||
return (sopoll(so, events, fp->f_cred, td));
|
||||
#else /* __rtems__ */
|
||||
return (sopoll(so, events, NULL, td));
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_soo_poll(rtems_libio_t *iop, int events)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = soo_poll(fp, events, NULL, td);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
struct socket *so = fp->f_data;
|
||||
#else /* __rtems__ */
|
||||
static int
|
||||
soo_stat(struct socket *so, struct stat *ub)
|
||||
{
|
||||
#endif /* __rtems__ */
|
||||
#ifdef MAC
|
||||
int error;
|
||||
#endif
|
||||
|
||||
#ifndef __rtems__
|
||||
bzero((caddr_t)ub, sizeof (*ub));
|
||||
#endif /* __rtems__ */
|
||||
ub->st_mode = S_IFSOCK;
|
||||
#ifdef MAC
|
||||
error = mac_socket_check_stat(active_cred, so);
|
||||
@ -525,19 +335,6 @@ soo_stat(struct socket *so, struct stat *ub)
|
||||
#endif /* __rtems__ */
|
||||
return (*so->so_proto->pr_usrreqs->pru_sense)(so, ub);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_soo_stat(
|
||||
const rtems_filesystem_location_info_t *loc,
|
||||
struct stat *buf
|
||||
)
|
||||
{
|
||||
struct socket *so = rtems_bsd_loc_to_f_data(loc);
|
||||
int error = soo_stat(so, buf);
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* API socket close on file pointer. We call soclose() to close the socket
|
||||
@ -545,27 +342,15 @@ rtems_bsd_soo_stat(
|
||||
* file reference but the actual socket will not go away until the socket's
|
||||
* ref count hits 0.
|
||||
*/
|
||||
#ifdef __rtems__
|
||||
int
|
||||
#else /* __rtems__ */
|
||||
static int
|
||||
#endif /* __rtems__ */
|
||||
soo_close(struct file *fp, struct thread *td)
|
||||
{
|
||||
int error = 0;
|
||||
struct socket *so;
|
||||
|
||||
#ifdef __rtems__
|
||||
/* FIXME: Move this to the RTEMS close() function */
|
||||
knote_fdclose(td, rtems_bsd_fp_to_fd(fp));
|
||||
#endif /* __rtems__ */
|
||||
|
||||
so = fp->f_data;
|
||||
#ifndef __rtems__
|
||||
fp->f_ops = &badfileops;
|
||||
#else /* __rtems__ */
|
||||
fp->f_io.pathinfo.handlers = &rtems_filesystem_handlers_default;
|
||||
#endif /* __rtems__ */
|
||||
fp->f_data = NULL;
|
||||
|
||||
if (so)
|
||||
@ -573,7 +358,6 @@ soo_close(struct file *fp, struct thread *td)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
|
||||
{
|
||||
@ -642,6 +426,7 @@ soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Use the 'backend3' field in AIO jobs to store the amount of data
|
||||
* completed by the AIO job so far.
|
||||
@ -1014,10 +799,12 @@ soo_aio_cancel(struct kaiocb *job)
|
||||
else
|
||||
aio_cancel(job);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int
|
||||
soo_aio_queue(struct file *fp, struct kaiocb *job)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct socket *so;
|
||||
struct sockbuf *sb;
|
||||
int error;
|
||||
@ -1050,56 +837,7 @@ soo_aio_queue(struct file *fp, struct kaiocb *job)
|
||||
}
|
||||
SOCKBUF_UNLOCK(sb);
|
||||
return (0);
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
return (EIO);
|
||||
#endif /* __rtems__ */
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_soo_open(rtems_libio_t *iop, const char *path, int oflag,
|
||||
mode_t mode)
|
||||
{
|
||||
return rtems_bsd_error_to_status_and_errno(ENXIO);
|
||||
}
|
||||
|
||||
static int
|
||||
rtems_bsd_soo_close(rtems_libio_t *iop)
|
||||
{
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int error = soo_close(fp, NULL);
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
static int
|
||||
rtems_bsd_soo_fcntl(rtems_libio_t *iop, int cmd)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
if (cmd == F_SETFL) {
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
int nbio = iop->flags & LIBIO_FLAGS_NO_DELAY;
|
||||
|
||||
error = soo_ioctl(fp, FIONBIO, &nbio, NULL, NULL);
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
const rtems_filesystem_file_handlers_r socketops = {
|
||||
.open_h = rtems_bsd_soo_open,
|
||||
.close_h = rtems_bsd_soo_close,
|
||||
.read_h = rtems_bsd_soo_read,
|
||||
.write_h = rtems_bsd_soo_write,
|
||||
.ioctl_h = rtems_bsd_soo_ioctl,
|
||||
.lseek_h = rtems_filesystem_default_lseek,
|
||||
.fstat_h = rtems_bsd_soo_stat,
|
||||
.ftruncate_h = rtems_filesystem_default_ftruncate,
|
||||
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
|
||||
.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
|
||||
.fcntl_h = rtems_bsd_soo_fcntl,
|
||||
.poll_h = rtems_bsd_soo_poll,
|
||||
.kqfilter_h = rtems_bsd_soo_kqfilter,
|
||||
.readv_h = rtems_bsd_soo_readv,
|
||||
.writev_h = rtems_bsd_soo_writev,
|
||||
.mmap_h = rtems_filesystem_default_mmap
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
|
@ -155,10 +155,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/sysent.h>
|
||||
#include <compat/freebsd32/freebsd32.h>
|
||||
#endif
|
||||
#ifdef __rtems__
|
||||
#include <rtems/libio.h>
|
||||
#define maxfiles rtems_libio_number_iops
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int soreceive_rcvoob(struct socket *so, struct uio *uio,
|
||||
int flags);
|
||||
@ -177,9 +173,6 @@ static void filt_sowdetach(struct knote *kn);
|
||||
static int filt_sowrite(struct knote *kn, long hint);
|
||||
static int filt_soempty(struct knote *kn, long hint);
|
||||
static int inline hhook_run_socket(struct socket *so, void *hctx, int32_t h_id);
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
fo_kqfilter_t soo_kqfilter;
|
||||
|
||||
static struct filterops soread_filtops = {
|
||||
@ -3427,15 +3420,6 @@ soo_kqfilter(struct file *fp, struct knote *kn)
|
||||
SOCK_UNLOCK(so);
|
||||
return (0);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
rtems_bsd_soo_kqfilter(rtems_libio_t *iop, struct knote *kn)
|
||||
{
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
|
||||
return soo_kqfilter(fp, kn);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Some routines that return EOPNOTSUPP for entry points that are not
|
||||
|
@ -78,9 +78,9 @@ __FBSDID("$FreeBSD$");
|
||||
static int sendit(struct thread *td, int s, struct msghdr *mp, int flags);
|
||||
static int recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp);
|
||||
|
||||
#ifndef __rtems__
|
||||
static int accept1(struct thread *td, int s, struct sockaddr *uname,
|
||||
socklen_t *anamelen, int flags);
|
||||
#ifndef __rtems__
|
||||
static int getsockname1(struct thread *td, struct getsockname_args *uap,
|
||||
int compat);
|
||||
static int getpeername1(struct thread *td, struct getpeername_args *uap,
|
||||
@ -90,20 +90,29 @@ struct getsockaddr_sockaddr {
|
||||
struct sockaddr header;
|
||||
char data[SOCK_MAXADDRLEN - sizeof(struct sockaddr)];
|
||||
} __aligned(sizeof(long));
|
||||
/*
|
||||
* The getsockaddr is used else where with an allocation. Having a version
|
||||
* local that does not alloc is a nice optimisation but we need to maintain
|
||||
* the exported version. See nfs_mount in nfs_clvfsops.c.
|
||||
*/
|
||||
static int
|
||||
getsockaddr_noalloc(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)
|
||||
{
|
||||
struct sockaddr *sa;
|
||||
|
||||
static int getsockaddr(struct sockaddr **, const struct sockaddr *, size_t);
|
||||
static int kern_getsockname(struct thread *, int, struct sockaddr **,
|
||||
socklen_t *);
|
||||
static int kern_listen(struct thread *, int, int);
|
||||
static int kern_setsockopt(struct thread *, int, int, int, const void *,
|
||||
enum uio_seg, socklen_t);
|
||||
static int kern_shutdown(struct thread *, int, int);
|
||||
static int kern_socket(struct thread *, int, int, int);
|
||||
static int kern_socketpair(struct thread *, int, int, int, int *);
|
||||
if (len > SOCK_MAXADDRLEN)
|
||||
return (ENAMETOOLONG);
|
||||
if (len < offsetof(struct sockaddr, sa_data[0]))
|
||||
return (EINVAL);
|
||||
sa = memcpy(*namp, uaddr, len);
|
||||
sa->sa_len = len;
|
||||
return (0);
|
||||
}
|
||||
#define getsockaddr_hold getsockadd
|
||||
#define getsockaddr getsockaddr_noalloc
|
||||
#endif /* __rtems__ */
|
||||
static int sockargs(struct mbuf **, char *, socklen_t, int);
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Convert a user file descriptor to a kernel file entry and check if required
|
||||
* capability rights are present.
|
||||
@ -131,46 +140,6 @@ getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp,
|
||||
*fpp = fp;
|
||||
return (0);
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
static int
|
||||
rtems_bsd_getsock(int fd, struct file **fpp, u_int *fflagp)
|
||||
{
|
||||
struct file *fp;
|
||||
int error;
|
||||
|
||||
if ((uint32_t) fd < rtems_libio_number_iops) {
|
||||
unsigned int flags;
|
||||
|
||||
fp = rtems_bsd_fd_to_fp(fd);
|
||||
flags = rtems_libio_iop_hold(&fp->f_io);
|
||||
if ((flags & LIBIO_FLAGS_OPEN) == 0) {
|
||||
rtems_libio_iop_drop(&fp->f_io);
|
||||
fp = NULL;
|
||||
error = EBADF;
|
||||
} else if (fp->f_io.pathinfo.handlers != &socketops) {
|
||||
rtems_libio_iop_drop(&fp->f_io);
|
||||
fp = NULL;
|
||||
error = ENOTSOCK;
|
||||
} else {
|
||||
if (fflagp != NULL) {
|
||||
*fflagp = rtems_bsd_libio_flags_to_fflag(
|
||||
fp->f_io.flags);
|
||||
}
|
||||
|
||||
error = 0;
|
||||
}
|
||||
} else {
|
||||
fp = NULL;
|
||||
error = EBADF;
|
||||
}
|
||||
|
||||
*fpp = fp;
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
#define getsock_cap(td, fd, rights, fpp, fflagp, havecapsp) rtems_bsd_getsock(fd, fpp, fflagp)
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* System call interface to the socket abstraction.
|
||||
@ -179,9 +148,6 @@ rtems_bsd_getsock(int fd, struct file **fpp, u_int *fflagp)
|
||||
#define COMPAT_OLDSOCK
|
||||
#endif
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_socket(struct thread *td, struct socket_args *uap)
|
||||
{
|
||||
@ -227,43 +193,10 @@ kern_socket(struct thread *td, int domain, int type, int protocol)
|
||||
(void) fo_ioctl(fp, FIONBIO, &fflag, td->td_ucred, td);
|
||||
td->td_retval[0] = fd;
|
||||
}
|
||||
#ifndef __rtems__
|
||||
fdrop(fp, td);
|
||||
#endif /* __rtems__ */
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
socket(int domain, int type, int protocol)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct socket_args ua = {
|
||||
.domain = domain,
|
||||
.type = type,
|
||||
.protocol = protocol
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_socket(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static int kern_bindat(struct thread *td, int dirfd, int fd,
|
||||
struct sockaddr *sa);
|
||||
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_bind(struct thread *td, struct bind_args *uap)
|
||||
{
|
||||
@ -283,27 +216,6 @@ sys_bind(struct thread *td, struct bind_args *uap)
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
bind(int socket, const struct sockaddr *address, socklen_t address_len)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct bind_args ua = {
|
||||
.s = socket,
|
||||
.name = address,
|
||||
.namelen = address_len
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_bind(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
|
||||
@ -366,9 +278,6 @@ sys_bindat(struct thread *td, struct bindat_args *uap)
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_listen(struct thread *td, struct listen_args *uap)
|
||||
{
|
||||
@ -397,31 +306,7 @@ kern_listen(struct thread *td, int s, int backlog)
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
listen(int socket, int backlog)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct listen_args ua = {
|
||||
.s = socket,
|
||||
.backlog = backlog
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_listen(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static int kern_accept4(struct thread *td, int s, struct sockaddr **name,
|
||||
socklen_t *namelen, int flags, struct file **fp);
|
||||
#endif /* __rtems__ */
|
||||
/*
|
||||
* accept1()
|
||||
*/
|
||||
@ -464,43 +349,17 @@ accept1(td, s, uname, anamelen, flags)
|
||||
sizeof(namelen));
|
||||
if (error != 0)
|
||||
fdclose(td, fp, td->td_retval[0]);
|
||||
#ifndef __rtems__
|
||||
fdrop(fp, td);
|
||||
#endif /* __rtems__ */
|
||||
free(name, M_SONAME);
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
accept(int socket, struct sockaddr *__restrict address,
|
||||
socklen_t *__restrict address_len)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = accept1(td, socket, address, address_len,
|
||||
ACCEPT4_INHERIT);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
kern_accept(struct thread *td, int s, struct sockaddr **name,
|
||||
socklen_t *namelen, struct file **fp)
|
||||
{
|
||||
return (kern_accept4(td, s, name, namelen, ACCEPT4_INHERIT, fp));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
kern_accept4(struct thread *td, int s, struct sockaddr **name,
|
||||
@ -613,15 +472,12 @@ done:
|
||||
} else
|
||||
*fp = NULL;
|
||||
}
|
||||
#ifndef __rtems__
|
||||
if (nfp != NULL)
|
||||
fdrop(nfp, td);
|
||||
#endif /* __rtems__ */
|
||||
fdrop(headfp, td);
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
sys_accept(td, uap)
|
||||
struct thread *td;
|
||||
@ -654,14 +510,7 @@ oaccept(td, uap)
|
||||
ACCEPT4_INHERIT | ACCEPT4_COMPAT));
|
||||
}
|
||||
#endif /* COMPAT_OLDSOCK */
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static int kern_connectat(struct thread *td, int dirfd, int fd,
|
||||
struct sockaddr *sa);
|
||||
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_connect(struct thread *td, struct connect_args *uap)
|
||||
{
|
||||
@ -681,27 +530,6 @@ sys_connect(struct thread *td, struct connect_args *uap)
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
connect(int socket, const struct sockaddr *address, socklen_t address_len)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct connect_args ua = {
|
||||
.s = socket,
|
||||
.name = address,
|
||||
.namelen = address_len
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_connect(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
|
||||
@ -864,21 +692,15 @@ kern_socketpair(struct thread *td, int domain, int type, int protocol,
|
||||
(void) fo_ioctl(fp1, FIONBIO, &fflag, td->td_ucred, td);
|
||||
(void) fo_ioctl(fp2, FIONBIO, &fflag, td->td_ucred, td);
|
||||
}
|
||||
#ifndef __rtems__
|
||||
fdrop(fp1, td);
|
||||
fdrop(fp2, td);
|
||||
#endif /* __rtems__ */
|
||||
return (0);
|
||||
free4:
|
||||
fdclose(td, fp2, rsv[1]);
|
||||
#ifndef __rtems__
|
||||
fdrop(fp2, td);
|
||||
#endif /* __rtems__ */
|
||||
free3:
|
||||
fdclose(td, fp1, rsv[0]);
|
||||
#ifndef __rtems__
|
||||
fdrop(fp1, td);
|
||||
#endif /* __rtems__ */
|
||||
free2:
|
||||
if (so2 != NULL)
|
||||
(void)soclose(so2);
|
||||
@ -888,9 +710,6 @@ free1:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_socketpair(struct thread *td, struct socketpair_args *uap)
|
||||
{
|
||||
@ -914,34 +733,7 @@ sys_socketpair(struct thread *td, struct socketpair_args *uap)
|
||||
#endif /* __rtems__ */
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
socketpair(int domain, int type, int protocol, int *socket_vector)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct socketpair_args ua = {
|
||||
.domain = domain,
|
||||
.type = type,
|
||||
.protocol = protocol,
|
||||
.rsv = socket_vector
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_socketpair(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
kern_sendit( struct thread *td, int s, struct msghdr *mp, int flags,
|
||||
struct mbuf *control, enum uio_seg segflg);
|
||||
#endif /* __rtems__ */
|
||||
static int
|
||||
sendit(struct thread *td, int s, struct msghdr *mp, int flags)
|
||||
{
|
||||
@ -1016,9 +808,7 @@ kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags,
|
||||
struct uio auio;
|
||||
struct iovec *iov;
|
||||
struct socket *so;
|
||||
#ifndef __rtems__
|
||||
cap_rights_t *rights;
|
||||
#endif /* __rtems__ */
|
||||
#ifdef KTRACE
|
||||
struct uio *ktruio = NULL;
|
||||
#endif
|
||||
@ -1033,6 +823,8 @@ kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags,
|
||||
AUDIT_ARG_SOCKADDR(td, AT_FDCWD, mp->msg_name);
|
||||
rights = &cap_send_connect_rights;
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
rights = NULL;
|
||||
#endif /* __rtems__ */
|
||||
error = getsock_cap(td, s, rights, &fp, NULL, NULL);
|
||||
if (error != 0) {
|
||||
@ -1111,9 +903,6 @@ bad:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_sendto(struct thread *td, struct sendto_args *uap)
|
||||
{
|
||||
@ -1138,34 +927,6 @@ sys_sendto(struct thread *td, struct sendto_args *uap)
|
||||
return (sendit(td, uap->s, &msg, uap->flags));
|
||||
}
|
||||
#ifdef __rtems__
|
||||
ssize_t
|
||||
sendto(int socket, const void *message, size_t length, int flags,
|
||||
const struct sockaddr *dest_addr, socklen_t dest_len)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct sendto_args ua = {
|
||||
.s = socket,
|
||||
.buf = (caddr_t) message,
|
||||
.len = length,
|
||||
.flags = flags,
|
||||
.to = dest_addr,
|
||||
.tolen = dest_len
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_sendto(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_sendto(int socket, struct mbuf *m, int flags,
|
||||
const struct sockaddr *dest_addr)
|
||||
@ -1175,7 +936,7 @@ rtems_bsd_sendto(int socket, struct mbuf *m, int flags,
|
||||
struct socket *so;
|
||||
int error;
|
||||
|
||||
error = getsock_cap(td->td_proc->p_fd, socket, CAP_WRITE, &fp, NULL, NULL);
|
||||
error = getsock_cap(td, socket, CAP_WRITE, &fp, NULL, NULL);
|
||||
if (error)
|
||||
return (error);
|
||||
so = (struct socket *)fp->f_data;
|
||||
@ -1232,9 +993,6 @@ osendmsg(struct thread *td, struct osendmsg_args *uap)
|
||||
#endif
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_sendmsg(struct thread *td, struct sendmsg_args *uap)
|
||||
{
|
||||
@ -1257,35 +1015,7 @@ sys_sendmsg(struct thread *td, struct sendmsg_args *uap)
|
||||
free(iov, M_IOV);
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
ssize_t
|
||||
sendmsg(int socket, const struct msghdr *message, int flags)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct sendmsg_args ua = {
|
||||
.s = socket,
|
||||
.msg = message,
|
||||
.flags = flags
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_sendmsg(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
kern_recvit(struct thread *td, int s, struct msghdr *mp, enum uio_seg fromseg,
|
||||
struct mbuf **controlp)
|
||||
@ -1460,9 +1190,6 @@ recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_recvfrom(struct thread *td, struct recvfrom_args *uap)
|
||||
{
|
||||
@ -1489,35 +1216,6 @@ sys_recvfrom(struct thread *td, struct recvfrom_args *uap)
|
||||
done2:
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
ssize_t
|
||||
recvfrom(int socket, void *__restrict buffer, size_t length, int flags,
|
||||
struct sockaddr *__restrict address, socklen_t *__restrict address_len)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct recvfrom_args ua = {
|
||||
.s = socket,
|
||||
.buf = buffer,
|
||||
.len = length,
|
||||
.flags = flags,
|
||||
.from = address,
|
||||
.fromlenaddr = address_len
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_recvfrom(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
#ifdef COMPAT_OLDSOCK
|
||||
@ -1578,9 +1276,6 @@ orecvmsg(struct thread *td, struct orecvmsg_args *uap)
|
||||
#endif
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_recvmsg(struct thread *td, struct recvmsg_args *uap)
|
||||
{
|
||||
@ -1609,35 +1304,7 @@ sys_recvmsg(struct thread *td, struct recvmsg_args *uap)
|
||||
free(iov, M_IOV);
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
ssize_t
|
||||
recvmsg(int socket, struct msghdr *message, int flags)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct recvmsg_args ua = {
|
||||
.s = socket,
|
||||
.msg = message,
|
||||
.flags = flags
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_recvmsg(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
return td->td_retval[0];
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_shutdown(struct thread *td, struct shutdown_args *uap)
|
||||
{
|
||||
@ -1673,23 +1340,7 @@ kern_shutdown(struct thread *td, int s, int how)
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
shutdown(int socket, int how)
|
||||
{
|
||||
struct shutdown_args ua = {
|
||||
.s = socket,
|
||||
.how = how
|
||||
};
|
||||
int error = sys_shutdown(NULL, &ua);
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_setsockopt(struct thread *td, struct setsockopt_args *uap)
|
||||
{
|
||||
@ -1697,39 +1348,10 @@ sys_setsockopt(struct thread *td, struct setsockopt_args *uap)
|
||||
return (kern_setsockopt(td, uap->s, uap->level, uap->name,
|
||||
uap->val, UIO_USERSPACE, uap->valsize));
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
setsockopt(int socket, int level, int option_name, const void *option_value,
|
||||
socklen_t option_len)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct setsockopt_args ua = {
|
||||
.s = socket,
|
||||
.level = level,
|
||||
.name = option_name,
|
||||
.val = __DECONST(void *, option_value),
|
||||
.valsize = option_len
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_setsockopt(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
#ifndef __rtems__
|
||||
kern_setsockopt(struct thread *td, int s, int level, int name, void *val,
|
||||
enum uio_seg valseg, socklen_t valsize)
|
||||
#else /* __rtems__ */
|
||||
kern_setsockopt(struct thread *td, int s, int level, int name, const void *val,
|
||||
enum uio_seg valseg, socklen_t valsize)
|
||||
#endif /* __rtems__ */
|
||||
{
|
||||
struct socket *so;
|
||||
struct file *fp;
|
||||
@ -1744,11 +1366,7 @@ kern_setsockopt(struct thread *td, int s, int level, int name, const void *val,
|
||||
sopt.sopt_dir = SOPT_SET;
|
||||
sopt.sopt_level = level;
|
||||
sopt.sopt_name = name;
|
||||
#ifndef __rtems__
|
||||
sopt.sopt_val = val;
|
||||
#else /* __rtems__ */
|
||||
sopt.sopt_val = __DECONST(void *, val);
|
||||
#endif /* __rtems__ */
|
||||
sopt.sopt_valsize = valsize;
|
||||
switch (valseg) {
|
||||
case UIO_USERSPACE:
|
||||
@ -1772,12 +1390,6 @@ kern_setsockopt(struct thread *td, int s, int level, int name, const void *val,
|
||||
return(error);
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
static int kern_getsockopt( struct thread *td, int s, int level, int name,
|
||||
void *val, enum uio_seg valseg, socklen_t *valsize);
|
||||
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_getsockopt(struct thread *td, struct getsockopt_args *uap)
|
||||
{
|
||||
@ -1797,30 +1409,6 @@ sys_getsockopt(struct thread *td, struct getsockopt_args *uap)
|
||||
error = copyout(&valsize, uap->avalsize, sizeof (valsize));
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
getsockopt(int socket, int level, int option_name, void *__restrict
|
||||
option_value, socklen_t *__restrict option_len)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct getsockopt_args ua = {
|
||||
.s = socket,
|
||||
.level = level,
|
||||
.name = option_name,
|
||||
.val = (caddr_t) option_value,
|
||||
.avalsize = option_len
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = sys_getsockopt(td, &ua);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Kernel version of getsockopt.
|
||||
@ -1898,28 +1486,6 @@ getsockname1(struct thread *td, struct getsockname_args *uap, int compat)
|
||||
error = copyout(&len, uap->alen, sizeof(len));
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
getsockname(int socket, struct sockaddr *__restrict address,
|
||||
socklen_t *__restrict address_len)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct getsockname_args ua = {
|
||||
.fdes = socket,
|
||||
.asa = address,
|
||||
.alen = address_len
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = getsockname1(td, &ua, 0);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
kern_getsockname(struct thread *td, int fd, struct sockaddr **sa,
|
||||
@ -1960,7 +1526,6 @@ bad:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
sys_getsockname(struct thread *td, struct getsockname_args *uap)
|
||||
{
|
||||
@ -1976,13 +1541,7 @@ ogetsockname(struct thread *td, struct getsockname_args *uap)
|
||||
return (getsockname1(td, uap, 1));
|
||||
}
|
||||
#endif /* COMPAT_OLDSOCK */
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,
|
||||
socklen_t *alen);
|
||||
#endif /* __rtems__ */
|
||||
/*
|
||||
* getpeername1() - Get name of peer for connected socket.
|
||||
*/
|
||||
@ -2013,28 +1572,6 @@ getpeername1(struct thread *td, struct getpeername_args *uap, int compat)
|
||||
error = copyout(&len, uap->alen, sizeof(len));
|
||||
return (error);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
getpeername(int socket, struct sockaddr *__restrict address,
|
||||
socklen_t *__restrict address_len)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct getpeername_args ua = {
|
||||
.fdes = socket,
|
||||
.asa = address,
|
||||
.alen = address_len
|
||||
};
|
||||
int error;
|
||||
|
||||
if (td != NULL) {
|
||||
error = getpeername1(td, &ua, 0);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,
|
||||
@ -2080,7 +1617,6 @@ done:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
sys_getpeername(struct thread *td, struct getpeername_args *uap)
|
||||
{
|
||||
@ -2097,7 +1633,6 @@ ogetpeername(struct thread *td, struct ogetpeername_args *uap)
|
||||
return (getpeername1(td, (struct getpeername_args *)uap, 1));
|
||||
}
|
||||
#endif /* COMPAT_OLDSOCK */
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int
|
||||
sockargs(struct mbuf **mp, char *buf, socklen_t buflen, int type)
|
||||
@ -2137,23 +1672,22 @@ sockargs(struct mbuf **mp, char *buf, socklen_t buflen, int type)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
#undef getsockaddr
|
||||
int
|
||||
#ifndef __rtems__
|
||||
getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len)
|
||||
_bsd_getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len)
|
||||
#else /* __rtems__ */
|
||||
getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)
|
||||
int
|
||||
getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len)
|
||||
#endif /* __rtems__ */
|
||||
{
|
||||
struct sockaddr *sa;
|
||||
#ifndef __rtems__
|
||||
int error;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
if (len > SOCK_MAXADDRLEN)
|
||||
return (ENAMETOOLONG);
|
||||
if (len < offsetof(struct sockaddr, sa_data[0]))
|
||||
return (EINVAL);
|
||||
#ifndef __rtems__
|
||||
sa = malloc(len, M_SONAME, M_WAITOK);
|
||||
error = copyin(uaddr, sa, len);
|
||||
if (error != 0) {
|
||||
@ -2168,11 +1702,6 @@ getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)
|
||||
*namp = sa;
|
||||
}
|
||||
return (error);
|
||||
#else /* __rtems__ */
|
||||
sa = memcpy(*namp, uaddr, len);
|
||||
sa->sa_len = len;
|
||||
return (0);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -608,7 +608,8 @@ rtems_uipc_imfs_destroy(IMFS_jnode_t *node)
|
||||
}
|
||||
|
||||
static const IMFS_node_control rtems_uipc_imfs_control =
|
||||
IMFS_GENERIC_INITIALIZER(&socketops, rtems_uipc_imfs_initialize,
|
||||
IMFS_GENERIC_INITIALIZER(&rtems_bsd_sysgen_imfsnodeops,
|
||||
rtems_uipc_imfs_initialize,
|
||||
rtems_uipc_imfs_destroy);
|
||||
|
||||
static const IMFS_node_control rtems_uipc_imfs_zombi_control =
|
||||
@ -616,12 +617,13 @@ static const IMFS_node_control rtems_uipc_imfs_zombi_control =
|
||||
IMFS_node_destroy_default);
|
||||
|
||||
static void
|
||||
VOP_UNP_DETACH(IMFS_generic_t *vp)
|
||||
VOP_UNP_DETACH_rtems(IMFS_generic_t *vp)
|
||||
{
|
||||
|
||||
vp->Node.control = &rtems_uipc_imfs_zombi_control;
|
||||
vp->context = NULL;
|
||||
}
|
||||
#undef VOP_UNP_DETACH
|
||||
#define VOP_UNP_DETACH VOP_UNP_DETACH_rtems
|
||||
#endif /* __rtems__ */
|
||||
static int
|
||||
uipc_bindat(int fd, struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
@ -1725,7 +1727,7 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam,
|
||||
&ctx, &soun->sun_path[0], (size_t)len, eval_flags,
|
||||
&rtems_filesystem_root, &rtems_filesystem_current);
|
||||
|
||||
if (currentloc->handlers == &socketops) {
|
||||
if (currentloc->handlers == &rtems_bsd_sysgen_imfsnodeops) {
|
||||
vp = currentloc->node_access;
|
||||
} else {
|
||||
vp = NULL;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
@ -40,7 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/limits.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <rtems/bsd/sys/unistd.h>
|
||||
#include <sys/posix4.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resourcevar.h>
|
||||
@ -48,10 +50,14 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/syscallsubr.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/rwlock.h>
|
||||
#ifndef __rtems__
|
||||
#include <sys/sema.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#ifndef __rtems__
|
||||
#include <sys/syscall.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/syslog.h>
|
||||
@ -302,10 +308,15 @@ struct aiocb_ops {
|
||||
};
|
||||
|
||||
static TAILQ_HEAD(,aioproc) aio_freeproc; /* (c) Idle daemons */
|
||||
#ifndef __rtems__
|
||||
static struct sema aio_newproc_sem;
|
||||
#endif /* __rtems__ */
|
||||
static struct mtx aio_job_mtx;
|
||||
static TAILQ_HEAD(,kaiocb) aio_jobs; /* (c) Async job list */
|
||||
static struct unrhdr *aiod_unr;
|
||||
#ifdef __rtems__
|
||||
static struct kaioinfo *aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
void aio_init_aioinfo(struct proc *p);
|
||||
static int aio_onceonly(void);
|
||||
@ -407,7 +418,9 @@ aio_onceonly(void)
|
||||
kqueue_add_filteropts(EVFILT_AIO, &aio_filtops);
|
||||
kqueue_add_filteropts(EVFILT_LIO, &lio_filtops);
|
||||
TAILQ_INIT(&aio_freeproc);
|
||||
#ifndef __rtems__
|
||||
sema_init(&aio_newproc_sem, 0, "aio_new_proc");
|
||||
#endif /* __rtems__ */
|
||||
mtx_init(&aio_job_mtx, "aio_job", NULL, MTX_DEF);
|
||||
TAILQ_INIT(&aio_jobs);
|
||||
aiod_unr = new_unrhdr(1, INT_MAX, NULL);
|
||||
@ -451,6 +464,7 @@ aio_init_aioinfo(struct proc *p)
|
||||
TAILQ_INIT(&ki->kaio_syncready);
|
||||
TASK_INIT(&ki->kaio_task, 0, aio_kick_helper, p);
|
||||
TASK_INIT(&ki->kaio_sync_task, 0, aio_schedule_fsync, ki);
|
||||
#ifndef __rtems__
|
||||
PROC_LOCK(p);
|
||||
if (p->p_aioinfo == NULL) {
|
||||
p->p_aioinfo = ki;
|
||||
@ -460,14 +474,25 @@ aio_init_aioinfo(struct proc *p)
|
||||
mtx_destroy(&ki->kaio_mtx);
|
||||
uma_zfree(kaio_zone, ki);
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
if (aio_proc_p_aioinfo == NULL) {
|
||||
aio_proc_p_aioinfo = ki;
|
||||
} else {
|
||||
mtx_destroy(&ki->kaio_mtx);
|
||||
uma_zfree(kaio_zone, ki);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
while (num_aio_procs < MIN(target_aio_procs, max_aio_procs))
|
||||
aio_newproc(NULL);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static int
|
||||
aio_sendsig(struct proc *p, struct sigevent *sigev, ksiginfo_t *ksi)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct thread *td;
|
||||
int error;
|
||||
|
||||
@ -482,6 +507,9 @@ aio_sendsig(struct proc *p, struct sigevent *sigev, ksiginfo_t *ksi)
|
||||
}
|
||||
PROC_UNLOCK(p);
|
||||
return (error);
|
||||
#else /* __rtems__ */
|
||||
return 0;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -494,11 +522,15 @@ aio_free_entry(struct kaiocb *job)
|
||||
{
|
||||
struct kaioinfo *ki;
|
||||
struct aioliojob *lj;
|
||||
#ifndef __rtems__
|
||||
struct proc *p;
|
||||
|
||||
p = job->userproc;
|
||||
MPASS(curproc == p);
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
MPASS(ki != NULL);
|
||||
|
||||
AIO_LOCK_ASSERT(ki, MA_OWNED);
|
||||
@ -521,18 +553,22 @@ aio_free_entry(struct kaiocb *job)
|
||||
TAILQ_REMOVE(&ki->kaio_liojoblist, lj, lioj_list);
|
||||
/* lio is going away, we need to destroy any knotes */
|
||||
knlist_delete(&lj->klist, curthread, 1);
|
||||
#ifndef __rtems__
|
||||
PROC_LOCK(p);
|
||||
sigqueue_take(&lj->lioj_ksi);
|
||||
PROC_UNLOCK(p);
|
||||
#endif /* __rtems__ */
|
||||
uma_zfree(aiolio_zone, lj);
|
||||
}
|
||||
}
|
||||
|
||||
/* job is going away, we need to destroy any knotes */
|
||||
knlist_delete(&job->klist, curthread, 1);
|
||||
#ifndef __rtems__
|
||||
PROC_LOCK(p);
|
||||
sigqueue_take(&job->ksi);
|
||||
PROC_UNLOCK(p);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
AIO_UNLOCK(ki);
|
||||
|
||||
@ -635,7 +671,11 @@ aio_proc_rundown(void *arg, struct proc *p)
|
||||
|
||||
KASSERT(curthread->td_proc == p,
|
||||
("%s: called on non-curproc", __func__));
|
||||
#ifndef __rtems__
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
if (ki == NULL)
|
||||
return;
|
||||
|
||||
@ -655,7 +695,11 @@ restart:
|
||||
/* Wait for all running I/O to be finished */
|
||||
if (TAILQ_FIRST(&ki->kaio_jobqueue) || ki->kaio_active_count != 0) {
|
||||
ki->kaio_flags |= KAIO_WAKEUP;
|
||||
#ifndef __rtems__
|
||||
msleep(&p->p_aioinfo, AIO_MTX(ki), PRIBIO, "aioprn", hz);
|
||||
#else /* __rtems__ */
|
||||
msleep(&aio_proc_p_aioinfo, AIO_MTX(ki), PRIBIO, "aioprn", hz);
|
||||
#endif /* __rtems__ */
|
||||
goto restart;
|
||||
}
|
||||
|
||||
@ -667,9 +711,11 @@ restart:
|
||||
if (lj->lioj_count == 0) {
|
||||
TAILQ_REMOVE(&ki->kaio_liojoblist, lj, lioj_list);
|
||||
knlist_delete(&lj->klist, curthread, 1);
|
||||
#ifndef __rtems__
|
||||
PROC_LOCK(p);
|
||||
sigqueue_take(&lj->lioj_ksi);
|
||||
PROC_UNLOCK(p);
|
||||
#endif /* __rtems__ */
|
||||
uma_zfree(aiolio_zone, lj);
|
||||
} else {
|
||||
panic("LIO job not cleaned up: C:%d, FC:%d\n",
|
||||
@ -681,7 +727,11 @@ restart:
|
||||
taskqueue_drain(taskqueue_aiod_kick, &ki->kaio_sync_task);
|
||||
mtx_destroy(&ki->kaio_mtx);
|
||||
uma_zfree(kaio_zone, ki);
|
||||
#ifndef __rtems__
|
||||
p->p_aioinfo = NULL;
|
||||
#else /* __rtems__ */
|
||||
aio_proc_p_aioinfo = NULL;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -698,7 +748,11 @@ aio_selectjob(struct aioproc *aiop)
|
||||
restart:
|
||||
TAILQ_FOREACH(job, &aio_jobs, list) {
|
||||
userp = job->userproc;
|
||||
#ifndef __rtems__
|
||||
ki = userp->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
if (ki->kaio_active_count < max_aio_per_proc) {
|
||||
TAILQ_REMOVE(&aio_jobs, job, list);
|
||||
@ -785,10 +839,12 @@ aio_process_rw(struct kaiocb *job)
|
||||
auio.uio_segflg = UIO_USERSPACE;
|
||||
auio.uio_td = td;
|
||||
|
||||
#ifndef __rtems__
|
||||
msgrcv_st = td->td_ru.ru_msgrcv;
|
||||
msgsnd_st = td->td_ru.ru_msgsnd;
|
||||
inblock_st = td->td_ru.ru_inblock;
|
||||
oublock_st = td->td_ru.ru_oublock;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* aio_aqueue() acquires a reference to the file that is
|
||||
@ -806,6 +862,7 @@ aio_process_rw(struct kaiocb *job)
|
||||
auio.uio_rw = UIO_WRITE;
|
||||
error = fo_write(fp, &auio, fp->f_cred, FOF_OFFSET, td);
|
||||
}
|
||||
#ifndef __rtems__
|
||||
msgrcv_end = td->td_ru.ru_msgrcv;
|
||||
msgsnd_end = td->td_ru.ru_msgsnd;
|
||||
inblock_end = td->td_ru.ru_inblock;
|
||||
@ -815,14 +872,17 @@ aio_process_rw(struct kaiocb *job)
|
||||
job->msgsnd = msgsnd_end - msgsnd_st;
|
||||
job->inblock = inblock_end - inblock_st;
|
||||
job->outblock = oublock_end - oublock_st;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
if ((error) && (auio.uio_resid != cnt)) {
|
||||
if (error == ERESTART || error == EINTR || error == EWOULDBLOCK)
|
||||
error = 0;
|
||||
if ((error == EPIPE) && (cb->aio_lio_opcode == LIO_WRITE)) {
|
||||
#ifndef __rtems__
|
||||
PROC_LOCK(job->userproc);
|
||||
kern_psignal(job->userproc, SIGPIPE);
|
||||
PROC_UNLOCK(job->userproc);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
}
|
||||
|
||||
@ -879,7 +939,11 @@ aio_bio_done_notify(struct proc *userp, struct kaiocb *job)
|
||||
int lj_done;
|
||||
bool schedule_fsync;
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = userp->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
AIO_LOCK_ASSERT(ki, MA_OWNED);
|
||||
lj = job->lio;
|
||||
lj_done = 0;
|
||||
@ -894,12 +958,15 @@ aio_bio_done_notify(struct proc *userp, struct kaiocb *job)
|
||||
if (ki->kaio_flags & KAIO_RUNDOWN)
|
||||
goto notification_done;
|
||||
|
||||
#ifndef __rtems__
|
||||
if (job->uaiocb.aio_sigevent.sigev_notify == SIGEV_SIGNAL ||
|
||||
job->uaiocb.aio_sigevent.sigev_notify == SIGEV_THREAD_ID)
|
||||
aio_sendsig(userp, &job->uaiocb.aio_sigevent, &job->ksi);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
KNOTE_LOCKED(&job->klist, 1);
|
||||
|
||||
#ifndef __rtems__
|
||||
if (lj_done) {
|
||||
if (lj->lioj_signal.sigev_notify == SIGEV_KEVENT) {
|
||||
lj->lioj_flags |= LIOJ_KEVENT_POSTED;
|
||||
@ -913,6 +980,7 @@ aio_bio_done_notify(struct proc *userp, struct kaiocb *job)
|
||||
lj->lioj_flags |= LIOJ_SIGNAL_POSTED;
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
notification_done:
|
||||
if (job->jobflags & KAIOCB_CHECKSYNC) {
|
||||
@ -935,7 +1003,12 @@ notification_done:
|
||||
}
|
||||
if (ki->kaio_flags & KAIO_WAKEUP) {
|
||||
ki->kaio_flags &= ~KAIO_WAKEUP;
|
||||
|
||||
#ifndef __rtems__
|
||||
wakeup(&userp->p_aioinfo);
|
||||
#else /* __rtems__ */
|
||||
wakeup(&aio_proc_p_aioinfo);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
}
|
||||
|
||||
@ -974,7 +1047,9 @@ static bool
|
||||
aio_clear_cancel_function_locked(struct kaiocb *job)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
AIO_LOCK_ASSERT(job->userproc->p_aioinfo, MA_OWNED);
|
||||
#endif /* __rtems__ */
|
||||
MPASS(job->cancel_fn != NULL);
|
||||
if (job->jobflags & KAIOCB_CANCELLING) {
|
||||
job->jobflags |= KAIOCB_CLEARED;
|
||||
@ -990,7 +1065,11 @@ aio_clear_cancel_function(struct kaiocb *job)
|
||||
struct kaioinfo *ki;
|
||||
bool ret;
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = job->userproc->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
AIO_LOCK(ki);
|
||||
ret = aio_clear_cancel_function_locked(job);
|
||||
AIO_UNLOCK(ki);
|
||||
@ -1001,7 +1080,9 @@ static bool
|
||||
aio_set_cancel_function_locked(struct kaiocb *job, aio_cancel_fn_t *func)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
AIO_LOCK_ASSERT(job->userproc->p_aioinfo, MA_OWNED);
|
||||
#endif /* __rtems__ */
|
||||
if (job->jobflags & KAIOCB_CANCELLED)
|
||||
return (false);
|
||||
job->cancel_fn = func;
|
||||
@ -1014,7 +1095,11 @@ aio_set_cancel_function(struct kaiocb *job, aio_cancel_fn_t *func)
|
||||
struct kaioinfo *ki;
|
||||
bool ret;
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = job->userproc->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
AIO_LOCK(ki);
|
||||
ret = aio_set_cancel_function_locked(job, func);
|
||||
AIO_UNLOCK(ki);
|
||||
@ -1030,8 +1115,13 @@ aio_complete(struct kaiocb *job, long status, int error)
|
||||
job->uaiocb._aiocb_private.error = error;
|
||||
job->uaiocb._aiocb_private.status = status;
|
||||
|
||||
#ifndef __rtems__
|
||||
userp = job->userproc;
|
||||
ki = userp->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
userp = NULL;
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
AIO_LOCK(ki);
|
||||
KASSERT(!(job->jobflags & KAIOCB_FINISHED),
|
||||
@ -1055,7 +1145,9 @@ void
|
||||
aio_switch_vmspace(struct kaiocb *job)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
vmspace_switch_aio(job->userproc->p_vmspace);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1078,24 +1170,30 @@ aio_daemon(void *_id)
|
||||
* doesn't get freed by jobs that switch to a different
|
||||
* vmspace.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
p = td->td_proc;
|
||||
myvm = vmspace_acquire_ref(p);
|
||||
|
||||
KASSERT(p->p_textvp == NULL, ("kthread has a textvp"));
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Allocate and ready the aio control info. There is one aiop structure
|
||||
* per daemon.
|
||||
*/
|
||||
aiop = uma_zalloc(aiop_zone, M_WAITOK);
|
||||
#ifndef __rtems__
|
||||
aiop->aioproc = p;
|
||||
#endif /* __rtems__ */
|
||||
aiop->aioprocflags = 0;
|
||||
|
||||
/*
|
||||
* Wakeup parent process. (Parent sleeps to keep from blasting away
|
||||
* and creating too many daemons.)
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
sema_post(&aio_newproc_sem);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
mtx_lock(&aio_job_mtx);
|
||||
for (;;) {
|
||||
@ -1113,7 +1211,11 @@ aio_daemon(void *_id)
|
||||
while ((job = aio_selectjob(aiop)) != NULL) {
|
||||
mtx_unlock(&aio_job_mtx);
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = job->userproc->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
job->handle_fn(job);
|
||||
|
||||
mtx_lock(&aio_job_mtx);
|
||||
@ -1124,6 +1226,7 @@ aio_daemon(void *_id)
|
||||
/*
|
||||
* Disconnect from user address space.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if (p->p_vmspace != myvm) {
|
||||
mtx_unlock(&aio_job_mtx);
|
||||
vmspace_switch_aio(myvm);
|
||||
@ -1134,6 +1237,7 @@ aio_daemon(void *_id)
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
mtx_assert(&aio_job_mtx, MA_OWNED);
|
||||
|
||||
@ -1155,12 +1259,14 @@ aio_daemon(void *_id)
|
||||
mtx_unlock(&aio_job_mtx);
|
||||
uma_zfree(aiop_zone, aiop);
|
||||
free_unr(aiod_unr, id);
|
||||
#ifndef __rtems__
|
||||
vmspace_free(myvm);
|
||||
|
||||
KASSERT(p->p_vmspace == myvm,
|
||||
("AIOD: bad vmspace for exiting daemon"));
|
||||
KASSERT(myvm->vm_refcnt > 1,
|
||||
("AIOD: bad vm refcnt for exiting daemon: %d", myvm->vm_refcnt));
|
||||
#endif /* __rtems__ */
|
||||
kproc_exit(0);
|
||||
}
|
||||
|
||||
@ -1182,7 +1288,9 @@ aio_newproc(int *start)
|
||||
/*
|
||||
* Wait until daemon is started.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
sema_wait(&aio_newproc_sem);
|
||||
#endif /* __rtems__ */
|
||||
mtx_lock(&aio_job_mtx);
|
||||
num_aio_procs++;
|
||||
if (start != NULL)
|
||||
@ -1248,7 +1356,11 @@ aio_qbio(struct proc *p, struct kaiocb *job)
|
||||
goto unref;
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
poff = (vm_offset_t)cb->aio_buf & PAGE_MASK;
|
||||
if ((dev->si_flags & SI_UNMAPPED) && unmapped_buf_allowed) {
|
||||
if (cb->aio_nbytes > MAXPHYS) {
|
||||
@ -1287,7 +1399,11 @@ aio_qbio(struct proc *p, struct kaiocb *job)
|
||||
prot = VM_PROT_READ;
|
||||
if (cb->aio_lio_opcode == LIO_READ)
|
||||
prot |= VM_PROT_WRITE; /* Less backwards than it looks */
|
||||
#ifndef __rtems__
|
||||
job->npages = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map,
|
||||
#else /* __rtems__ */
|
||||
job->npages = vm_fault_quick_hold_pages(NULL,
|
||||
#endif /* __rtems__ */
|
||||
(vm_offset_t)bp->bio_data, bp->bio_length, prot, job->pages,
|
||||
nitems(job->pages));
|
||||
if (job->npages < 0) {
|
||||
@ -1309,7 +1425,9 @@ aio_qbio(struct proc *p, struct kaiocb *job)
|
||||
}
|
||||
|
||||
/* Perform transfer. */
|
||||
#ifndef __rtems__
|
||||
csw->d_strategy(bp);
|
||||
#endif /* __rtems__ */
|
||||
dev_relthread(dev, ref);
|
||||
return (0);
|
||||
|
||||
@ -1449,7 +1567,9 @@ int
|
||||
aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
|
||||
int type, struct aiocb_ops *ops)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct proc *p = td->td_proc;
|
||||
#endif /* __rtems__ */
|
||||
struct file *fp;
|
||||
struct kaiocb *job;
|
||||
struct kaioinfo *ki;
|
||||
@ -1460,10 +1580,14 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
|
||||
int jid;
|
||||
u_short evflags;
|
||||
|
||||
#ifndef __rtems__
|
||||
if (p->p_aioinfo == NULL)
|
||||
aio_init_aioinfo(p);
|
||||
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
ops->store_status(ujob, -1);
|
||||
ops->store_error(ujob, 0);
|
||||
@ -1490,6 +1614,7 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
if (job->uaiocb.aio_sigevent.sigev_notify != SIGEV_KEVENT &&
|
||||
job->uaiocb.aio_sigevent.sigev_notify != SIGEV_SIGNAL &&
|
||||
job->uaiocb.aio_sigevent.sigev_notify != SIGEV_THREAD_ID &&
|
||||
@ -1505,6 +1630,7 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
|
||||
uma_zfree(aiocb_zone, job);
|
||||
return (EINVAL);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
ksiginfo_init(&job->ksi);
|
||||
|
||||
@ -1581,6 +1707,15 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
/*
|
||||
* Note: the following has been removed because kqueue and signals
|
||||
* meet here and for reasons I cannot explain signal support in libbsd
|
||||
* has not been supported but it needs to be.
|
||||
*/
|
||||
error = EINVAL;
|
||||
goto aqueue_fail;
|
||||
#else /* __rtems__ */
|
||||
if (job->uaiocb.aio_sigevent.sigev_notify != SIGEV_KEVENT)
|
||||
goto no_kqueue;
|
||||
evflags = job->uaiocb.aio_sigevent.sigev_notify_kevent_flags;
|
||||
@ -1598,12 +1733,15 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
|
||||
error = kqfd_register(kqfd, &kev, td, M_WAITOK);
|
||||
if (error)
|
||||
goto aqueue_fail;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
no_kqueue:
|
||||
|
||||
ops->store_error(ujob, EINPROGRESS);
|
||||
job->uaiocb._aiocb_private.error = EINPROGRESS;
|
||||
#ifndef __rtems__
|
||||
job->userproc = p;
|
||||
#endif /* __rtems__ */
|
||||
job->cred = crhold(td->td_ucred);
|
||||
job->jobflags = KAIOCB_QUEUEING;
|
||||
job->lio = lj;
|
||||
@ -1631,7 +1769,11 @@ no_kqueue:
|
||||
* The bulk of the completion is deferred in that case
|
||||
* until this point.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
aio_bio_done_notify(p, job);
|
||||
#else /* __rtems__ */
|
||||
aio_bio_done_notify(NULL, job);
|
||||
#endif /* __rtems__ */
|
||||
} else
|
||||
TAILQ_INSERT_TAIL(&ki->kaio_jobqueue, job, plist);
|
||||
AIO_UNLOCK(ki);
|
||||
@ -1678,7 +1820,11 @@ aio_cancel_sync(struct kaiocb *job)
|
||||
{
|
||||
struct kaioinfo *ki;
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = job->userproc->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
AIO_LOCK(ki);
|
||||
if (!aio_cancel_cleared(job))
|
||||
TAILQ_REMOVE(&ki->kaio_syncqueue, job, list);
|
||||
@ -1696,7 +1842,11 @@ aio_queue_file(struct file *fp, struct kaiocb *job)
|
||||
int error;
|
||||
bool safe;
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = job->userproc->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
error = aio_qbio(job->userproc, job);
|
||||
if (error >= 0)
|
||||
return (error);
|
||||
@ -1755,7 +1905,11 @@ aio_queue_file(struct file *fp, struct kaiocb *job)
|
||||
static void
|
||||
aio_kick_nowait(struct proc *userp)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct kaioinfo *ki = userp->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
struct kaioinfo *ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
struct aioproc *aiop;
|
||||
|
||||
mtx_assert(&aio_job_mtx, MA_OWNED);
|
||||
@ -1772,7 +1926,11 @@ aio_kick_nowait(struct proc *userp)
|
||||
static int
|
||||
aio_kick(struct proc *userp)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct kaioinfo *ki = userp->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
struct kaioinfo *ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
struct aioproc *aiop;
|
||||
int error, ret = 0;
|
||||
|
||||
@ -1818,12 +1976,18 @@ aio_kick_helper(void *context, int pending)
|
||||
static int
|
||||
kern_aio_return(struct thread *td, struct aiocb *ujob, struct aiocb_ops *ops)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct proc *p = td->td_proc;
|
||||
#endif /* __rtems__ */
|
||||
struct kaiocb *job;
|
||||
struct kaioinfo *ki;
|
||||
long status, error;
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
if (ki == NULL)
|
||||
return (EINVAL);
|
||||
AIO_LOCK(ki);
|
||||
@ -1836,10 +2000,12 @@ kern_aio_return(struct thread *td, struct aiocb *ujob, struct aiocb_ops *ops)
|
||||
status = job->uaiocb._aiocb_private.status;
|
||||
error = job->uaiocb._aiocb_private.error;
|
||||
td->td_retval[0] = status;
|
||||
#ifndef __rtems__
|
||||
td->td_ru.ru_oublock += job->outblock;
|
||||
td->td_ru.ru_inblock += job->inblock;
|
||||
td->td_ru.ru_msgsnd += job->msgsnd;
|
||||
td->td_ru.ru_msgrcv += job->msgrcv;
|
||||
#endif /* __rtems__ */
|
||||
aio_free_entry(job);
|
||||
AIO_UNLOCK(ki);
|
||||
ops->store_error(ujob, error);
|
||||
@ -1865,7 +2031,9 @@ static int
|
||||
kern_aio_suspend(struct thread *td, int njoblist, struct aiocb **ujoblist,
|
||||
struct timespec *ts)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct proc *p = td->td_proc;
|
||||
#endif /* __rtems__ */
|
||||
struct timeval atv;
|
||||
struct kaioinfo *ki;
|
||||
struct kaiocb *firstjob, *job;
|
||||
@ -1882,7 +2050,11 @@ kern_aio_suspend(struct thread *td, int njoblist, struct aiocb **ujoblist,
|
||||
timo = tvtohz(&atv);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
if (ki == NULL)
|
||||
return (EAGAIN);
|
||||
|
||||
@ -1908,8 +2080,13 @@ kern_aio_suspend(struct thread *td, int njoblist, struct aiocb **ujoblist,
|
||||
break;
|
||||
|
||||
ki->kaio_flags |= KAIO_WAKEUP;
|
||||
#ifndef __rtems__
|
||||
error = msleep(&p->p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
|
||||
"aiospn", timo);
|
||||
#else /* __rtems__ */
|
||||
error = msleep(&aio_proc_p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
|
||||
"aiospn", timo);
|
||||
#endif /* __rtems__ */
|
||||
if (error == ERESTART)
|
||||
error = EINTR;
|
||||
if (error)
|
||||
@ -1952,7 +2129,11 @@ sys_aio_suspend(struct thread *td, struct aio_suspend_args *uap)
|
||||
int
|
||||
sys_aio_cancel(struct thread *td, struct aio_cancel_args *uap)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct proc *p = td->td_proc;
|
||||
#else /* __rtems__ */
|
||||
struct proc *p = NULL;
|
||||
#endif /* __rtems__ */
|
||||
struct kaioinfo *ki;
|
||||
struct kaiocb *job, *jobn;
|
||||
struct file *fp;
|
||||
@ -1966,7 +2147,11 @@ sys_aio_cancel(struct thread *td, struct aio_cancel_args *uap)
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
if (ki == NULL)
|
||||
goto done;
|
||||
|
||||
@ -2028,12 +2213,18 @@ done:
|
||||
static int
|
||||
kern_aio_error(struct thread *td, struct aiocb *ujob, struct aiocb_ops *ops)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct proc *p = td->td_proc;
|
||||
#endif /* __rtems__ */
|
||||
struct kaiocb *job;
|
||||
struct kaioinfo *ki;
|
||||
int status;
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
if (ki == NULL) {
|
||||
td->td_retval[0] = EINVAL;
|
||||
return (0);
|
||||
@ -2121,7 +2312,9 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
|
||||
struct aiocb **acb_list, int nent, struct sigevent *sig,
|
||||
struct aiocb_ops *ops)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct proc *p = td->td_proc;
|
||||
#endif /* __rtems__ */
|
||||
struct aiocb *job;
|
||||
struct kaioinfo *ki;
|
||||
struct aioliojob *lj;
|
||||
@ -2136,10 +2329,19 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
|
||||
if (nent < 0 || nent > max_aio_queue_per_proc)
|
||||
return (EINVAL);
|
||||
|
||||
#ifndef __rtems__
|
||||
if (p->p_aioinfo == NULL)
|
||||
aio_init_aioinfo(p);
|
||||
#else /* __rtems__ */
|
||||
if (aio_proc_p_aioinfo == NULL)
|
||||
aio_init_aioinfo(NULL);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
lj = uma_zalloc(aiolio_zone, M_WAITOK);
|
||||
lj->lioj_flags = 0;
|
||||
@ -2152,6 +2354,14 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
|
||||
* Setup signal.
|
||||
*/
|
||||
if (sig && (mode == LIO_NOWAIT)) {
|
||||
#ifdef __rtems__
|
||||
/*
|
||||
* Note: the following has been removed because kqueue and signals
|
||||
* meet here and for reasons I cannot explain signal support in libbsd
|
||||
* has not been supported but it needs to be.
|
||||
*/
|
||||
return EINVAL;
|
||||
#else /* __rtems__ */
|
||||
bcopy(sig, &lj->lioj_signal, sizeof(lj->lioj_signal));
|
||||
if (lj->lioj_signal.sigev_notify == SIGEV_KEVENT) {
|
||||
/* Assume only new style KEVENT */
|
||||
@ -2182,6 +2392,7 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
|
||||
uma_zfree(aiolio_zone, lj);
|
||||
return EINVAL;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
AIO_LOCK(ki);
|
||||
@ -2216,7 +2427,11 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
|
||||
if (mode == LIO_WAIT) {
|
||||
while (lj->lioj_count - 1 != lj->lioj_finished_count) {
|
||||
ki->kaio_flags |= KAIO_WAKEUP;
|
||||
#ifndef __rtems__
|
||||
error = msleep(&p->p_aioinfo, AIO_MTX(ki),
|
||||
#else /* __rtems__ */
|
||||
error = msleep(&aio_proc_p_aioinfo, AIO_MTX(ki),
|
||||
#endif /* __rtems__ */
|
||||
PRIBIO | PCATCH, "aiospn", 0);
|
||||
if (error == ERESTART)
|
||||
error = EINTR;
|
||||
@ -2225,6 +2440,15 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
|
||||
}
|
||||
} else {
|
||||
if (lj->lioj_count - 1 == lj->lioj_finished_count) {
|
||||
#ifdef __rtems__
|
||||
/*
|
||||
* Note: the following has been removed because kqueue
|
||||
* and signals meet here and for reasons I cannot
|
||||
* explain signal support in libbsd has not been
|
||||
* supported but it needs to be.
|
||||
*/
|
||||
return EINVAL;
|
||||
#else /* __rtems__ */
|
||||
if (lj->lioj_signal.sigev_notify == SIGEV_KEVENT) {
|
||||
lj->lioj_flags |= LIOJ_KEVENT_POSTED;
|
||||
KNOTE_LOCKED(&lj->klist, 1);
|
||||
@ -2237,15 +2461,18 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
|
||||
&lj->lioj_ksi);
|
||||
lj->lioj_flags |= LIOJ_SIGNAL_POSTED;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
}
|
||||
lj->lioj_count--;
|
||||
if (lj->lioj_count == 0) {
|
||||
TAILQ_REMOVE(&ki->kaio_liojoblist, lj, lioj_list);
|
||||
knlist_delete(&lj->klist, curthread, 1);
|
||||
#ifndef __rtems__
|
||||
PROC_LOCK(p);
|
||||
sigqueue_take(&lj->lioj_ksi);
|
||||
PROC_UNLOCK(p);
|
||||
#endif /* __rtems__ */
|
||||
AIO_UNLOCK(ki);
|
||||
uma_zfree(aiolio_zone, lj);
|
||||
} else
|
||||
@ -2341,7 +2568,11 @@ aio_biowakeup(struct bio *bp)
|
||||
|
||||
/* Release mapping into kernel space. */
|
||||
userp = job->userproc;
|
||||
#ifndef __rtems__
|
||||
ki = userp->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
if (job->pbuf) {
|
||||
pmap_qremove((vm_offset_t)job->pbuf->b_data, job->npages);
|
||||
relpbuf(job->pbuf, NULL);
|
||||
@ -2379,7 +2610,9 @@ static int
|
||||
kern_aio_waitcomplete(struct thread *td, struct aiocb **ujobp,
|
||||
struct timespec *ts, struct aiocb_ops *ops)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct proc *p = td->td_proc;
|
||||
#endif /* __rtems__ */
|
||||
struct timeval atv;
|
||||
struct kaioinfo *ki;
|
||||
struct kaiocb *job;
|
||||
@ -2403,9 +2636,15 @@ kern_aio_waitcomplete(struct thread *td, struct aiocb **ujobp,
|
||||
timo = tvtohz(&atv);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
if (p->p_aioinfo == NULL)
|
||||
aio_init_aioinfo(p);
|
||||
ki = p->p_aioinfo;
|
||||
#else /* __rtems__ */
|
||||
if (aio_proc_p_aioinfo == NULL)
|
||||
aio_init_aioinfo(NULL);
|
||||
ki = aio_proc_p_aioinfo;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
error = 0;
|
||||
job = NULL;
|
||||
@ -2416,8 +2655,13 @@ kern_aio_waitcomplete(struct thread *td, struct aiocb **ujobp,
|
||||
break;
|
||||
}
|
||||
ki->kaio_flags |= KAIO_WAKEUP;
|
||||
#ifndef __rtems__
|
||||
error = msleep(&p->p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
|
||||
"aiowc", timo);
|
||||
#else /* __rtems__ */
|
||||
error = msleep(&aio_proc_p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
|
||||
"aiowc", timo);
|
||||
#endif /* __rtems__ */
|
||||
if (timo && error == ERESTART)
|
||||
error = EINTR;
|
||||
if (error)
|
||||
@ -2430,10 +2674,12 @@ kern_aio_waitcomplete(struct thread *td, struct aiocb **ujobp,
|
||||
status = job->uaiocb._aiocb_private.status;
|
||||
error = job->uaiocb._aiocb_private.error;
|
||||
td->td_retval[0] = status;
|
||||
#ifndef __rtems__
|
||||
td->td_ru.ru_oublock += job->outblock;
|
||||
td->td_ru.ru_inblock += job->inblock;
|
||||
td->td_ru.ru_msgsnd += job->msgsnd;
|
||||
td->td_ru.ru_msgrcv += job->msgrcv;
|
||||
#endif /* __rtems__ */
|
||||
aio_free_entry(job);
|
||||
AIO_UNLOCK(ki);
|
||||
ops->store_aiocb(ujobp, ujob);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
@ -54,7 +56,9 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/conf.h>
|
||||
#include <sys/counter.h>
|
||||
#include <sys/buf.h>
|
||||
#ifndef __rtems__
|
||||
#include <sys/devicestat.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/eventhandler.h>
|
||||
#include <sys/fail.h>
|
||||
#include <sys/limits.h>
|
||||
@ -85,8 +89,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include <vm/vm_pager.h>
|
||||
#include <vm/vm_extern.h>
|
||||
#include <vm/vm_map.h>
|
||||
#ifndef __rtems__
|
||||
#include <vm/swap_pager.h>
|
||||
#include "opt_swap.h"
|
||||
#endif /* __rtems__ */
|
||||
#include <rtems/bsd/local/opt_swap.h>
|
||||
|
||||
static MALLOC_DEFINE(M_BIOBUF, "biobuf", "BIO buffer");
|
||||
|
||||
@ -147,7 +153,15 @@ struct bufdomain {
|
||||
#define BD_DOMAIN(bd) (bd - bdomain)
|
||||
|
||||
static struct buf *buf; /* buffer header pool */
|
||||
#ifndef __rtems__
|
||||
extern struct buf *swbuf; /* Swap buffer header pool. */
|
||||
#else /* __rtems__ */
|
||||
#define VPR_NOREUSE 0
|
||||
#define VPR_TRYFREE 0
|
||||
#define bogus_page (NULL + 1)
|
||||
#define num_pages(x) \
|
||||
((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) >> PAGE_SHIFT))
|
||||
#endif /* __rtems__ */
|
||||
caddr_t __read_mostly unmapped_buf;
|
||||
|
||||
/* Used below and for softdep flushing threads in ufs/ffs/ffs_softdep.c */
|
||||
@ -791,12 +805,16 @@ bufspace_daemon(void *arg)
|
||||
{
|
||||
struct bufdomain *bd;
|
||||
|
||||
#ifndef __rtems__
|
||||
EVENTHANDLER_REGISTER(shutdown_pre_sync, kthread_shutdown, curthread,
|
||||
SHUTDOWN_PRI_LAST + 100);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
bd = arg;
|
||||
for (;;) {
|
||||
#ifndef __rtems__
|
||||
kthread_suspend_check();
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Free buffers from the clean queue until we meet our
|
||||
@ -844,7 +862,9 @@ bufspace_daemon(void *arg)
|
||||
} else
|
||||
BD_UNLOCK(bd);
|
||||
}
|
||||
#ifndef __rtems__
|
||||
maybe_yield();
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
bufspace_daemon_wait(bd);
|
||||
}
|
||||
@ -953,6 +973,7 @@ static __inline void
|
||||
vfs_buf_test_cache(struct buf *bp, vm_ooffset_t foff, vm_offset_t off,
|
||||
vm_offset_t size, vm_page_t m)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
|
||||
VM_OBJECT_ASSERT_LOCKED(m->object);
|
||||
if (bp->b_flags & B_CACHE) {
|
||||
@ -960,6 +981,7 @@ vfs_buf_test_cache(struct buf *bp, vm_ooffset_t foff, vm_offset_t off,
|
||||
if (vm_page_is_valid(m, base, size) == 0)
|
||||
bp->b_flags &= ~B_CACHE;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/* Wake up the buffer daemon if necessary */
|
||||
@ -1017,9 +1039,11 @@ bd_speedup(void)
|
||||
mtx_unlock(&bdlock);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
#ifndef NSWBUF_MIN
|
||||
#define NSWBUF_MIN 16
|
||||
#endif
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __i386__
|
||||
#define TRANSIENT_DENOM 5
|
||||
@ -1129,6 +1153,7 @@ kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est)
|
||||
nbuf = buf_sz / BKVASIZE;
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* swbufs are used as temporary holders for I/O, such as paging I/O.
|
||||
* We have no less then 16 and no more then 256.
|
||||
@ -1137,12 +1162,15 @@ kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est)
|
||||
TUNABLE_INT_FETCH("kern.nswbuf", &nswbuf);
|
||||
if (nswbuf < NSWBUF_MIN)
|
||||
nswbuf = NSWBUF_MIN;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Reserve space for the buffer cache buffers
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
swbuf = (void *)v;
|
||||
v = (caddr_t)(swbuf + nswbuf);
|
||||
#endif /* __rtems__ */
|
||||
buf = (void *)v;
|
||||
v = (caddr_t)(buf + nbuf);
|
||||
|
||||
@ -1164,7 +1192,12 @@ bufinit(void)
|
||||
mtx_init(&bdlock, "buffer daemon lock", NULL, MTX_DEF);
|
||||
mtx_init(&bdirtylock, "dirty buf lock", NULL, MTX_DEF);
|
||||
|
||||
#ifndef __rtems__
|
||||
unmapped_buf = (caddr_t)kva_alloc(MAXPHYS);
|
||||
#else /* __rtems__ */
|
||||
extern caddr_t unmapped_base;
|
||||
unmapped_buf = (caddr_t)unmapped_base;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* finally, initialize each buffer header and stick on empty q */
|
||||
for (i = 0; i < nbuf; i++) {
|
||||
@ -1252,7 +1285,9 @@ bufinit(void)
|
||||
numfreebuffers = nbuf;
|
||||
|
||||
/* Setup the kva and free list allocators. */
|
||||
#ifndef __rtems__
|
||||
vmem_set_reclaim(buffer_arena, bufkva_reclaim);
|
||||
#endif /* __rtems__ */
|
||||
buf_zone = uma_zcache_create("buf free cache", sizeof(struct buf),
|
||||
NULL, NULL, NULL, NULL, buf_import, buf_release, NULL, 0);
|
||||
|
||||
@ -1335,6 +1370,7 @@ isbufbusy(struct buf *bp)
|
||||
void
|
||||
bufshutdown(int show_busybufs)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
static int first_buf_printf = 1;
|
||||
struct buf *bp;
|
||||
int iter, nbusy, pbusy;
|
||||
@ -1441,6 +1477,7 @@ bufshutdown(int show_busybufs)
|
||||
}
|
||||
swapoff_all();
|
||||
DELAY(100000); /* wait for console output to finish */
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1454,7 +1491,9 @@ bpmap_qenter(struct buf *bp)
|
||||
* bp->b_offset may be offset into the first page.
|
||||
*/
|
||||
bp->b_data = (caddr_t)trunc_page((vm_offset_t)bp->b_data);
|
||||
#ifndef __rtems__
|
||||
pmap_qenter((vm_offset_t)bp->b_data, bp->b_pages, bp->b_npages);
|
||||
#endif /* __rtems__ */
|
||||
bp->b_data = (caddr_t)((vm_offset_t)bp->b_data |
|
||||
(vm_offset_t)(bp->b_offset & PAGE_MASK));
|
||||
}
|
||||
@ -2103,7 +2142,9 @@ breada(struct vnode * vp, daddr_t * rablkno, int * rabsize, int cnt,
|
||||
PROC_UNLOCK(curproc);
|
||||
}
|
||||
#endif /* RACCT */
|
||||
#ifndef __rtems__
|
||||
td->td_ru.ru_inblock++;
|
||||
#endif /* __rtems__ */
|
||||
rabp->b_flags |= B_ASYNC;
|
||||
rabp->b_flags &= ~B_INVAL;
|
||||
if ((flags & GB_CKHASH) != 0) {
|
||||
@ -2166,7 +2207,9 @@ breadn_flags(struct vnode *vp, daddr_t blkno, int size, daddr_t *rablkno,
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
}
|
||||
#endif /* RACCT */
|
||||
#ifndef __rtems__
|
||||
td->td_ru.ru_inblock++;
|
||||
#endif /* __rtems__ */
|
||||
bp->b_iocmd = BIO_READ;
|
||||
bp->b_flags &= ~B_INVAL;
|
||||
if ((flags & GB_CKHASH) != 0) {
|
||||
@ -2274,7 +2317,9 @@ bufwrite(struct buf *bp)
|
||||
PROC_UNLOCK(curproc);
|
||||
}
|
||||
#endif /* RACCT */
|
||||
#ifndef __rtems__
|
||||
curthread->td_ru.ru_oublock++;
|
||||
#endif /* __rtems__ */
|
||||
if (oldflags & B_ASYNC)
|
||||
BUF_KERNPROC(bp);
|
||||
bp->b_iooffset = dbtob(bp->b_blkno);
|
||||
@ -2835,6 +2880,9 @@ out:
|
||||
static void
|
||||
vfs_vmio_iodone(struct buf *bp)
|
||||
{
|
||||
#ifdef __rtems__
|
||||
panic(__func__);
|
||||
#else /* __rtems__ */
|
||||
vm_ooffset_t foff;
|
||||
vm_page_t m;
|
||||
vm_object_t obj;
|
||||
@ -2901,6 +2949,7 @@ vfs_vmio_iodone(struct buf *bp)
|
||||
pmap_qenter(trunc_page((vm_offset_t)bp->b_data),
|
||||
bp->b_pages, bp->b_npages);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2916,7 +2965,9 @@ vfs_vmio_invalidate(struct buf *bp)
|
||||
|
||||
if (buf_mapped(bp)) {
|
||||
BUF_CHECK_MAPPED(bp);
|
||||
#ifndef __rtems__
|
||||
pmap_qremove(trunc_page((vm_offset_t)bp->b_data), bp->b_npages);
|
||||
#endif /* _-rtems__ */
|
||||
} else
|
||||
BUF_CHECK_UNMAPPED(bp);
|
||||
/*
|
||||
@ -2942,6 +2993,7 @@ vfs_vmio_invalidate(struct buf *bp)
|
||||
panic("vfs_vmio_invalidate: Unexpected bogus page.");
|
||||
bp->b_pages[i] = NULL;
|
||||
|
||||
#ifndef __rtems__
|
||||
presid = resid > (PAGE_SIZE - poffset) ?
|
||||
(PAGE_SIZE - poffset) : resid;
|
||||
KASSERT(presid >= 0, ("brelse: extra page"));
|
||||
@ -2954,6 +3006,7 @@ vfs_vmio_invalidate(struct buf *bp)
|
||||
if (pmap_page_wired_mappings(m) == 0)
|
||||
vm_page_set_invalid(m, poffset, presid);
|
||||
vm_page_release_locked(m, flags);
|
||||
#endif /* __rtems__ */
|
||||
resid -= presid;
|
||||
poffset = 0;
|
||||
}
|
||||
@ -2976,8 +3029,10 @@ vfs_vmio_truncate(struct buf *bp, int desiredpages)
|
||||
|
||||
if (buf_mapped(bp)) {
|
||||
BUF_CHECK_MAPPED(bp);
|
||||
#ifndef __rtems__
|
||||
pmap_qremove((vm_offset_t)trunc_page((vm_offset_t)bp->b_data) +
|
||||
(desiredpages << PAGE_SHIFT), bp->b_npages - desiredpages);
|
||||
#endif /* __rtems__ */
|
||||
} else
|
||||
BUF_CHECK_UNMAPPED(bp);
|
||||
|
||||
@ -2996,10 +3051,12 @@ vfs_vmio_truncate(struct buf *bp, int desiredpages)
|
||||
m = bp->b_pages[i];
|
||||
KASSERT(m != bogus_page, ("allocbuf: bogus page found"));
|
||||
bp->b_pages[i] = NULL;
|
||||
#ifndef __rtems__
|
||||
if (obj != NULL)
|
||||
vm_page_release_locked(m, flags);
|
||||
else
|
||||
vm_page_release(m, flags);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
if (obj != NULL)
|
||||
VM_OBJECT_WUNLOCK(obj);
|
||||
@ -3039,11 +3096,13 @@ vfs_vmio_extend(struct buf *bp, int desiredpages, int size)
|
||||
* deadlocks once allocbuf() is called after
|
||||
* pages are vfs_busy_pages().
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
(void)vm_page_grab_pages(obj,
|
||||
OFF_TO_IDX(bp->b_offset) + bp->b_npages,
|
||||
VM_ALLOC_SYSTEM | VM_ALLOC_IGN_SBUSY |
|
||||
VM_ALLOC_NOBUSY | VM_ALLOC_WIRED,
|
||||
&bp->b_pages[bp->b_npages], desiredpages - bp->b_npages);
|
||||
#endif /* __rtems__ */
|
||||
bp->b_npages = desiredpages;
|
||||
}
|
||||
|
||||
@ -3079,9 +3138,11 @@ vfs_vmio_extend(struct buf *bp, int desiredpages, int size)
|
||||
/*
|
||||
* Step 3, fixup the KVA pmap.
|
||||
*/
|
||||
#ifdef __rtems__
|
||||
if (buf_mapped(bp))
|
||||
bpmap_qenter(bp);
|
||||
else
|
||||
#endif /* __rtems__ */
|
||||
BUF_CHECK_UNMAPPED(bp);
|
||||
}
|
||||
|
||||
@ -3178,9 +3239,13 @@ vfs_bio_awrite(struct buf *bp)
|
||||
*/
|
||||
if (ncl != 1) {
|
||||
BUF_UNLOCK(bp);
|
||||
#ifndef __rtems__
|
||||
nwritten = cluster_wbuild(vp, size, lblkno - j, ncl,
|
||||
gbflags);
|
||||
return (nwritten);
|
||||
#else /* __rtems__ */
|
||||
panic("no cluster support");
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
}
|
||||
bremfree(bp);
|
||||
@ -3330,8 +3395,10 @@ buf_daemon()
|
||||
/*
|
||||
* This process needs to be suspended prior to shutdown sync.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
EVENTHANDLER_REGISTER(shutdown_pre_sync, kthread_shutdown, curthread,
|
||||
SHUTDOWN_PRI_LAST + 100);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Start the buf clean daemons as children threads.
|
||||
@ -3354,7 +3421,9 @@ buf_daemon()
|
||||
bd_request = 0;
|
||||
mtx_unlock(&bdlock);
|
||||
|
||||
#ifndef __rtems__
|
||||
kthread_suspend_check();
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Save speedupreq for this pass and reset to capture new
|
||||
@ -3453,7 +3522,9 @@ flushbufqueues(struct vnode *lvp, struct bufdomain *bd, int target,
|
||||
TAILQ_INSERT_HEAD(&bq->bq_queue, sentinel, b_freelist);
|
||||
BQ_UNLOCK(bq);
|
||||
while (flushed != target) {
|
||||
#ifndef __rtems__
|
||||
maybe_yield();
|
||||
#endif /* __rtems__ */
|
||||
BQ_LOCK(bq);
|
||||
bp = TAILQ_NEXT(sentinel, b_freelist);
|
||||
if (bp != NULL) {
|
||||
@ -3532,9 +3603,13 @@ flushbufqueues(struct vnode *lvp, struct bufdomain *bd, int target,
|
||||
if (error == 0) {
|
||||
CTR3(KTR_BUF, "flushbufqueue(%p) vp %p flags %X",
|
||||
bp, bp->b_vp, bp->b_flags);
|
||||
#ifndef __rtems__
|
||||
if (curproc == bufdaemonproc) {
|
||||
vfs_bio_awrite(bp);
|
||||
} else {
|
||||
#else /* __rtems__ */
|
||||
{
|
||||
#endif /* __rtems__ */
|
||||
bremfree(bp);
|
||||
bwrite(bp);
|
||||
counter_u64_add(notbufdflushes, 1);
|
||||
@ -3549,7 +3624,11 @@ flushbufqueues(struct vnode *lvp, struct bufdomain *bd, int target,
|
||||
* Sleeping on runningbufspace while holding
|
||||
* vnode lock leads to deadlock.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if (curproc == bufdaemonproc &&
|
||||
#else /* __rtems__ */
|
||||
if (
|
||||
#endif /* __rtems__ */
|
||||
runningbufspace > hirunningspace)
|
||||
waitrunningbufspace();
|
||||
continue;
|
||||
@ -3587,6 +3666,7 @@ incore(struct bufobj *bo, daddr_t blkno)
|
||||
static int
|
||||
inmem(struct vnode * vp, daddr_t blkno)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_object_t obj;
|
||||
vm_offset_t toff, tinc, size;
|
||||
vm_page_t m;
|
||||
@ -3625,6 +3705,9 @@ inmem(struct vnode * vp, daddr_t blkno)
|
||||
notinmem:
|
||||
VM_OBJECT_RUNLOCK(obj);
|
||||
return (0);
|
||||
#else /* __rtems__ */
|
||||
return 1;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3672,6 +3755,7 @@ vfs_clean_pages_dirty_buf(struct buf *bp)
|
||||
static void
|
||||
vfs_setdirty_locked_object(struct buf *bp)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_object_t object;
|
||||
int i;
|
||||
|
||||
@ -3730,6 +3814,7 @@ vfs_setdirty_locked_object(struct buf *bp)
|
||||
bp->b_dirtyend = eoffset;
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4470,6 +4555,7 @@ bufdone(struct buf *bp)
|
||||
void
|
||||
vfs_unbusy_pages(struct buf *bp)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
int i;
|
||||
vm_object_t obj;
|
||||
vm_page_t m;
|
||||
@ -4498,6 +4584,7 @@ vfs_unbusy_pages(struct buf *bp)
|
||||
}
|
||||
vm_object_pip_wakeupn(obj, bp->b_npages);
|
||||
VM_OBJECT_WUNLOCK(obj);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4511,6 +4598,7 @@ vfs_unbusy_pages(struct buf *bp)
|
||||
static void
|
||||
vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, vm_page_t m)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_ooffset_t eoff;
|
||||
|
||||
/*
|
||||
@ -4529,6 +4617,7 @@ vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, vm_page_t m)
|
||||
*/
|
||||
if (eoff > off)
|
||||
vm_page_set_valid_range(m, off & PAGE_MASK, eoff - off);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4540,6 +4629,7 @@ vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, vm_page_t m)
|
||||
static void
|
||||
vfs_page_set_validclean(struct buf *bp, vm_ooffset_t off, vm_page_t m)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_ooffset_t soff, eoff;
|
||||
|
||||
/*
|
||||
@ -4564,6 +4654,7 @@ vfs_page_set_validclean(struct buf *bp, vm_ooffset_t off, vm_page_t m)
|
||||
(vm_offset_t) (eoff - soff)
|
||||
);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4573,6 +4664,7 @@ vfs_page_set_validclean(struct buf *bp, vm_ooffset_t off, vm_page_t m)
|
||||
void
|
||||
vfs_drain_busy_pages(struct buf *bp)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_page_t m;
|
||||
int i, last_busied;
|
||||
|
||||
@ -4593,6 +4685,7 @@ vfs_drain_busy_pages(struct buf *bp)
|
||||
}
|
||||
for (i = 0; i < last_busied; i++)
|
||||
vm_page_sunbusy(bp->b_pages[i]);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4610,6 +4703,7 @@ vfs_drain_busy_pages(struct buf *bp)
|
||||
void
|
||||
vfs_busy_pages(struct buf *bp, int clear_modify)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_object_t obj;
|
||||
vm_ooffset_t foff;
|
||||
vm_page_t m;
|
||||
@ -4666,6 +4760,7 @@ vfs_busy_pages(struct buf *bp, int clear_modify)
|
||||
pmap_qenter(trunc_page((vm_offset_t)bp->b_data),
|
||||
bp->b_pages, bp->b_npages);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4679,6 +4774,7 @@ vfs_busy_pages(struct buf *bp, int clear_modify)
|
||||
void
|
||||
vfs_bio_set_valid(struct buf *bp, int base, int size)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
int i, n;
|
||||
vm_page_t m;
|
||||
|
||||
@ -4704,6 +4800,7 @@ vfs_bio_set_valid(struct buf *bp, int base, int size)
|
||||
n = PAGE_SIZE;
|
||||
}
|
||||
VM_OBJECT_WUNLOCK(bp->b_bufobj->bo_object);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4721,12 +4818,15 @@ vfs_bio_set_valid(struct buf *bp, int base, int size)
|
||||
void
|
||||
vfs_bio_clrbuf(struct buf *bp)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
int i, j, mask, sa, ea, slide;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
if ((bp->b_flags & (B_VMIO | B_MALLOC)) != B_VMIO) {
|
||||
clrbuf(bp);
|
||||
return;
|
||||
}
|
||||
#ifndef __rtems__
|
||||
bp->b_flags &= ~B_INVAL;
|
||||
bp->b_ioflags &= ~BIO_ERROR;
|
||||
VM_OBJECT_WLOCK(bp->b_bufobj->bo_object);
|
||||
@ -4773,6 +4873,7 @@ vfs_bio_clrbuf(struct buf *bp)
|
||||
unlock:
|
||||
VM_OBJECT_WUNLOCK(bp->b_bufobj->bo_object);
|
||||
bp->b_resid = 0;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
void
|
||||
@ -4785,6 +4886,7 @@ vfs_bio_bzero_buf(struct buf *bp, int base, int size)
|
||||
BUF_CHECK_MAPPED(bp);
|
||||
bzero(bp->b_data + base, size);
|
||||
} else {
|
||||
#ifndef __rtems__
|
||||
BUF_CHECK_UNMAPPED(bp);
|
||||
n = PAGE_SIZE - (base & PAGE_MASK);
|
||||
for (i = base / PAGE_SIZE; size > 0 && i < bp->b_npages; ++i) {
|
||||
@ -4796,6 +4898,7 @@ vfs_bio_bzero_buf(struct buf *bp, int base, int size)
|
||||
size -= n;
|
||||
n = PAGE_SIZE;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
}
|
||||
|
||||
@ -4848,6 +4951,7 @@ vfs_bio_set_flags(struct buf *bp, int ioflag)
|
||||
static void
|
||||
vm_hold_load_pages(struct buf *bp, vm_offset_t from, vm_offset_t to)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_offset_t pg;
|
||||
vm_page_t p;
|
||||
int index;
|
||||
@ -4871,12 +4975,14 @@ vm_hold_load_pages(struct buf *bp, vm_offset_t from, vm_offset_t to)
|
||||
bp->b_pages[index] = p;
|
||||
}
|
||||
bp->b_npages = index;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/* Return pages associated with this buf to the vm system */
|
||||
static void
|
||||
vm_hold_free_pages(struct buf *bp, int newbsize)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_offset_t from;
|
||||
vm_page_t p;
|
||||
int index, newnpages;
|
||||
@ -4895,6 +5001,7 @@ vm_hold_free_pages(struct buf *bp, int newbsize)
|
||||
}
|
||||
vm_wire_sub(bp->b_npages - newnpages);
|
||||
bp->b_npages = newnpages;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4914,6 +5021,7 @@ vm_hold_free_pages(struct buf *bp, int newbsize)
|
||||
int
|
||||
vmapbuf(struct buf *bp, int mapbuf)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_prot_t prot;
|
||||
int pidx;
|
||||
|
||||
@ -4933,6 +5041,7 @@ vmapbuf(struct buf *bp, int mapbuf)
|
||||
bp->b_data = bp->b_kvabase + bp->b_offset;
|
||||
} else
|
||||
bp->b_data = unmapped_buf;
|
||||
#endif /* __rtems__ */
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -4945,6 +5054,7 @@ vmapbuf(struct buf *bp, int mapbuf)
|
||||
void
|
||||
vunmapbuf(struct buf *bp)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
int npages;
|
||||
|
||||
npages = bp->b_npages;
|
||||
@ -4953,6 +5063,7 @@ vunmapbuf(struct buf *bp)
|
||||
vm_page_unhold_pages(bp->b_pages, npages);
|
||||
|
||||
bp->b_data = unmapped_buf;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
void
|
||||
@ -5136,6 +5247,7 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int count,
|
||||
int *rbehind, int *rahead, vbg_get_lblkno_t get_lblkno,
|
||||
vbg_get_blksize_t get_blksize)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_page_t m;
|
||||
vm_object_t object;
|
||||
struct buf *bp;
|
||||
@ -5282,11 +5394,23 @@ end_pages:
|
||||
goto again;
|
||||
VM_OBJECT_WUNLOCK(object);
|
||||
return (error != 0 ? VM_PAGER_ERROR : VM_PAGER_OK);
|
||||
#else /* __rtems__ */
|
||||
return (0);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include <rtems/bsd/local/opt_ddb.h>
|
||||
#ifdef __rtems__
|
||||
#define DB_SHOW_COMMAND(cmd_name, func_name) \
|
||||
void rtems_bsd_cmd_ ## func_name(caddr_t addr, bool have_addr, int count, char* modif)
|
||||
#define db_printf printf
|
||||
#define db_show_buffer rtems_bsd_cmd_db_show_buffer
|
||||
#define DDB
|
||||
#endif /* __rtems__ */
|
||||
#ifdef DDB
|
||||
#ifndef __rtems__
|
||||
#include <ddb/ddb.h>
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* DDB command to show buffer data */
|
||||
DB_SHOW_COMMAND(buffer, db_show_buffer)
|
||||
@ -5322,9 +5446,13 @@ DB_SHOW_COMMAND(buffer, db_show_buffer)
|
||||
vm_page_t m;
|
||||
m = bp->b_pages[i];
|
||||
if (m != NULL)
|
||||
#ifndef __rtems__
|
||||
db_printf("(%p, 0x%lx, 0x%lx)", m->object,
|
||||
(u_long)m->pindex,
|
||||
(u_long)VM_PAGE_TO_PHYS(m));
|
||||
#else /* __rtems__ */
|
||||
db_printf("(%p)", m);
|
||||
#endif /* __rtems__ */
|
||||
else
|
||||
db_printf("( ??? )");
|
||||
if ((i + 1) < bp->b_npages)
|
||||
@ -5421,8 +5549,10 @@ DB_SHOW_COMMAND(lockedbufs, lockedbufs)
|
||||
if (BUF_ISLOCKED(bp)) {
|
||||
db_show_buffer((uintptr_t)bp, 1, 0, NULL);
|
||||
db_printf("\n");
|
||||
#ifndef __rtems__
|
||||
if (db_pager_quit)
|
||||
break;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5449,6 +5579,7 @@ DB_SHOW_COMMAND(vnodebufs, db_show_vnodebufs)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
DB_COMMAND(countfreebufs, db_coundfreebufs)
|
||||
{
|
||||
struct buf *bp;
|
||||
@ -5471,4 +5602,11 @@ DB_COMMAND(countfreebufs, db_coundfreebufs)
|
||||
nfree + used);
|
||||
db_printf("numfreebuffers is %d\n", numfreebuffers);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
#endif /* DDB */
|
||||
#ifdef __rtems__
|
||||
void rtems_bsd_bio_dump(void)
|
||||
{
|
||||
rtems_bsd_cmd_bufqueues(0, true, 0, NULL);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -37,8 +39,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_ktrace.h"
|
||||
#include <rtems/bsd/local/opt_ddb.h>
|
||||
#include <rtems/bsd/local/opt_ktrace.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -339,12 +341,14 @@ cache_out_ts(struct namecache *ncp, struct timespec *tsp, int *ticksp)
|
||||
}
|
||||
|
||||
static int __read_mostly doingcache = 1; /* 1 => enable the cache */
|
||||
#ifndef __rtems__
|
||||
SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0,
|
||||
"VFS namecache enabled");
|
||||
|
||||
/* Export size information to userland */
|
||||
SYSCTL_INT(_debug_sizeof, OID_AUTO, namecache, CTLFLAG_RD, SYSCTL_NULL_INT_PTR,
|
||||
sizeof(struct namecache), "sizeof(struct namecache)");
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* The new name cache statistics
|
||||
@ -397,10 +401,12 @@ static void
|
||||
cache_maybe_yield(void)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
if (should_yield()) {
|
||||
cache_yield++;
|
||||
kern_yield(PRI_USER);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -1918,7 +1924,11 @@ nchinit(void *dummy __unused)
|
||||
numfullpathfail4 = counter_u64_alloc(M_WAITOK);
|
||||
numfullpathfound = counter_u64_alloc(M_WAITOK);
|
||||
}
|
||||
#ifndef __rtems__
|
||||
SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nchinit, NULL);
|
||||
#else /* __rtems__ */
|
||||
SYSINIT(vfs_c, SI_SUB_VFS, SI_ORDER_SECOND, nchinit, NULL);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
void
|
||||
cache_changesize(int newmaxvnodes)
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -36,7 +38,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_debug_cluster.h"
|
||||
#include <rtems/bsd/local/opt_debug_cluster.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -254,7 +256,9 @@ cluster_read(struct vnode *vp, u_quad_t filesize, daddr_t lblkno, long size,
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
}
|
||||
#endif /* RACCT */
|
||||
#ifndef __rtems__
|
||||
td->td_ru.ru_inblock++;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -314,7 +318,9 @@ cluster_read(struct vnode *vp, u_quad_t filesize, daddr_t lblkno, long size,
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
}
|
||||
#endif /* RACCT */
|
||||
#ifndef __rtems__
|
||||
td->td_ru.ru_inblock++;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
if (reqbp) {
|
||||
@ -447,6 +453,7 @@ cluster_rbuild(struct vnode *vp, u_quad_t filesize, daddr_t lbn,
|
||||
* take part in the cluster. If it is partially valid
|
||||
* then we stop.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
off = tbp->b_offset;
|
||||
tsize = size;
|
||||
VM_OBJECT_WLOCK(tbp->b_bufobj->bo_object);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -46,13 +48,15 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/lock.h>
|
||||
#ifndef __rtems__
|
||||
#include <sys/lockf.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <rtems/bsd/sys/unistd.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/dirent.h>
|
||||
#include <sys/poll.h>
|
||||
@ -66,7 +70,9 @@ __FBSDID("$FreeBSD$");
|
||||
#include <vm/vm_map.h>
|
||||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_pager.h>
|
||||
#ifndef __rtems__
|
||||
#include <vm/vnode_pager.h>
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int vop_nolookup(struct vop_lookup_args *);
|
||||
static int vop_norename(struct vop_rename_args *);
|
||||
@ -401,6 +407,7 @@ vop_stdaccessx(struct vop_accessx_args *ap)
|
||||
int
|
||||
vop_stdadvlock(struct vop_advlock_args *ap)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct vnode *vp;
|
||||
struct vattr vattr;
|
||||
int error;
|
||||
@ -422,11 +429,15 @@ vop_stdadvlock(struct vop_advlock_args *ap)
|
||||
vattr.va_size = 0;
|
||||
|
||||
return (lf_advlock(ap, &(vp->v_lockf), vattr.va_size));
|
||||
#else /* __rtems__ */
|
||||
return (EINVAL);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
int
|
||||
vop_stdadvlockasync(struct vop_advlockasync_args *ap)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct vnode *vp;
|
||||
struct vattr vattr;
|
||||
int error;
|
||||
@ -443,16 +454,23 @@ vop_stdadvlockasync(struct vop_advlockasync_args *ap)
|
||||
vattr.va_size = 0;
|
||||
|
||||
return (lf_advlockasync(ap, &(vp->v_lockf), vattr.va_size));
|
||||
#else /* __rtems__ */
|
||||
return (EINVAL);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
int
|
||||
vop_stdadvlockpurge(struct vop_advlockpurge_args *ap)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct vnode *vp;
|
||||
|
||||
vp = ap->a_vp;
|
||||
lf_purgelocks(vp, &vp->v_lockf);
|
||||
return (0);
|
||||
#else /* __rtems__ */
|
||||
return (EINVAL);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -670,20 +688,28 @@ vop_stdgetpages(ap)
|
||||
int *a_rahead;
|
||||
} */ *ap;
|
||||
{
|
||||
#ifndef __rtems__
|
||||
|
||||
return vnode_pager_generic_getpages(ap->a_vp, ap->a_m,
|
||||
ap->a_count, ap->a_rbehind, ap->a_rahead, NULL, NULL);
|
||||
#else /* __rtems__ */
|
||||
return EINVAL;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static int
|
||||
vop_stdgetpages_async(struct vop_getpages_async_args *ap)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
int error;
|
||||
|
||||
error = VOP_GETPAGES(ap->a_vp, ap->a_m, ap->a_count, ap->a_rbehind,
|
||||
ap->a_rahead);
|
||||
ap->a_iodone(ap->a_arg, ap->a_m, ap->a_count, error);
|
||||
return (error);
|
||||
#else /* __rtems__ */
|
||||
return EINVAL;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
int
|
||||
@ -703,9 +729,13 @@ vop_stdputpages(ap)
|
||||
int *a_rtvals;
|
||||
} */ *ap;
|
||||
{
|
||||
#ifndef __rtems__
|
||||
|
||||
return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
|
||||
ap->a_sync, ap->a_rtvals);
|
||||
#else /* __rtems__ */
|
||||
return EINVAL;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
int
|
||||
@ -962,8 +992,10 @@ vop_stdallocate(struct vop_allocate_args *ap)
|
||||
offset += cur;
|
||||
if (len == 0)
|
||||
break;
|
||||
#ifndef __rtems__
|
||||
if (should_yield())
|
||||
break;
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
out:
|
||||
@ -984,6 +1016,7 @@ vop_stdadvise(struct vop_advise_args *ap)
|
||||
|
||||
vp = ap->a_vp;
|
||||
switch (ap->a_advice) {
|
||||
#ifndef __rtems__
|
||||
case POSIX_FADV_WILLNEED:
|
||||
/*
|
||||
* Do nothing for now. Filesystems should provide a
|
||||
@ -1026,6 +1059,7 @@ vop_stdadvise(struct vop_advise_args *ap)
|
||||
BO_RUNLOCK(bo);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
break;
|
||||
#endif /* __rtems__ */
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -39,8 +41,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_inet6.h"
|
||||
#include <rtems/bsd/local/opt_inet.h>
|
||||
#include <rtems/bsd/local/opt_inet6.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -61,7 +63,12 @@ __FBSDID("$FreeBSD$");
|
||||
#include <netinet/in.h>
|
||||
#include <net/radix.h>
|
||||
|
||||
#ifndef __rtems__
|
||||
static MALLOC_DEFINE(M_NETADDR, "export_host", "Export host address structure");
|
||||
#else /* __rtems__ */
|
||||
static MALLOC_DEFINE(M_NETADDR_e, "export_host", "Export host address structure");
|
||||
#define M_NETADDR M_NETADDR_e
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#if defined(INET) || defined(INET6)
|
||||
static struct radix_node_head *vfs_create_addrlist_af(
|
||||
@ -119,11 +126,13 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep,
|
||||
* with fields like cr_uidinfo and cr_prison? Currently, this
|
||||
* routine does not touch them (leaves them as NULL).
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if (argp->ex_anon.cr_version != XUCRED_VERSION) {
|
||||
vfs_mount_error(mp, "ex_anon.cr_version: %d != %d",
|
||||
argp->ex_anon.cr_version, XUCRED_VERSION);
|
||||
return (EINVAL);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
if (argp->ex_addrlen == 0) {
|
||||
if (mp->mnt_flag & MNT_DEFEXPORTED) {
|
||||
@ -134,11 +143,13 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep,
|
||||
np = &nep->ne_defexported;
|
||||
np->netc_exflags = argp->ex_flags;
|
||||
np->netc_anon = crget();
|
||||
#ifndef __rtems__
|
||||
np->netc_anon->cr_uid = argp->ex_anon.cr_uid;
|
||||
crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups,
|
||||
argp->ex_anon.cr_groups);
|
||||
np->netc_anon->cr_prison = &prison0;
|
||||
prison_hold(np->netc_anon->cr_prison);
|
||||
#endif /* __rtems__ */
|
||||
np->netc_numsecflavors = argp->ex_numsecflavors;
|
||||
bcopy(argp->ex_secflavors, np->netc_secflavors,
|
||||
sizeof(np->netc_secflavors));
|
||||
@ -213,11 +224,13 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep,
|
||||
}
|
||||
np->netc_exflags = argp->ex_flags;
|
||||
np->netc_anon = crget();
|
||||
#ifndef __rtems__
|
||||
np->netc_anon->cr_uid = argp->ex_anon.cr_uid;
|
||||
crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups,
|
||||
argp->ex_anon.cr_groups);
|
||||
np->netc_anon->cr_prison = &prison0;
|
||||
prison_hold(np->netc_anon->cr_prison);
|
||||
#endif /* __rtems__ */
|
||||
np->netc_numsecflavors = argp->ex_numsecflavors;
|
||||
bcopy(argp->ex_secflavors, np->netc_secflavors,
|
||||
sizeof(np->netc_secflavors));
|
||||
@ -525,4 +538,3 @@ vfs_stdcheckexp(struct mount *mp, struct sockaddr *nam, int *extflagsp,
|
||||
lockmgr(&mp->mnt_explock, LK_RELEASE, NULL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
@ -491,6 +493,8 @@ kern_extattr_get_path(struct thread *td, const char *path, int attrnamespace,
|
||||
* References: vp must be a valid reference for the duration of the call
|
||||
*/
|
||||
static int
|
||||
|
||||
|
||||
extattr_delete_vp(struct vnode *vp, int attrnamespace, const char *attrname,
|
||||
struct thread *td)
|
||||
{
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -69,7 +71,11 @@ int maxvfsconf = VFS_GENERIC + 1;
|
||||
*/
|
||||
struct vfsconfhead vfsconf = TAILQ_HEAD_INITIALIZER(vfsconf);
|
||||
struct sx vfsconf_sx;
|
||||
#ifndef __rtems__
|
||||
SX_SYSINIT(vfsconf, &vfsconf_sx, "vfsconf");
|
||||
#else /* __rtems__ */
|
||||
SX_SYSINIT_FLAGS(vfsconf, &vfsconf_sx, "vfsconf", SX_RECURSE);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Loader.conf variable vfs.typenumhash enables setting vfc_typenum using a hash
|
||||
@ -147,18 +153,22 @@ vfs_byname_kld(const char *fstype, struct thread *td, int *error)
|
||||
return (vfsp);
|
||||
|
||||
/* Try to load the respective module. */
|
||||
#ifndef __rtems__
|
||||
*error = kern_kldload(td, fstype, &fileid);
|
||||
loaded = (*error == 0);
|
||||
if (*error == EEXIST)
|
||||
*error = 0;
|
||||
if (*error)
|
||||
return (NULL);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* Look up again to see if the VFS was loaded. */
|
||||
vfsp = vfs_byname(fstype);
|
||||
if (vfsp == NULL) {
|
||||
#ifndef __rtems__
|
||||
if (loaded)
|
||||
(void)kern_kldunload(td, fileid, LINKER_UNLOAD_FORCE);
|
||||
#endif /* __rtems__ */
|
||||
*error = ENODEV;
|
||||
return (NULL);
|
||||
}
|
||||
@ -278,8 +288,10 @@ vfs_register(struct vfsconf *vfc)
|
||||
if (vfsops->vfs_sysctl == NULL)
|
||||
vfsops->vfs_sysctl = vfs_stdsysctl;
|
||||
|
||||
#ifndef __rtems__
|
||||
if (vfc->vfc_flags & VFCF_JAIL)
|
||||
prison_add_vfs(vfc);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Call init function for this VFS...
|
||||
@ -297,6 +309,7 @@ vfs_register(struct vfsconf *vfc)
|
||||
* preserved by re-registering the oid after modifying its
|
||||
* number.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
sysctl_wlock();
|
||||
SLIST_FOREACH(oidp, SYSCTL_CHILDREN(&sysctl___vfs), oid_link) {
|
||||
if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) {
|
||||
@ -307,6 +320,7 @@ vfs_register(struct vfsconf *vfc)
|
||||
}
|
||||
}
|
||||
sysctl_wunlock();
|
||||
#endif /* __rtems__ */
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -39,8 +41,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_capsicum.h"
|
||||
#include "opt_ktrace.h"
|
||||
#include <rtems/bsd/local/opt_capsicum.h>
|
||||
#include <rtems/bsd/local/opt_ktrace.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -158,7 +160,11 @@ nameiinit(void *dummy __unused)
|
||||
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
|
||||
getnewvnode("crossmp", NULL, &crossmp_vnodeops, &vp_crossmp);
|
||||
}
|
||||
#ifndef __rtems__
|
||||
SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL);
|
||||
#else /* __rtems__ */
|
||||
SYSINIT(vfs_l, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int lookup_cap_dotdot = 1;
|
||||
SYSCTL_INT(_vfs, OID_AUTO, lookup_cap_dotdot, CTLFLAG_RWTUN,
|
||||
@ -557,6 +563,7 @@ static int
|
||||
compute_cn_lkflags(struct mount *mp, int lkflags, int cnflags)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
if (mp == NULL || ((lkflags & LK_SHARED) &&
|
||||
(!(mp->mnt_kern_flag & MNTK_LOOKUP_SHARED) ||
|
||||
((cnflags & ISDOTDOT) &&
|
||||
@ -565,6 +572,7 @@ compute_cn_lkflags(struct mount *mp, int lkflags, int cnflags)
|
||||
lkflags |= LK_EXCLUSIVE;
|
||||
}
|
||||
lkflags |= LK_NODDLKTREAT;
|
||||
#endif /* __rtems__ */
|
||||
return (lkflags);
|
||||
}
|
||||
|
||||
@ -820,10 +828,14 @@ dirloop:
|
||||
goto bad;
|
||||
}
|
||||
for (;;) {
|
||||
#ifndef __rtems__
|
||||
for (pr = cnp->cn_cred->cr_prison; pr != NULL;
|
||||
pr = pr->pr_parent)
|
||||
if (dp == pr->pr_root)
|
||||
break;
|
||||
#else /* __rtems__ */
|
||||
pr = NULL;
|
||||
#endif /* __rtems__ */
|
||||
if (dp == ndp->ni_rootdir ||
|
||||
dp == ndp->ni_topdir ||
|
||||
dp == rootvnode ||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -796,16 +798,22 @@ sys_mount(struct thread *td, struct mount_args *uap)
|
||||
*/
|
||||
flags &= ~MNT_ROOTFS;
|
||||
|
||||
#ifndef __rtems__
|
||||
fstype = malloc(MFSNAMELEN, M_TEMP, M_WAITOK);
|
||||
error = copyinstr(uap->type, fstype, MFSNAMELEN, NULL);
|
||||
if (error) {
|
||||
free(fstype, M_TEMP);
|
||||
return (error);
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
fstype = uap->type;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
AUDIT_ARG_TEXT(fstype);
|
||||
vfsp = vfs_byname_kld(fstype, td, &error);
|
||||
#ifndef __rtems__
|
||||
free(fstype, M_TEMP);
|
||||
#endif /* __rtems__ */
|
||||
if (vfsp == NULL)
|
||||
return (ENOENT);
|
||||
if (vfsp->vfc_vfsops->vfs_cmount == NULL)
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -43,8 +45,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_watchdog.h"
|
||||
#include <rtems/bsd/local/opt_ddb.h>
|
||||
#include <rtems/bsd/local/opt_watchdog.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -57,14 +59,18 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/dirent.h>
|
||||
#include <sys/event.h>
|
||||
#include <sys/eventhandler.h>
|
||||
#ifndef __rtems__
|
||||
#include <sys/extattr.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/file.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/kdb.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/kthread.h>
|
||||
#ifndef __rtems__
|
||||
#include <sys/lockf.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/namei.h>
|
||||
@ -388,6 +394,7 @@ out:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
sysctl_ftry_reclaim_vnode(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
@ -427,6 +434,7 @@ SYSCTL_PROC(_debug, OID_AUTO, ftry_reclaim_vnode,
|
||||
CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_WR, NULL, 0,
|
||||
sysctl_ftry_reclaim_vnode, "I",
|
||||
"Try to reclaim a vnode by its file descriptor");
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* Shift count for (uintptr_t)vp to initialize vp->v_hash. */
|
||||
static int vnsz2log;
|
||||
@ -492,7 +500,9 @@ vnode_init(void *mem, int size, int flags)
|
||||
/*
|
||||
* Initialize rangelocks.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
rangelock_init(&vp->v_rl);
|
||||
#endif /* __rtems__ */
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -506,7 +516,9 @@ vnode_fini(void *mem, int size)
|
||||
struct bufobj *bo;
|
||||
|
||||
vp = mem;
|
||||
#ifndef __rtems__
|
||||
rangelock_destroy(&vp->v_rl);
|
||||
#endif /* __rtems__ */
|
||||
lockdestroy(vp->v_vnlock);
|
||||
mtx_destroy(&vp->v_interlock);
|
||||
bo = &vp->v_bufobj;
|
||||
@ -551,10 +563,18 @@ vntblinit(void *dummy __unused)
|
||||
* size. The memory required by desiredvnodes vnodes and vm objects
|
||||
* must not exceed 1/10th of the kernel's heap size.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
physvnodes = maxproc + pgtok(vm_cnt.v_page_count) / 64 +
|
||||
3 * min(98304 * 16, pgtok(vm_cnt.v_page_count)) / 64;
|
||||
virtvnodes = vm_kmem_size / (10 * (sizeof(struct vm_object) +
|
||||
sizeof(struct vnode) + NC_SZ * ncsizefactor + NFS_NCLNODE_SZ));
|
||||
#else /* __rtems__ */
|
||||
/*
|
||||
* Make a fixed number until someone decided on a better solution for RTEMS
|
||||
*/
|
||||
physvnodes = 128;
|
||||
virtvnodes = 128;
|
||||
#endif /* __rtems__ */
|
||||
desiredvnodes = min(physvnodes, virtvnodes);
|
||||
if (desiredvnodes > MAXVNODES_MAX) {
|
||||
if (bootverbose)
|
||||
@ -1005,7 +1025,11 @@ vlrureclaim(struct mount *mp, bool reclaim_nc_src, int trigger)
|
||||
(!reclaim_nc_src && !LIST_EMPTY(&vp->v_cache_src)) ||
|
||||
((vp->v_iflag & VI_FREE) != 0) ||
|
||||
(vp->v_iflag & VI_DOOMED) != 0 || (vp->v_object != NULL &&
|
||||
#ifndef __rtems__
|
||||
vp->v_object->resident_page_count > trigger)) {
|
||||
#else /* __rtems__ */
|
||||
false)) {
|
||||
#endif /* __rtems__ */
|
||||
VI_UNLOCK(vp);
|
||||
goto next_iter;
|
||||
}
|
||||
@ -1032,7 +1056,11 @@ vlrureclaim(struct mount *mp, bool reclaim_nc_src, int trigger)
|
||||
(!reclaim_nc_src && !LIST_EMPTY(&vp->v_cache_src)) ||
|
||||
(vp->v_iflag & VI_FREE) != 0 ||
|
||||
(vp->v_object != NULL &&
|
||||
#ifndef __rtems__
|
||||
vp->v_object->resident_page_count > trigger)) {
|
||||
#else /* __rtems__ */
|
||||
false)) {
|
||||
#endif /* __rtems__ */
|
||||
VOP_UNLOCK(vp, LK_INTERLOCK);
|
||||
vdrop(vp);
|
||||
goto next_iter_mntunlocked;
|
||||
@ -1045,15 +1073,21 @@ vlrureclaim(struct mount *mp, bool reclaim_nc_src, int trigger)
|
||||
vdropl(vp);
|
||||
done++;
|
||||
next_iter_mntunlocked:
|
||||
#ifndef __rtems__
|
||||
if (!should_yield())
|
||||
goto relock_mnt;
|
||||
#endif /* __rtems__ */
|
||||
goto yield;
|
||||
next_iter:
|
||||
#ifndef __rtems__
|
||||
if (!should_yield())
|
||||
continue;
|
||||
#endif /* __rtems__ */
|
||||
MNT_IUNLOCK(mp);
|
||||
yield:
|
||||
#ifndef __rtems__
|
||||
kern_yield(PRI_USER);
|
||||
#endif /* __rtems__ */
|
||||
relock_mnt:
|
||||
MNT_ILOCK(mp);
|
||||
}
|
||||
@ -1247,12 +1281,16 @@ vnlru_proc(void)
|
||||
int done, force, trigger, usevnodes, vsp;
|
||||
bool reclaim_nc_src;
|
||||
|
||||
#ifndef __rtems__
|
||||
EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, vnlruproc,
|
||||
SHUTDOWN_PRI_FIRST);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
force = 0;
|
||||
for (;;) {
|
||||
#ifndef __rtems__
|
||||
kproc_suspend_check(vnlruproc);
|
||||
#endif /* __rtems__ */
|
||||
mtx_lock(&vnode_free_list_mtx);
|
||||
/*
|
||||
* If numvnodes is too large (due to desiredvnodes being
|
||||
@ -1304,7 +1342,11 @@ vnlru_proc(void)
|
||||
* misconfigured cases, and this is necessary. Normally
|
||||
* it is about 8 to 100 (pages), which is quite large.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
trigger = vm_cnt.v_page_count * 2 / usevnodes;
|
||||
#else /* __rtems__ */
|
||||
trigger = 32000 / usevnodes;
|
||||
#endif /* __rtems__ */
|
||||
if (force < 2)
|
||||
trigger = vsmalltrigger;
|
||||
reclaim_nc_src = force >= 3;
|
||||
@ -1789,6 +1831,7 @@ bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo)
|
||||
*/
|
||||
do {
|
||||
bufobj_wwait(bo, 0, 0);
|
||||
#ifndef __rtems__
|
||||
if ((flags & V_VMIO) == 0) {
|
||||
BO_UNLOCK(bo);
|
||||
if (bo->bo_object != NULL) {
|
||||
@ -1798,12 +1841,14 @@ bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo)
|
||||
}
|
||||
BO_LOCK(bo);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
} while (bo->bo_numoutput > 0);
|
||||
BO_UNLOCK(bo);
|
||||
|
||||
/*
|
||||
* Destroy the copy in the VM cache, too.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if (bo->bo_object != NULL &&
|
||||
(flags & (V_ALT | V_NORMAL | V_CLEANONLY | V_VMIO)) == 0) {
|
||||
VM_OBJECT_WLOCK(bo->bo_object);
|
||||
@ -1811,6 +1856,7 @@ bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo)
|
||||
OBJPR_CLEANONLY : 0);
|
||||
VM_OBJECT_WUNLOCK(bo->bo_object);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef INVARIANTS
|
||||
BO_LOCK(bo);
|
||||
@ -1836,8 +1882,10 @@ vinvalbuf(struct vnode *vp, int flags, int slpflag, int slptimeo)
|
||||
|
||||
CTR3(KTR_VFS, "%s: vp %p with flags %d", __func__, vp, flags);
|
||||
ASSERT_VOP_LOCKED(vp, "vinvalbuf");
|
||||
#ifndef __rtems__
|
||||
if (vp->v_object != NULL && vp->v_object->handle != vp)
|
||||
return (0);
|
||||
#endif /* __rtems__ */
|
||||
return (bufobj_invalbuf(&vp->v_bufobj, flags, slpflag, slptimeo));
|
||||
}
|
||||
|
||||
@ -2005,7 +2053,9 @@ restartsync:
|
||||
|
||||
bufobj_wwait(bo, 0, 0);
|
||||
BO_UNLOCK(bo);
|
||||
#ifndef __rtems__
|
||||
vnode_pager_setsize(vp, length);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -2354,15 +2404,19 @@ sched_sync(void)
|
||||
starttime = time_uptime;
|
||||
td->td_pflags |= TDP_NORUNNINGBUF;
|
||||
|
||||
#ifndef __rtems__
|
||||
EVENTHANDLER_REGISTER(shutdown_pre_sync, syncer_shutdown, td->td_proc,
|
||||
SHUTDOWN_PRI_LAST);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
mtx_lock(&sync_mtx);
|
||||
for (;;) {
|
||||
if (syncer_state == SYNCER_FINAL_DELAY &&
|
||||
syncer_final_iter == 0) {
|
||||
mtx_unlock(&sync_mtx);
|
||||
#ifndef __rtems__
|
||||
kproc_suspend_check(td->td_proc);
|
||||
#endif /* __rtems__ */
|
||||
mtx_lock(&sync_mtx);
|
||||
}
|
||||
net_worklist_len = syncer_worklist_len - sync_vnode_count;
|
||||
@ -2427,7 +2481,9 @@ sched_sync(void)
|
||||
* drivers need to sleep while patting
|
||||
*/
|
||||
mtx_unlock(&sync_mtx);
|
||||
#ifndef __rtems__
|
||||
wdog_kern_pat(WD_LASTVAL);
|
||||
#endif /* __rtems__ */
|
||||
mtx_lock(&sync_mtx);
|
||||
}
|
||||
|
||||
@ -2460,12 +2516,14 @@ sched_sync(void)
|
||||
* matter as we are just trying to generally pace the
|
||||
* filesystem activity.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if (syncer_state != SYNCER_RUNNING ||
|
||||
time_uptime == starttime) {
|
||||
thread_lock(td);
|
||||
sched_prio(td, PPAUSE);
|
||||
thread_unlock(td);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
if (syncer_state != SYNCER_RUNNING)
|
||||
cv_timedwait(&sync_wakeup, &sync_mtx,
|
||||
hz / SYNCER_SHUTDOWN_SPEEDUP);
|
||||
@ -3127,8 +3185,10 @@ _vdrop(struct vnode *vp, bool locked)
|
||||
VNASSERT(TAILQ_EMPTY(&vp->v_cache_dst), vp, ("vp has namecache dst"));
|
||||
VNASSERT(LIST_EMPTY(&vp->v_cache_src), vp, ("vp has namecache src"));
|
||||
VNASSERT(vp->v_cache_dd == NULL, vp, ("vp has namecache for .."));
|
||||
#ifndef __rtems__
|
||||
VNASSERT(TAILQ_EMPTY(&vp->v_rl.rl_waiters), vp,
|
||||
("Dangling rangelock waiters"));
|
||||
#endif /* __rtems__ */
|
||||
VI_UNLOCK(vp);
|
||||
#ifdef MAC
|
||||
mac_vnode_destroy(vp);
|
||||
@ -3181,12 +3241,14 @@ vinactive(struct vnode *vp, struct thread *td)
|
||||
* point that VOP_INACTIVE() is called, there could still be
|
||||
* pending I/O and dirty pages in the object.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if ((obj = vp->v_object) != NULL && (vp->v_vflag & VV_NOSYNC) == 0 &&
|
||||
(obj->flags & OBJ_MIGHTBEDIRTY) != 0) {
|
||||
VM_OBJECT_WLOCK(obj);
|
||||
vm_object_page_clean(obj, 0, 0, 0);
|
||||
VM_OBJECT_WUNLOCK(obj);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
VOP_INACTIVE(vp, td);
|
||||
VI_LOCK(vp);
|
||||
VNASSERT(vp->v_iflag & VI_DOINGINACT, vp,
|
||||
@ -3266,9 +3328,11 @@ loop:
|
||||
*/
|
||||
if (flags & WRITECLOSE) {
|
||||
if (vp->v_object != NULL) {
|
||||
#ifndef __rtems__
|
||||
VM_OBJECT_WLOCK(vp->v_object);
|
||||
vm_object_page_clean(vp->v_object, 0, 0, 0);
|
||||
VM_OBJECT_WUNLOCK(vp->v_object);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
error = VOP_FSYNC(vp, MNT_WAIT, td);
|
||||
if (error != 0) {
|
||||
@ -3490,7 +3554,11 @@ vgonel(struct vnode *vp)
|
||||
VI_UNLOCK(vp);
|
||||
}
|
||||
if (vp->v_type == VSOCK)
|
||||
#ifndef __rtems__
|
||||
vfs_unp_reclaim(vp);
|
||||
#else /* __rtems__ */
|
||||
panic("vgonel with sock");
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Clean out any buffers associated with the vnode.
|
||||
@ -3671,6 +3739,7 @@ vn_printf(struct vnode *vp, const char *fmt, ...)
|
||||
printf(" flags (%s)\n", buf + 1);
|
||||
if (mtx_owned(VI_MTX(vp)))
|
||||
printf(" VI_LOCKed");
|
||||
#ifndef __rtems__
|
||||
if (vp->v_object != NULL)
|
||||
printf(" v_object %p ref %d pages %d "
|
||||
"cleanbuf %d dirtybuf %d\n",
|
||||
@ -3678,6 +3747,7 @@ vn_printf(struct vnode *vp, const char *fmt, ...)
|
||||
vp->v_object->resident_page_count,
|
||||
vp->v_bufobj.bo_clean.bv_cnt,
|
||||
vp->v_bufobj.bo_dirty.bv_cnt);
|
||||
#endif /* __rtems__ */
|
||||
printf(" ");
|
||||
lockmgr_printinfo(vp->v_vnlock);
|
||||
if (vp->v_data != NULL)
|
||||
@ -4216,6 +4286,7 @@ vfs_unmountall(void)
|
||||
void
|
||||
vfs_msync(struct mount *mp, int flags)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct vnode *vp, *mvp;
|
||||
struct vm_object *obj;
|
||||
|
||||
@ -4248,6 +4319,7 @@ vfs_msync(struct mount *mp, int flags)
|
||||
} else
|
||||
VI_UNLOCK(vp);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4452,10 +4524,14 @@ sync_fsync(struct vop_fsync_args *ap)
|
||||
vfs_unbusy(mp);
|
||||
return (0);
|
||||
}
|
||||
#ifndef __rtems__
|
||||
save = curthread_pflags_set(TDP_SYNCIO);
|
||||
#endif /* __rtems__ */
|
||||
vfs_msync(mp, MNT_NOWAIT);
|
||||
error = VFS_SYNC(mp, MNT_LAZY);
|
||||
#ifndef __rtems__
|
||||
curthread_pflags_restore(save);
|
||||
#endif /* __rtems__ */
|
||||
vn_finished_write(mp);
|
||||
vfs_unbusy(mp);
|
||||
return (error);
|
||||
@ -4656,6 +4732,7 @@ int
|
||||
extattr_check_cred(struct vnode *vp, int attrnamespace, struct ucred *cred,
|
||||
struct thread *td, accmode_t accmode)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
|
||||
/*
|
||||
* Kernel-invoked always succeeds.
|
||||
@ -4676,6 +4753,9 @@ extattr_check_cred(struct vnode *vp, int attrnamespace, struct ucred *cred,
|
||||
default:
|
||||
return (EPERM);
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
return (0);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
#ifdef DEBUG_VFS_LOCKS
|
||||
@ -5438,8 +5518,10 @@ __mnt_vnode_next_all(struct vnode **mvp, struct mount *mp)
|
||||
{
|
||||
struct vnode *vp;
|
||||
|
||||
#ifndef __rtems__
|
||||
if (should_yield())
|
||||
kern_yield(PRI_USER);
|
||||
#endif /* __rtems__ */
|
||||
MNT_ILOCK(mp);
|
||||
KASSERT((*mvp)->v_mount == mp, ("marker vnode mount list mismatch"));
|
||||
for (vp = TAILQ_NEXT(*mvp, v_nmntvnodes); vp != NULL;
|
||||
@ -5664,8 +5746,10 @@ struct vnode *
|
||||
__mnt_vnode_next_active(struct vnode **mvp, struct mount *mp)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
if (should_yield())
|
||||
kern_yield(PRI_USER);
|
||||
#endif /* __rtems__ */
|
||||
mtx_lock(&mp->mnt_listmtx);
|
||||
return (mnt_vnode_next_active(mvp, mp));
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -39,8 +41,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_capsicum.h"
|
||||
#include "opt_ktrace.h"
|
||||
#include <rtems/bsd/local/opt_capsicum.h>
|
||||
#include <rtems/bsd/local/opt_ktrace.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -65,7 +67,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/sdt.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <rtems/bsd/sys/unistd.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/proc.h>
|
||||
@ -87,7 +89,9 @@ __FBSDID("$FreeBSD$");
|
||||
#include <vm/vm_page.h>
|
||||
#include <vm/uma.h>
|
||||
|
||||
#ifndef __rtems__
|
||||
#include <ufs/ufs/quota.h>
|
||||
#endif /* __rtems__ */
|
||||
|
||||
MALLOC_DEFINE(M_FADVISE, "fadvise", "posix_fadvise(2) information");
|
||||
|
||||
@ -151,6 +155,7 @@ sys_sync(struct thread *td, struct sync_args *uap)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Change filesystem quotas.
|
||||
*/
|
||||
@ -203,6 +208,7 @@ sys_quotactl(struct thread *td, struct quotactl_args *uap)
|
||||
vfs_unbusy(mp);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Used by statfs conversion routines to scale the block size up if
|
||||
@ -904,6 +910,7 @@ kern_chdir(struct thread *td, char *path, enum uio_seg pathseg)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Change notion of root (``/'') directory.
|
||||
*/
|
||||
@ -945,6 +952,7 @@ error:
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Common routine for chroot and chdir. Callers must provide a locked vnode
|
||||
@ -999,8 +1007,10 @@ flags_to_rights(int flags, cap_rights_t *rightsp)
|
||||
if (flags & (O_SYNC | O_FSYNC))
|
||||
cap_rights_set(rightsp, CAP_FSYNC);
|
||||
|
||||
#ifndef __rtems__
|
||||
if (flags & (O_EXLOCK | O_SHLOCK))
|
||||
cap_rights_set(rightsp, CAP_FLOCK);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1061,9 +1071,13 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
* Only one of the O_EXEC, O_RDONLY, O_WRONLY and O_RDWR flags
|
||||
* may be specified.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if (flags & O_EXEC) {
|
||||
if (flags & O_ACCMODE)
|
||||
return (EINVAL);
|
||||
#else /* __rtems__ */
|
||||
if (false) {
|
||||
#endif /* __rtems__ */
|
||||
} else if ((flags & O_ACCMODE) == O_ACCMODE) {
|
||||
return (EINVAL);
|
||||
} else {
|
||||
@ -1083,10 +1097,16 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
*/
|
||||
/* Set the flags early so the finit in devfs can pick them up. */
|
||||
fp->f_flag = flags & FMASK;
|
||||
#ifndef __rtems__
|
||||
cmode = ((mode & ~fdp->fd_cmask) & ALLPERMS) & ~S_ISTXT;
|
||||
#else /* __rtems__ */
|
||||
cmode = (mode & ~fdp->fd_cmask) & ALLPERMS;
|
||||
#endif /* __rtems__ */
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, fd,
|
||||
&rights, td);
|
||||
#ifndef __rtems__
|
||||
td->td_dupfd = -1; /* XXX check for fdopen */
|
||||
#endif /* __rtems__ */
|
||||
error = vn_open(&nd, &flags, cmode, fp);
|
||||
if (error != 0) {
|
||||
/*
|
||||
@ -1106,16 +1126,23 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
*/
|
||||
if ((nd.ni_lcf & NI_LCF_STRICTRELATIVE) == 0 &&
|
||||
(error == ENODEV || error == ENXIO) &&
|
||||
#ifndef __rtems__
|
||||
td->td_dupfd >= 0) {
|
||||
error = dupfdopen(td, fdp, td->td_dupfd, flags, error,
|
||||
&indx);
|
||||
if (error == 0)
|
||||
goto success;
|
||||
#else /* __rtems__ */
|
||||
true) {
|
||||
panic("fdopen() dup");
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
goto bad;
|
||||
}
|
||||
#ifndef __rtems__
|
||||
td->td_dupfd = 0;
|
||||
#endif /* __rtems__ */
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
vp = nd.ni_vp;
|
||||
|
||||
@ -1255,12 +1282,16 @@ kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
if (error == 0 && dev == VNOVAL)
|
||||
error = EINVAL;
|
||||
break;
|
||||
#ifndef __rtems__
|
||||
case S_IFWHT:
|
||||
error = priv_check(td, PRIV_VFS_MKNOD_WHT);
|
||||
break;
|
||||
#endif /* __rtems__ */
|
||||
case S_IFIFO:
|
||||
#ifndef __rtems__
|
||||
if (dev == 0)
|
||||
return (kern_mkfifoat(td, fd, path, pathseg, mode));
|
||||
#endif /* __rtems__ */
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
error = EINVAL;
|
||||
@ -1298,9 +1329,11 @@ restart:
|
||||
case S_IFBLK:
|
||||
vattr.va_type = VBLK;
|
||||
break;
|
||||
#ifndef __rtems__
|
||||
case S_IFWHT:
|
||||
whiteout = 1;
|
||||
break;
|
||||
#endif /* __rtems__ */
|
||||
default:
|
||||
panic("kern_mknod: invalid mode");
|
||||
}
|
||||
@ -1333,6 +1366,7 @@ restart:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Create a named pipe.
|
||||
*/
|
||||
@ -1418,6 +1452,7 @@ out:
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Make a hard file link.
|
||||
@ -1459,15 +1494,19 @@ sys_linkat(struct thread *td, struct linkat_args *uap)
|
||||
}
|
||||
|
||||
int hardlink_check_uid = 0;
|
||||
#ifndef __rtems__
|
||||
SYSCTL_INT(_security_bsd, OID_AUTO, hardlink_check_uid, CTLFLAG_RW,
|
||||
&hardlink_check_uid, 0,
|
||||
"Unprivileged processes cannot create hard links to files owned by other "
|
||||
"users");
|
||||
#endif /* __rtems__ */
|
||||
static int hardlink_check_gid = 0;
|
||||
#ifndef __rtems__
|
||||
SYSCTL_INT(_security_bsd, OID_AUTO, hardlink_check_gid, CTLFLAG_RW,
|
||||
&hardlink_check_gid, 0,
|
||||
"Unprivileged processes cannot create hard links to files owned by other "
|
||||
"groups");
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int
|
||||
can_hardlink(struct vnode *vp, struct ucred *cred)
|
||||
@ -1689,6 +1728,7 @@ out:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Delete a whiteout from the filesystem.
|
||||
*/
|
||||
@ -1735,6 +1775,7 @@ restart:
|
||||
vn_finished_write(mp);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Delete a name from the filesystem.
|
||||
@ -1952,6 +1993,7 @@ sys_access(struct thread *td, struct access_args *uap)
|
||||
0, uap->amode));
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
#ifndef _SYS_SYSPROTO_H_
|
||||
struct faccessat_args {
|
||||
int dirfd;
|
||||
@ -2014,7 +2056,9 @@ out:
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Check access permissions using "effective" credentials.
|
||||
*/
|
||||
@ -2031,7 +2075,9 @@ sys_eaccess(struct thread *td, struct eaccess_args *uap)
|
||||
return (kern_accessat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
|
||||
AT_EACCESS, uap->amode));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
#if defined(COMPAT_43)
|
||||
/*
|
||||
* Get file status; this version follows links.
|
||||
@ -2256,6 +2302,7 @@ freebsd11_fstatat(struct thread *td, struct freebsd11_fstatat_args* uap)
|
||||
return (error);
|
||||
}
|
||||
#endif /* COMPAT_FREEBSD11 */
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Get file status
|
||||
@ -2398,6 +2445,7 @@ freebsd11_nlstat(struct thread *td, struct freebsd11_nlstat_args *uap)
|
||||
}
|
||||
#endif /* COMPAT_FREEBSD11 */
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Get configurable pathname variables.
|
||||
*/
|
||||
@ -2456,6 +2504,7 @@ kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name,
|
||||
vput(nd.ni_vp);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Return target name of a symbolic link.
|
||||
@ -2607,6 +2656,7 @@ sys_chflags(struct thread *td, struct chflags_args *uap)
|
||||
uap->flags, 0));
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
#ifndef _SYS_SYSPROTO_H_
|
||||
struct chflagsat_args {
|
||||
int fd;
|
||||
@ -2695,6 +2745,7 @@ sys_fchflags(struct thread *td, struct fchflags_args *uap)
|
||||
fdrop(fp, td);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Common implementation code for chmod(), lchmod() and fchmod().
|
||||
@ -2954,6 +3005,7 @@ sys_fchown(struct thread *td, struct fchown_args *uap)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Common implementation code for utimes(), lutimes(), and futimes().
|
||||
*/
|
||||
@ -3272,6 +3324,7 @@ kern_utimensat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
vrele(nd.ni_vp);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Truncate a file given its path name.
|
||||
@ -3396,11 +3449,13 @@ kern_fsync(struct thread *td, int fd, bool fullsync)
|
||||
}
|
||||
vn_lock(vp, lock_flags | LK_RETRY);
|
||||
AUDIT_ARG_VNODE1(vp);
|
||||
#ifndef __rtems__
|
||||
if (vp->v_object != NULL) {
|
||||
VM_OBJECT_WLOCK(vp->v_object);
|
||||
vm_object_page_clean(vp->v_object, 0, 0, 0);
|
||||
VM_OBJECT_WUNLOCK(vp->v_object);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
error = fullsync ? VOP_FSYNC(vp, MNT_WAIT, td) : VOP_FDATASYNC(vp, td);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
vn_finished_write(mp);
|
||||
@ -3481,6 +3536,7 @@ again:
|
||||
AUDITVNODE1, pathseg, old, oldfd,
|
||||
&cap_renameat_source_rights, td);
|
||||
#else
|
||||
|
||||
NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART | AUDITVNODE1,
|
||||
pathseg, old, oldfd,
|
||||
&cap_renameat_source_rights, td);
|
||||
@ -4035,6 +4091,7 @@ fail:
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Set the mode mask for creation of filesystem nodes.
|
||||
*/
|
||||
@ -4102,6 +4159,7 @@ out:
|
||||
vput(vp);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Convert a user file descriptor to a kernel file entry and check that, if it
|
||||
@ -4139,6 +4197,7 @@ getvnode(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp)
|
||||
}
|
||||
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Get an (NFS) file handle.
|
||||
*/
|
||||
@ -4515,6 +4574,7 @@ out:
|
||||
vfs_unbusy(mp);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len)
|
||||
@ -4600,6 +4660,7 @@ kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
sys_posix_fallocate(struct thread *td, struct posix_fallocate_args *uap)
|
||||
{
|
||||
@ -4746,3 +4807,4 @@ sys_posix_fadvise(struct thread *td, struct posix_fadvise_args *uap)
|
||||
uap->advice);
|
||||
return (kern_posix_error(td, error));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -45,7 +47,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_hwpmc_hooks.h"
|
||||
#include <rtems/bsd/local/opt_hwpmc_hooks.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -74,7 +76,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/ttycom.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <rtems/bsd/sys/unistd.h>
|
||||
#include <sys/user.h>
|
||||
|
||||
#include <security/audit/audit.h>
|
||||
@ -114,10 +116,14 @@ struct fileops vnops = {
|
||||
.fo_close = vn_closefile,
|
||||
.fo_chmod = vn_chmod,
|
||||
.fo_chown = vn_chown,
|
||||
#ifndef __rtems__
|
||||
.fo_sendfile = vn_sendfile,
|
||||
#endif /* __rtems__ */
|
||||
.fo_seek = vn_seek,
|
||||
#ifndef __rtems__
|
||||
.fo_fill_kinfo = vn_fill_kinfo,
|
||||
.fo_mmap = vn_mmap,
|
||||
#endif /* __rtems__ */
|
||||
.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
|
||||
};
|
||||
|
||||
@ -353,8 +359,10 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred,
|
||||
}
|
||||
if (fmode & FREAD)
|
||||
accmode |= VREAD;
|
||||
#ifndef __rtems__
|
||||
if (fmode & FEXEC)
|
||||
accmode |= VEXEC;
|
||||
#endif /* __rtems__ */
|
||||
if ((fmode & O_APPEND) && (fmode & FWRITE))
|
||||
accmode |= VAPPEND;
|
||||
#ifdef MAC
|
||||
@ -394,7 +402,9 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred,
|
||||
* Arrange for that by having fdrop() to use vn_closefile().
|
||||
*/
|
||||
if (error != 0) {
|
||||
#ifndef __rtems__
|
||||
fp->f_flag |= FOPENFAILED;
|
||||
#endif /* __rtems__ */
|
||||
fp->f_vnode = vp;
|
||||
if (fp->f_ops == &badfileops) {
|
||||
fp->f_type = DTYPE_VNODE;
|
||||
@ -448,7 +458,11 @@ vn_close1(struct vnode *vp, int flags, struct ucred *file_cred,
|
||||
vn_start_write(vp, &mp, V_WAIT);
|
||||
vn_lock(vp, lock_flags | LK_RETRY);
|
||||
AUDIT_ARG_VNODE1(vp);
|
||||
#ifndef __rtems__
|
||||
if ((flags & (FWRITE | FOPENFAILED)) == FWRITE) {
|
||||
#else /* __rtems__ */
|
||||
if ((flags & FWRITE) == FWRITE) {
|
||||
#endif /* __rtems__ */
|
||||
VOP_ADD_WRITECOUNT_CHECKED(vp, -1);
|
||||
CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d",
|
||||
__func__, vp, vp->v_writecount);
|
||||
@ -478,8 +492,10 @@ sequential_heuristic(struct uio *uio, struct file *fp)
|
||||
{
|
||||
|
||||
ASSERT_VOP_LOCKED(fp->f_vnode, __func__);
|
||||
#ifndef __rtems__
|
||||
if (fp->f_flag & FRDAHEAD)
|
||||
return (fp->f_seqcount << IO_SEQSHIFT);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Offset 0 is handled specially. open() sets f_seqcount to 1 so
|
||||
@ -752,6 +768,7 @@ foffset_unlock_uio(struct file *fp, struct uio *uio, int flags)
|
||||
static int
|
||||
get_advice(struct file *fp, struct uio *uio)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct mtx *mtxp;
|
||||
int ret;
|
||||
|
||||
@ -767,6 +784,9 @@ get_advice(struct file *fp, struct uio *uio)
|
||||
ret = fp->f_advice->fa_advice;
|
||||
mtx_unlock(mtxp);
|
||||
return (ret);
|
||||
#else /* __rtems__ */
|
||||
return (POSIX_FADV_NORMAL);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -946,7 +966,9 @@ vn_io_fault_doio(struct vn_io_fault_args *args, struct uio *uio,
|
||||
int error, save;
|
||||
|
||||
error = 0;
|
||||
#ifndef __rtems__
|
||||
save = vm_fault_disable_pagefaults();
|
||||
#endif /* __rtems__ */
|
||||
switch (args->kind) {
|
||||
case VN_IO_FAULT_FOP:
|
||||
error = (args->args.fop_args.doio)(args->args.fop_args.fp,
|
||||
@ -965,24 +987,31 @@ vn_io_fault_doio(struct vn_io_fault_args *args, struct uio *uio,
|
||||
panic("vn_io_fault_doio: unknown kind of io %d %d",
|
||||
args->kind, uio->uio_rw);
|
||||
}
|
||||
#ifndef __rtems__
|
||||
vm_fault_enable_pagefaults(save);
|
||||
#endif /* __rtems__ */
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
vn_io_fault_touch(char *base, const struct uio *uio)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
int r;
|
||||
|
||||
r = fubyte(base);
|
||||
if (r == -1 || (uio->uio_rw == UIO_READ && subyte(base, r) == -1))
|
||||
return (EFAULT);
|
||||
return (0);
|
||||
#else /* __rtems__ */
|
||||
return (EFAULT);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static int
|
||||
vn_io_fault_prefault_user(const struct uio *uio)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
char *base;
|
||||
const struct iovec *iov;
|
||||
size_t len;
|
||||
@ -1020,6 +1049,9 @@ vn_io_fault_prefault_user(const struct uio *uio)
|
||||
}
|
||||
}
|
||||
return (error);
|
||||
#else /* __rtems__ */
|
||||
return (EFAULT);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1042,6 +1074,9 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
|
||||
size_t len, resid;
|
||||
ssize_t adv;
|
||||
int error, cnt, saveheld, prev_td_ma_cnt;
|
||||
#ifdef __rtems__
|
||||
struct uio uio_clone_;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
if (vn_io_fault_prefault) {
|
||||
error = vn_io_fault_prefault_user(uio);
|
||||
@ -1060,7 +1095,12 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
|
||||
* Cache a copy of the original uio, which is advanced to the redo
|
||||
* point using UIO_NOCOPY below.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
uio_clone = cloneuio(uio);
|
||||
#else /* __rtems__ */
|
||||
uio_clone_ = *uio;
|
||||
uio_clone = &uio_clone_;
|
||||
#endif /* __rtems__ */
|
||||
resid = uio->uio_resid;
|
||||
|
||||
short_uio.uio_segflg = UIO_USERSPACE;
|
||||
@ -1076,9 +1116,11 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
|
||||
uiomove(NULL, resid - uio->uio_resid, uio_clone);
|
||||
uio_clone->uio_segflg = uio->uio_segflg;
|
||||
|
||||
#ifndef __rtems__
|
||||
saveheld = curthread_pflags_set(TDP_UIOHELD);
|
||||
prev_td_ma = td->td_ma;
|
||||
prev_td_ma_cnt = td->td_ma_cnt;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
while (uio_clone->uio_resid != 0) {
|
||||
len = uio_clone->uio_iov->iov_len;
|
||||
@ -1098,6 +1140,7 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
|
||||
break;
|
||||
}
|
||||
cnt = atop(end - trunc_page(addr));
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* A perfectly misaligned address and length could cause
|
||||
* both the start and the end of the chunk to use partial
|
||||
@ -1109,16 +1152,21 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
|
||||
error = EFAULT;
|
||||
break;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
short_uio.uio_iov = &short_iovec[0];
|
||||
short_iovec[0].iov_base = (void *)addr;
|
||||
short_uio.uio_iovcnt = 1;
|
||||
short_uio.uio_resid = short_iovec[0].iov_len = len;
|
||||
short_uio.uio_offset = uio_clone->uio_offset;
|
||||
#ifndef __rtems__
|
||||
td->td_ma = ma;
|
||||
td->td_ma_cnt = cnt;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
error = vn_io_fault_doio(args, &short_uio, td);
|
||||
#ifndef __rtems__
|
||||
vm_page_unhold_pages(ma, cnt);
|
||||
#endif /* __rtems__ */
|
||||
adv = len - short_uio.uio_resid;
|
||||
|
||||
uio_clone->uio_iov->iov_base =
|
||||
@ -1133,11 +1181,15 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
|
||||
if (error != 0 || adv == 0)
|
||||
break;
|
||||
}
|
||||
#ifndef __rtems__
|
||||
td->td_ma = prev_td_ma;
|
||||
td->td_ma_cnt = prev_td_ma_cnt;
|
||||
curthread_pflags_restore(saveheld);
|
||||
#endif /* __rtems__ */
|
||||
out:
|
||||
#ifndef __rtems__
|
||||
free(uio_clone, M_IOV);
|
||||
#endif /* __rtems__ */
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1145,6 +1197,7 @@ static int
|
||||
vn_io_fault(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
int flags, struct thread *td)
|
||||
{
|
||||
#ifdef __rtems__
|
||||
fo_rdwr_t *doio;
|
||||
struct vnode *vp;
|
||||
void *rl_cookie;
|
||||
@ -1178,6 +1231,9 @@ vn_io_fault(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
}
|
||||
foffset_unlock_uio(fp, uio, flags);
|
||||
return (error);
|
||||
#else /* __rtems__ */
|
||||
return (EFAULT);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1195,6 +1251,8 @@ vn_io_fault(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
int
|
||||
vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
return (EFAULT);
|
||||
struct uio transp_uio;
|
||||
struct iovec transp_iov[1];
|
||||
struct thread *td;
|
||||
@ -1204,8 +1262,10 @@ vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio)
|
||||
td = curthread;
|
||||
if ((td->td_pflags & TDP_UIOHELD) == 0 ||
|
||||
uio->uio_segflg != UIO_USERSPACE)
|
||||
#endif /* __rtems__ */
|
||||
return (uiomove(data, xfersize, uio));
|
||||
|
||||
#ifndef __rtems__
|
||||
KASSERT(uio->uio_iovcnt == 1, ("uio_iovcnt %d", uio->uio_iovcnt));
|
||||
transp_iov[0].iov_base = data;
|
||||
transp_uio.uio_iov = &transp_iov[0];
|
||||
@ -1246,12 +1306,14 @@ vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio)
|
||||
uio->uio_resid -= adv;
|
||||
uio->uio_offset += adv;
|
||||
return (error);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
int
|
||||
vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
|
||||
struct uio *uio)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct thread *td;
|
||||
vm_offset_t iov_base;
|
||||
int cnt, pgadv;
|
||||
@ -1284,6 +1346,9 @@ vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
|
||||
uio->uio_resid -= cnt;
|
||||
uio->uio_offset += cnt;
|
||||
return (0);
|
||||
#else /* __rtems__ */
|
||||
return (EFAULT);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
|
||||
@ -1440,7 +1505,9 @@ vn_stat(struct vnode *vp, struct stat *sb, struct ucred *active_cred,
|
||||
sb->st_atim = vap->va_atime;
|
||||
sb->st_mtim = vap->va_mtime;
|
||||
sb->st_ctim = vap->va_ctime;
|
||||
#ifndef __rtems__
|
||||
sb->st_birthtim = vap->va_birthtime;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* According to www.opengroup.org, the meaning of st_blksize is
|
||||
@ -1452,11 +1519,13 @@ vn_stat(struct vnode *vp, struct stat *sb, struct ucred *active_cred,
|
||||
|
||||
sb->st_blksize = max(PAGE_SIZE, vap->va_blocksize);
|
||||
|
||||
#ifndef __rtems__
|
||||
sb->st_flags = vap->va_flags;
|
||||
if (priv_check(td, PRIV_VFS_GENERATION))
|
||||
sb->st_gen = 0;
|
||||
else
|
||||
sb->st_gen = vap->va_gen;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
sb->st_blocks = vap->va_bytes / S_BLKSIZE;
|
||||
return (0);
|
||||
@ -1486,6 +1555,7 @@ vn_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
|
||||
if (error == 0)
|
||||
*(int *)data = vattr.va_size - fp->f_offset;
|
||||
return (error);
|
||||
#ifndef __rtems__
|
||||
case FIOBMAP2:
|
||||
bmarg = (struct fiobmap2_arg *)data;
|
||||
vn_lock(vp, LK_SHARED | LK_RETRY);
|
||||
@ -1498,6 +1568,7 @@ vn_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
|
||||
&bmarg->bn, &bmarg->runp, &bmarg->runb);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
return (error);
|
||||
#endif /* __rtems__ */
|
||||
case FIONBIO:
|
||||
case FIOASYNC:
|
||||
return (0);
|
||||
@ -1578,7 +1649,11 @@ vn_closefile(struct file *fp, struct thread *td)
|
||||
|
||||
vp = fp->f_vnode;
|
||||
fp->f_ops = &badfileops;
|
||||
#ifndef __rtems__
|
||||
ref= (fp->f_flag & FHASLOCK) != 0 && fp->f_type == DTYPE_VNODE;
|
||||
#else /* __rtems__ */
|
||||
ref = false;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
error = vn_close1(vp, fp->f_flag, fp->f_cred, td, ref);
|
||||
|
||||
@ -1617,7 +1692,11 @@ vn_start_write_locked(struct mount *mp, int flags)
|
||||
/*
|
||||
* Check on status of suspension.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
if ((curthread->td_pflags & TDP_IGNSUSP) == 0 ||
|
||||
#else /* __rtems__ */
|
||||
if (
|
||||
#endif /* __rtems__ */
|
||||
mp->mnt_susp_owner != curthread) {
|
||||
mflags = ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0 ?
|
||||
(flags & PCATCH) : 0) | (PUSER - 1);
|
||||
@ -1864,7 +1943,9 @@ vfs_write_resume(struct mount *mp, int flags)
|
||||
mp->mnt_susp_owner = NULL;
|
||||
wakeup(&mp->mnt_writeopcount);
|
||||
wakeup(&mp->mnt_flag);
|
||||
#ifndef __rtems__
|
||||
curthread->td_pflags &= ~TDP_IGNSUSP;
|
||||
#endif /* __rtems__ */
|
||||
if ((flags & VR_START_WRITE) != 0) {
|
||||
MNT_REF(mp);
|
||||
mp->mnt_writeopcount++;
|
||||
@ -1910,7 +1991,9 @@ vfs_write_suspend_umnt(struct mount *mp)
|
||||
mp->mnt_kern_flag &= ~(MNTK_SUSPENDED | MNTK_SUSPEND2);
|
||||
wakeup(&mp->mnt_flag);
|
||||
MNT_IUNLOCK(mp);
|
||||
#ifndef __rtems__
|
||||
curthread->td_pflags |= TDP_IGNSUSP;
|
||||
#endif /* __rtems__ */
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -2106,9 +2189,11 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio,
|
||||
return (0);
|
||||
if ((uoff_t)uio->uio_offset + uio->uio_resid >
|
||||
lim_cur(td, RLIMIT_FSIZE)) {
|
||||
#ifndef __rtems__
|
||||
PROC_LOCK(td->td_proc);
|
||||
kern_psignal(td->td_proc, SIGXFSZ);
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
#endif /* __rtems__ */
|
||||
return (EFBIG);
|
||||
}
|
||||
return (0);
|
||||
@ -2147,6 +2232,7 @@ vn_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred,
|
||||
void
|
||||
vn_pages_remove(struct vnode *vp, vm_pindex_t start, vm_pindex_t end)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
vm_object_t object;
|
||||
|
||||
if ((object = vp->v_object) == NULL)
|
||||
@ -2154,6 +2240,7 @@ vn_pages_remove(struct vnode *vp, vm_pindex_t start, vm_pindex_t end)
|
||||
VM_OBJECT_WLOCK(object);
|
||||
vm_object_page_remove(object, start, end, 0);
|
||||
VM_OBJECT_WUNLOCK(object);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
int
|
||||
@ -2386,6 +2473,7 @@ vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
int
|
||||
vn_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size,
|
||||
vm_prot_t prot, vm_prot_t cap_maxprot, int flags, vm_ooffset_t foff,
|
||||
@ -2499,6 +2587,7 @@ vn_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size,
|
||||
#endif
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
void
|
||||
vn_fsid(struct vnode *vp, struct vattr *va)
|
||||
|
@ -407,9 +407,6 @@ struct setfib_args {
|
||||
int fibnum;
|
||||
};
|
||||
#endif
|
||||
#ifdef __rtems__
|
||||
static
|
||||
#endif /* __rtems__ */
|
||||
int
|
||||
sys_setfib(struct thread *td, struct setfib_args *uap)
|
||||
{
|
||||
@ -423,20 +420,6 @@ sys_setfib(struct thread *td, struct setfib_args *uap)
|
||||
#endif /* __rtems__ */
|
||||
return (0);
|
||||
}
|
||||
#ifdef __rtems__
|
||||
int
|
||||
setfib(int fibnum)
|
||||
{
|
||||
struct setfib_args ua = {
|
||||
.fibnum = fibnum
|
||||
};
|
||||
int error;
|
||||
|
||||
error = sys_setfib(NULL, &ua);
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Packet routing routines.
|
||||
@ -2302,4 +2285,3 @@ rt_newaddrmsg_fib(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt,
|
||||
rt_addrmsg(cmd, ifa, fibnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,8 +303,6 @@ SYSCTL_TIMEVAL_SEC(_kern, OID_AUTO, cryptodev_warn_interval, CTLFLAG_RW,
|
||||
&warninterval,
|
||||
"Delay in seconds between warnings of deprecated /dev/crypto algorithms");
|
||||
|
||||
#ifndef __rtems__
|
||||
>>>>>>> e79fbf70f7e... RTEMS
|
||||
static int cryptof_ioctl(struct file *, u_long, void *,
|
||||
struct ucred *, struct thread *);
|
||||
static int cryptof_stat(struct file *, struct stat *,
|
||||
@ -327,9 +325,6 @@ static struct fileops cryptofops = {
|
||||
.fo_sendfile = invfo_sendfile,
|
||||
.fo_fill_kinfo = cryptof_fill_kinfo,
|
||||
};
|
||||
#else /* __rtems__ */
|
||||
static const rtems_filesystem_file_handlers_r cryptofops;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static struct csession *csefind(struct fcrypt *, u_int);
|
||||
static bool csedelete(struct fcrypt *, u_int);
|
||||
@ -773,27 +768,6 @@ bail:
|
||||
return (error);
|
||||
#undef SES2
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_cryptof_ioctl(rtems_libio_t *iop, ioctl_command_t request,
|
||||
void *buffer)
|
||||
{
|
||||
struct thread *td;
|
||||
int error;
|
||||
|
||||
td = rtems_bsd_get_curthread_or_null();
|
||||
if (td != NULL) {
|
||||
struct file *fp;
|
||||
|
||||
fp = rtems_bsd_iop_to_fp(iop);
|
||||
error = cryptof_ioctl(fp, request, buffer, NULL, td);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return (rtems_bsd_error_to_status_and_errno(error));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int cryptodev_cb(struct cryptop *);
|
||||
|
||||
@ -1384,17 +1358,11 @@ cryptodev_find(struct crypt_find_op *find)
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
#ifndef __rtems__
|
||||
cryptof_stat(
|
||||
struct file *fp,
|
||||
struct stat *sb,
|
||||
struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
#else /* __rtems__ */
|
||||
rtems_bsd_cryptof_stat(const rtems_filesystem_location_info_t *loc,
|
||||
struct stat *buf
|
||||
#endif /* __rtems__ */
|
||||
)
|
||||
{
|
||||
|
||||
return (EOPNOTSUPP);
|
||||
@ -1418,28 +1386,7 @@ cryptof_close(struct file *fp, struct thread *td)
|
||||
fp->f_data = NULL;
|
||||
return 0;
|
||||
}
|
||||
#ifdef __rtems__
|
||||
static int
|
||||
rtems_bsd_cryptof_close(rtems_libio_t *iop)
|
||||
{
|
||||
struct thread *td;
|
||||
int error;
|
||||
|
||||
td = rtems_bsd_get_curthread_or_null();
|
||||
if (td != NULL) {
|
||||
struct file *fp;
|
||||
|
||||
fp = rtems_bsd_iop_to_fp(iop);
|
||||
error = cryptof_close(fp, td);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
return (rtems_bsd_error_to_status_and_errno(error));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
cryptof_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
|
||||
{
|
||||
@ -1447,7 +1394,6 @@ cryptof_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp
|
||||
kif->kf_type = KF_TYPE_CRYPTO;
|
||||
return (0);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static struct csession *
|
||||
csefind(struct fcrypt *fcr, u_int ses)
|
||||
@ -1567,10 +1513,17 @@ cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread
|
||||
}
|
||||
/* falloc automatically provides an extra reference to 'f'. */
|
||||
finit(f, FREAD | FWRITE, DTYPE_CRYPTO, fcr, &cryptofops);
|
||||
*(u_int32_t *)data = fd;
|
||||
#ifndef __rtems__
|
||||
fdrop(f, td);
|
||||
#ifdef __rtems__
|
||||
fd = rtems_bsd_libio_iop_allocate_with_file(td, fd, &rtems_bsd_sysgen_nodeops);
|
||||
if (fd < 0) {
|
||||
fdclose(td, f, fd);
|
||||
mtx_destroy(&fcr->lock);
|
||||
free(fcr, M_XDATA);
|
||||
return (error);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
*(u_int32_t *)data = fd;
|
||||
fdrop(f, td);
|
||||
break;
|
||||
case CRIOFINDDEV:
|
||||
error = cryptodev_find((struct crypt_find_op *)data);
|
||||
@ -1627,23 +1580,3 @@ MODULE_VERSION(cryptodev, 1);
|
||||
DECLARE_MODULE(cryptodev, cryptodev_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
|
||||
MODULE_DEPEND(cryptodev, crypto, 1, 1, 1);
|
||||
MODULE_DEPEND(cryptodev, zlib, 1, 1, 1);
|
||||
#ifdef __rtems__
|
||||
static const rtems_filesystem_file_handlers_r cryptofops = {
|
||||
.open_h = rtems_filesystem_default_open,
|
||||
.close_h = rtems_bsd_cryptof_close,
|
||||
.read_h = rtems_filesystem_default_read,
|
||||
.write_h = rtems_filesystem_default_write,
|
||||
.ioctl_h = rtems_bsd_cryptof_ioctl,
|
||||
.lseek_h = rtems_filesystem_default_lseek,
|
||||
.fstat_h = rtems_bsd_cryptof_stat,
|
||||
.ftruncate_h = rtems_filesystem_default_ftruncate,
|
||||
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
|
||||
.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
|
||||
.fcntl_h = rtems_filesystem_default_fcntl,
|
||||
.poll_h = rtems_filesystem_default_poll,
|
||||
.kqfilter_h = rtems_filesystem_default_kqfilter,
|
||||
.readv_h = rtems_filesystem_default_readv,
|
||||
.writev_h = rtems_filesystem_default_writev,
|
||||
.mmap_h = rtems_filesystem_default_mmap
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
|
@ -102,9 +102,11 @@ struct bio {
|
||||
void *bio_caller2; /* Private use by the consumer. */
|
||||
TAILQ_ENTRY(bio) bio_queue; /* Disksort queue. */
|
||||
const char *bio_attribute; /* Attribute for BIO_[GS]ETATTR */
|
||||
#ifndef __rtems__
|
||||
struct disk_zone_args bio_zone;/* Used for BIO_ZONE */
|
||||
struct g_consumer *bio_from; /* GEOM linkage */
|
||||
struct g_provider *bio_to; /* GEOM linkage */
|
||||
#endif /* __rtems__ */
|
||||
off_t bio_length; /* Like bio_bcount */
|
||||
off_t bio_completed; /* Inverse of bio_resid */
|
||||
u_int bio_children; /* Number of spawned bios */
|
||||
|
@ -336,9 +336,9 @@ cap_rights_t *__cap_rights_set(cap_rights_t *rights, ...);
|
||||
__cap_rights_clear(__VA_ARGS__, 0ULL)
|
||||
cap_rights_t *__cap_rights_clear(cap_rights_t *rights, ...);
|
||||
#else /* __rtems__ */
|
||||
#define cap_rights_init(...) (void)0
|
||||
#define cap_rights_set(...) (void)0
|
||||
#define cap_rights_clear(...) (void)0
|
||||
#define cap_rights_init(...) NULL
|
||||
#define cap_rights_set(...) NULL
|
||||
#define cap_rights_clear(...) NULL
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#define cap_rights_is_set(...) \
|
||||
|
@ -90,15 +90,11 @@ struct cdev {
|
||||
LIST_HEAD(, cdev) si_children;
|
||||
LIST_ENTRY(cdev) si_siblings;
|
||||
struct cdev *si_parent;
|
||||
#ifndef __rtems__
|
||||
struct mount *si_mountpt;
|
||||
#endif /* __rtems__ */
|
||||
void *si_drv1, *si_drv2;
|
||||
struct cdevsw *si_devsw;
|
||||
#ifndef __rtems__
|
||||
int si_iosize_max; /* maximum I/O size (for physio &al) */
|
||||
u_long si_usecount;
|
||||
#endif /* __rtems__ */
|
||||
u_long si_threadcount;
|
||||
#ifndef __rtems__
|
||||
union {
|
||||
|
@ -48,9 +48,7 @@ struct kqueue {
|
||||
int kq_count; /* number of pending events */
|
||||
struct selinfo kq_sel;
|
||||
struct sigio *kq_sigio;
|
||||
#ifndef __rtems__
|
||||
struct filedesc *kq_fdp;
|
||||
#endif /* __rtems__ */
|
||||
int kq_state;
|
||||
#define KQ_SEL 0x01
|
||||
#define KQ_SLEEP 0x02
|
||||
|
@ -172,7 +172,6 @@ struct fadvise_info {
|
||||
};
|
||||
|
||||
struct file {
|
||||
#ifndef __rtems__
|
||||
void *f_data; /* file descriptor specific data */
|
||||
struct fileops *f_ops; /* File operations */
|
||||
struct ucred *f_cred; /* associated credentials. */
|
||||
@ -202,93 +201,13 @@ struct file {
|
||||
* Mandatory Access control information.
|
||||
*/
|
||||
void *f_label; /* Place-holder for MAC label. */
|
||||
#else /* __rtems__ */
|
||||
rtems_libio_t f_io;
|
||||
#ifdef __rtems__
|
||||
rtems_libio_t *f_io;
|
||||
#endif /* __rtems__ */
|
||||
};
|
||||
#ifdef __rtems__
|
||||
#define f_data f_io.pathinfo.node_access_2
|
||||
#define f_cdevpriv f_io.data1
|
||||
|
||||
static inline struct file *
|
||||
rtems_bsd_iop_to_fp(rtems_libio_t *iop)
|
||||
{
|
||||
return (struct file *) iop;
|
||||
}
|
||||
|
||||
static inline struct file *
|
||||
rtems_bsd_fd_to_fp(int fd)
|
||||
{
|
||||
return rtems_bsd_iop_to_fp(&rtems_libio_iops[fd]);
|
||||
}
|
||||
|
||||
static inline int
|
||||
rtems_bsd_fp_to_fd(struct file *fp)
|
||||
{
|
||||
return fp - rtems_bsd_iop_to_fp(&rtems_libio_iops[0]);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
rtems_bsd_loc_to_f_data(const rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
return loc->node_access_2;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
rtems_bsd_fflag_to_libio_flags(u_int fflag)
|
||||
{
|
||||
uint32_t libio_flags = 0;
|
||||
|
||||
if ((fflag & FREAD) == FREAD) {
|
||||
libio_flags |= LIBIO_FLAGS_READ;
|
||||
}
|
||||
|
||||
if ((fflag & FWRITE) == FWRITE) {
|
||||
libio_flags |= LIBIO_FLAGS_WRITE;
|
||||
}
|
||||
|
||||
if ((fflag & FNONBLOCK) == FNONBLOCK) {
|
||||
libio_flags |= LIBIO_FLAGS_NO_DELAY;
|
||||
}
|
||||
|
||||
return (libio_flags);
|
||||
}
|
||||
|
||||
static inline u_int
|
||||
rtems_bsd_libio_flags_to_fflag(uint32_t libio_flags)
|
||||
{
|
||||
u_int fflag = 0;
|
||||
|
||||
if ((libio_flags & LIBIO_FLAGS_READ) == LIBIO_FLAGS_READ) {
|
||||
fflag |= FREAD;
|
||||
}
|
||||
|
||||
if ((libio_flags & LIBIO_FLAGS_WRITE) == LIBIO_FLAGS_WRITE) {
|
||||
fflag |= FWRITE;
|
||||
}
|
||||
|
||||
if ((libio_flags & LIBIO_FLAGS_NO_DELAY) == LIBIO_FLAGS_NO_DELAY) {
|
||||
fflag |= FNONBLOCK;
|
||||
}
|
||||
|
||||
return (fflag);
|
||||
}
|
||||
|
||||
static int inline
|
||||
rtems_bsd_error_to_status_and_errno(int error)
|
||||
{
|
||||
if (error == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
#define f_cdevpriv f_vnun.fvn_cdevpriv
|
||||
#define f_advice f_vnun.fvn_advice
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#define FOFFSET_LOCKED 0x1
|
||||
#define FOFFSET_LOCK_WAITING 0x2
|
||||
@ -323,32 +242,12 @@ struct xfile {
|
||||
|
||||
extern struct fileops vnops;
|
||||
extern struct fileops badfileops;
|
||||
#ifndef __rtems__
|
||||
extern struct fileops socketops;
|
||||
#else /* __rtems__ */
|
||||
extern const rtems_filesystem_file_handlers_r socketops;
|
||||
#endif /* __rtems__ */
|
||||
extern int maxfiles; /* kernel limit on number of open files */
|
||||
extern int maxfilesperproc; /* per process limit on number of open files */
|
||||
extern volatile int openfiles; /* actual number of open files */
|
||||
|
||||
#ifndef __rtems__
|
||||
int fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp);
|
||||
#else /* __rtems__ */
|
||||
struct file *rtems_bsd_get_file(int fd);
|
||||
|
||||
static inline int
|
||||
rtems_bsd_do_fget(int fd, struct file **fpp)
|
||||
{
|
||||
struct file *fp;
|
||||
|
||||
fp = rtems_bsd_get_file(fd);
|
||||
*fpp = fp;
|
||||
return (fp != NULL ? 0 : EBADF);
|
||||
}
|
||||
|
||||
#define fget(td, fd, rights, fpp) rtems_bsd_do_fget(fd, fpp)
|
||||
#endif /* __rtems__ */
|
||||
int fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp,
|
||||
u_char *maxprotp, struct file **fpp);
|
||||
int fget_read(struct thread *td, int fd, cap_rights_t *rightsp,
|
||||
@ -359,7 +258,6 @@ int fget_fcntl(struct thread *td, int fd, cap_rights_t *rightsp,
|
||||
int needfcntl, struct file **fpp);
|
||||
int _fdrop(struct file *fp, struct thread *td);
|
||||
|
||||
#ifndef __rtems__
|
||||
fo_rdwr_t invfo_rdwr;
|
||||
fo_truncate_t invfo_truncate;
|
||||
fo_ioctl_t invfo_ioctl;
|
||||
@ -371,27 +269,12 @@ fo_sendfile_t invfo_sendfile;
|
||||
|
||||
fo_sendfile_t vn_sendfile;
|
||||
fo_seek_t vn_seek;
|
||||
#ifndef __rtems__
|
||||
fo_fill_kinfo_t vn_fill_kinfo;
|
||||
int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif);
|
||||
#else /* __rtems__ */
|
||||
int rtems_bsd_soo_kqfilter(rtems_libio_t *iop, struct knote *kn);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
void finit(struct file *, u_int, short, void *, struct fileops *);
|
||||
#else /* __rtems__ */
|
||||
static inline void
|
||||
finit(struct file *fp, u_int fflag, short type, void *data,
|
||||
const rtems_filesystem_file_handlers_r *ops)
|
||||
{
|
||||
|
||||
(void)type;
|
||||
fp->f_data = data;
|
||||
fp->f_io.pathinfo.handlers = ops;
|
||||
rtems_libio_iop_flags_set(&fp->f_io, LIBIO_FLAGS_OPEN |
|
||||
rtems_bsd_fflag_to_libio_flags(fflag));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
int fgetvp(struct thread *td, int fd, cap_rights_t *rightsp,
|
||||
struct vnode **vpp);
|
||||
int fgetvp_exec(struct thread *td, int fd, cap_rights_t *rightsp,
|
||||
@ -410,36 +293,32 @@ _fnoop(void)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
static __inline __result_use_check bool
|
||||
fhold(struct file *fp)
|
||||
{
|
||||
return (refcount_acquire_checked(&fp->f_count));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
#define fdrop(fp, td) \
|
||||
(refcount_release(&(fp)->f_count) ? _fdrop((fp), (td)) : _fnoop())
|
||||
#else /* __rtems__ */
|
||||
static inline void
|
||||
rtems_bsd_fdrop(struct file *fp)
|
||||
static inline int fdrop(struct file *fp, struct thread *td)
|
||||
{
|
||||
|
||||
rtems_libio_iop_drop(&fp->f_io);
|
||||
if (fp->f_io != NULL) {
|
||||
if (RTEMS_BSD_DESCRIP_TRACE)
|
||||
printf("bsd: fb: fdrop: iop=%p %d (%d) fp=%p (%d) by %p\n",
|
||||
fp->f_io, fp->f_io->data0, fp->f_io->flags >> 12,
|
||||
fp, fp->f_count, __builtin_return_address(0));
|
||||
rtems_libio_iop_drop(fp->f_io);
|
||||
} else if (RTEMS_BSD_DESCRIP_TRACE) {
|
||||
printf("bsd: fb: fdrop: %d %p %d by %p\n",
|
||||
-1, fp, fp->f_count, __builtin_return_address(0));
|
||||
}
|
||||
return (refcount_release(&(fp)->f_count) ? _fdrop((fp), (td)) : _fnoop());
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING: fdalloc() and falloc_caps() do not increment the reference count of
|
||||
* the file descriptor in contrast to FreeBSD. We must not call the fdrop()
|
||||
* corresponding to a fdalloc() or falloc_caps(). The reason for this is that
|
||||
* FreeBSD performs a lazy cleanup once the reference count reaches zero.
|
||||
* RTEMS uses the reference count to determine if a cleanup is allowed.
|
||||
*/
|
||||
#define fdrop(fp, td) rtems_bsd_fdrop(fp)
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
static __inline fo_rdwr_t fo_read;
|
||||
static __inline fo_rdwr_t fo_write;
|
||||
static __inline fo_truncate_t fo_truncate;
|
||||
@ -475,29 +354,13 @@ fo_truncate(struct file *fp, off_t length, struct ucred *active_cred,
|
||||
|
||||
return ((*fp->f_ops->fo_truncate)(fp, length, active_cred, td));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static __inline int
|
||||
fo_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
return ((*fp->f_ops->fo_ioctl)(fp, com, data, active_cred, td));
|
||||
#else /* __rtems__ */
|
||||
int rv;
|
||||
|
||||
(void) active_cred;
|
||||
(void) td;
|
||||
|
||||
errno = 0;
|
||||
rv = ((*fp->f_io.pathinfo.handlers->ioctl_h)(&fp->f_io, com, data));
|
||||
if (rv == 0) {
|
||||
return (0);
|
||||
} else {
|
||||
return (errno);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static __inline int
|
||||
@ -505,17 +368,9 @@ fo_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
return ((*fp->f_ops->fo_poll)(fp, events, active_cred, td));
|
||||
#else /* __rtems__ */
|
||||
(void) active_cred;
|
||||
(void) td;
|
||||
|
||||
return ((*fp->f_io.pathinfo.handlers->poll_h)(&fp->f_io, events));
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
static __inline int
|
||||
fo_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
@ -530,20 +385,14 @@ fo_close(struct file *fp, struct thread *td)
|
||||
|
||||
return ((*fp->f_ops->fo_close)(fp, td));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static __inline int
|
||||
fo_kqfilter(struct file *fp, struct knote *kn)
|
||||
{
|
||||
|
||||
#ifndef __rtems__
|
||||
return ((*fp->f_ops->fo_kqfilter)(fp, kn));
|
||||
#else /* __rtems__ */
|
||||
return ((*fp->f_io.pathinfo.handlers->kqfilter_h)(&fp->f_io, kn));
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
static __inline int
|
||||
fo_chmod(struct file *fp, mode_t mode, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
@ -602,6 +451,9 @@ fo_aio_queue(struct file *fp, struct kaiocb *job)
|
||||
|
||||
return ((*fp->f_ops->fo_aio_queue)(fp, job));
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-libio.h>
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
@ -76,7 +76,6 @@ struct fdescenttbl {
|
||||
*/
|
||||
#define NDSLOTTYPE u_long
|
||||
|
||||
#ifndef __rtems__
|
||||
struct filedesc {
|
||||
struct fdescenttbl *fd_files; /* open files table */
|
||||
struct vnode *fd_cdir; /* current directory */
|
||||
@ -93,9 +92,6 @@ struct filedesc {
|
||||
int fd_holdleaderscount; /* block fdfree() for shared close() */
|
||||
int fd_holdleaderswakeup; /* fdfree() needs wakeup */
|
||||
};
|
||||
#else /* __rtems__ */
|
||||
struct filedesc;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Structure to keep track of (process leader, struct fildedesc) tuples.
|
||||
@ -106,7 +102,6 @@ struct filedesc;
|
||||
*
|
||||
* fdl_refcount and fdl_holdcount are protected by struct filedesc mtx.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
struct filedesc_to_leader {
|
||||
int fdl_refcount; /* references from struct proc */
|
||||
int fdl_holdcount; /* temporary hold during closef */
|
||||
@ -118,9 +113,6 @@ struct filedesc_to_leader {
|
||||
};
|
||||
#define fd_nfiles fd_files->fdt_nfiles
|
||||
#define fd_ofiles fd_files->fdt_ofiles
|
||||
#else /* __rtems__ */
|
||||
struct filedesc_to_leader;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Per-process open flags.
|
||||
@ -128,26 +120,15 @@ struct filedesc_to_leader;
|
||||
#define UF_EXCLOSE 0x01 /* auto-close on exec */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#ifdef __rtems__
|
||||
#include <sys/file.h>
|
||||
#include <rtems/libio_.h>
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* Lock a file descriptor table. */
|
||||
#define FILEDESC_LOCK_INIT(fdp) sx_init(&(fdp)->fd_sx, "filedesc structure")
|
||||
#define FILEDESC_LOCK_DESTROY(fdp) sx_destroy(&(fdp)->fd_sx)
|
||||
#define FILEDESC_LOCK(fdp) (&(fdp)->fd_sx)
|
||||
#ifndef __rtems__
|
||||
#define FILEDESC_XLOCK(fdp) sx_xlock(&(fdp)->fd_sx)
|
||||
#define FILEDESC_XUNLOCK(fdp) sx_xunlock(&(fdp)->fd_sx)
|
||||
#define FILEDESC_SLOCK(fdp) sx_slock(&(fdp)->fd_sx)
|
||||
#define FILEDESC_SUNLOCK(fdp) sx_sunlock(&(fdp)->fd_sx)
|
||||
#else /* __rtems__ */
|
||||
#define FILEDESC_XLOCK(fdp) do { } while (0)
|
||||
#define FILEDESC_XUNLOCK(fdp) do { } while (0)
|
||||
#define FILEDESC_SLOCK(fdp) do { } while (0)
|
||||
#define FILEDESC_SUNLOCK(fdp) do { } while (0)
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#define FILEDESC_LOCK_ASSERT(fdp) sx_assert(&(fdp)->fd_sx, SX_LOCKED | \
|
||||
SX_NOTRECURSED)
|
||||
@ -177,42 +158,13 @@ void filecaps_init(struct filecaps *fcaps);
|
||||
bool filecaps_copy(const struct filecaps *src, struct filecaps *dst,
|
||||
bool locked);
|
||||
void filecaps_move(struct filecaps *src, struct filecaps *dst);
|
||||
#ifndef __rtems__
|
||||
void filecaps_free(struct filecaps *fcaps);
|
||||
#else /* __rtems__ */
|
||||
#define filecaps_free(fcaps) do { } while (0)
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int closef(struct file *fp, struct thread *td);
|
||||
int dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode,
|
||||
int openerror, int *indxp);
|
||||
#ifndef __rtems__
|
||||
int falloc_caps(struct thread *td, struct file **resultfp, int *resultfd,
|
||||
int flags, struct filecaps *fcaps);
|
||||
#else /* __rtems__ */
|
||||
static inline int
|
||||
falloc_caps(struct thread *td, struct file **resultfp, int *resultfd,
|
||||
int flags, struct filecaps *fcaps)
|
||||
{
|
||||
rtems_libio_t *iop;
|
||||
|
||||
(void)td;
|
||||
(void)flags;
|
||||
(void)fcaps;
|
||||
|
||||
iop = rtems_libio_allocate();
|
||||
*resultfp = rtems_bsd_iop_to_fp(iop);
|
||||
|
||||
if (iop != NULL) {
|
||||
iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry;
|
||||
rtems_filesystem_location_add_to_mt_entry(&iop->pathinfo);
|
||||
*resultfd = rtems_libio_iop_to_descriptor(iop);
|
||||
return (0);
|
||||
} else {
|
||||
return (ENFILE);
|
||||
}
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
int falloc_noinstall(struct thread *td, struct file **resultfp);
|
||||
void _finstall(struct filedesc *fdp, struct file *fp, int fd, int flags,
|
||||
struct filecaps *fcaps);
|
||||
@ -221,22 +173,7 @@ int finstall(struct thread *td, struct file *fp, int *resultfd, int flags,
|
||||
int fdalloc(struct thread *td, int minfd, int *result);
|
||||
int fdallocn(struct thread *td, int minfd, int *fds, int n);
|
||||
int fdcheckstd(struct thread *td);
|
||||
#ifndef __rtems__
|
||||
void fdclose(struct thread *td, struct file *fp, int idx);
|
||||
#else /* __rtems__ */
|
||||
/*
|
||||
* WARNING: Use of fdrop() after fclose() corrupts the file descriptor. See
|
||||
* fdrop() comment.
|
||||
*/
|
||||
static inline void
|
||||
fdclose(struct thread *td, struct file *fp, int idx)
|
||||
{
|
||||
(void)td;
|
||||
(void)idx;
|
||||
|
||||
rtems_libio_free(&fp->f_io);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
void fdcloseexec(struct thread *td);
|
||||
void fdsetugidsafety(struct thread *td);
|
||||
struct filedesc *fdcopy(struct filedesc *fdp);
|
||||
@ -261,27 +198,9 @@ int fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,
|
||||
struct file **fpp, struct filecaps *havecapsp);
|
||||
|
||||
/* Return a referenced file from an unlocked descriptor. */
|
||||
#ifndef __rtems__
|
||||
int fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
|
||||
struct file **fpp, seq_t *seqp);
|
||||
#else /* __rtems__ */
|
||||
static inline int
|
||||
do_fget_unlocked(struct filedesc *fdp, int fd, struct file **fpp, seq_t *seqp)
|
||||
{
|
||||
struct file *fp;
|
||||
|
||||
(void)fdp;
|
||||
(void)seqp;
|
||||
fp = rtems_bsd_get_file(fd);
|
||||
*fpp = fp;
|
||||
return (fp != NULL ? 0 : EBADF);
|
||||
}
|
||||
|
||||
#define fget_unlocked(fdp, fd, needrightsp, fpp, seqp) \
|
||||
do_fget_unlocked(fdp, fd, fpp, seqp)
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
/* Requires a FILEDESC_{S,X}LOCK held and returns without a ref. */
|
||||
static __inline struct file *
|
||||
fget_locked(struct filedesc *fdp, int fd)
|
||||
@ -320,13 +239,15 @@ fd_modified(struct filedesc *fdp, int fd, seq_t seq)
|
||||
return (!seq_consistent(fd_seq(fdp->fd_files, fd), seq));
|
||||
}
|
||||
#endif
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* cdir/rdir/jdir manipulation functions. */
|
||||
void pwd_chdir(struct thread *td, struct vnode *vp);
|
||||
int pwd_chroot(struct thread *td, struct vnode *vp);
|
||||
void pwd_ensure_dirs(void);
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-libio.h>
|
||||
#endif /* __rtems__ */
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_SYS_FILEDESC_H_ */
|
||||
|
@ -399,7 +399,18 @@ getcredhostid(struct ucred *cred, unsigned long *hostid)
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
void prison0_init(void);
|
||||
#ifndef __rtems__
|
||||
int prison_allow(struct ucred *, unsigned);
|
||||
#else /* __rtems__ */
|
||||
static inline int
|
||||
prison_allow(struct ucred *cred1, unsigned i)
|
||||
{
|
||||
|
||||
(void)cred1;
|
||||
(void)i;
|
||||
return (0);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
#ifndef __rtems__
|
||||
int prison_check(struct ucred *cred1, struct ucred *cred2);
|
||||
#else /* __rtems__ */
|
||||
|
@ -696,6 +696,7 @@ struct vfsops {
|
||||
|
||||
vfs_statfs_t __vfs_statfs;
|
||||
|
||||
#ifndef __rtems__
|
||||
#define VFS_PROLOGUE(MP) do { \
|
||||
struct mount *mp__; \
|
||||
int _prev_stops; \
|
||||
@ -708,6 +709,10 @@ vfs_statfs_t __vfs_statfs;
|
||||
#define VFS_EPILOGUE(MP) \
|
||||
sigallowstop(_prev_stops); \
|
||||
} while (0)
|
||||
#else /* __rtems__ */
|
||||
#define VFS_PROLOGUE(MP)
|
||||
#define VFS_EPILOGUE(MP)
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#define VFS_MOUNT(MP) ({ \
|
||||
int _rc; \
|
||||
@ -857,6 +862,7 @@ vfs_statfs_t __vfs_statfs;
|
||||
#define VFS_VERSION_02 0x20180504
|
||||
#define VFS_VERSION VFS_VERSION_02
|
||||
|
||||
#ifndef __rtems__
|
||||
#define VFS_SET(vfsops, fsname, flags) \
|
||||
static struct vfsconf fsname ## _vfsconf = { \
|
||||
.vfc_version = VFS_VERSION, \
|
||||
@ -871,6 +877,22 @@ vfs_statfs_t __vfs_statfs;
|
||||
& fsname ## _vfsconf \
|
||||
}; \
|
||||
DECLARE_MODULE(fsname, fsname ## _mod, SI_SUB_VFS, SI_ORDER_MIDDLE)
|
||||
#else /* __rtems__ */
|
||||
#define VFS_SET(vfsops, fsname, flags) \
|
||||
struct vfsconf fsname ## _vfsconf = { \
|
||||
.vfc_version = VFS_VERSION, \
|
||||
.vfc_name = #fsname, \
|
||||
.vfc_vfsops = &vfsops, \
|
||||
.vfc_typenum = -1, \
|
||||
.vfc_flags = flags, \
|
||||
}; \
|
||||
moduledata_t fsname ## _mod = { \
|
||||
#fsname, \
|
||||
vfs_modevent, \
|
||||
& fsname ## _vfsconf \
|
||||
}; \
|
||||
DECLARE_MODULE(fsname, fsname ## _mod, SI_SUB_VFS, SI_ORDER_MIDDLE)
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* exported vnode operations
|
||||
|
@ -718,7 +718,9 @@ struct proc {
|
||||
int p_osrel; /* (x) osreldate for the
|
||||
binary (from ELF note, if any) */
|
||||
char p_comm[MAXCOMLEN + 1]; /* (x) Process name. */
|
||||
#endif /* __rtems__ */
|
||||
struct sysentvec *p_sysent; /* (b) Syscall dispatch info. */
|
||||
#ifndef __rtems__
|
||||
struct pargs *p_args; /* (c) Process arguments. */
|
||||
rlim_t p_cpulimit; /* (c) Current CPU limit in seconds. */
|
||||
signed char p_nice; /* (c) Process "nice" value. */
|
||||
|
@ -123,7 +123,7 @@ void calcru(struct proc *p, struct timeval *up, struct timeval *sp);
|
||||
#ifndef __rtems__
|
||||
int chgkqcnt(struct uidinfo *uip, int diff, rlim_t max);
|
||||
#else /* __rtems__ */
|
||||
#define chgkqcnt(uip, diff, max) 0
|
||||
#define chgkqcnt(uip, diff, max) 1
|
||||
#endif /* __rtems__ */
|
||||
int chgproccnt(struct uidinfo *uip, int diff, rlim_t maxval);
|
||||
#ifndef __rtems__
|
||||
@ -146,7 +146,14 @@ int kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which,
|
||||
struct plimit
|
||||
*lim_alloc(void);
|
||||
void lim_copy(struct plimit *dst, struct plimit *src);
|
||||
#ifndef __rtems__
|
||||
rlim_t lim_cur(struct thread *td, int which);
|
||||
#else /* __rtems__ */
|
||||
static inline rlim_t lim_cur(struct thread *td, int which)
|
||||
{
|
||||
return INT64_MAX;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
rlim_t lim_cur_proc(struct proc *p, int which);
|
||||
void lim_fork(struct proc *p1, struct proc *p2);
|
||||
void lim_free(struct plimit *limp);
|
||||
|
@ -1129,18 +1129,10 @@ int sysctl_ctx_entry_del(struct sysctl_ctx_list *clist,
|
||||
struct sysctl_oid *oidp);
|
||||
|
||||
int kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
|
||||
#ifndef __rtems__
|
||||
size_t *oldlenp, void *new, size_t newlen, size_t *retval,
|
||||
#else /* __rtems__ */
|
||||
size_t *oldlenp, const void *newp, size_t newlen, size_t *retval,
|
||||
#endif /* __rtems__ */
|
||||
int flags);
|
||||
int kernel_sysctlbyname(struct thread *td, char *name, void *old,
|
||||
#ifndef __rtems__
|
||||
size_t *oldlenp, void *new, size_t newlen, size_t *retval,
|
||||
#else /* __rtems__ */
|
||||
size_t *oldlenp, const void *newp, size_t newlen, size_t *retval,
|
||||
#endif /* __rtems__ */
|
||||
int flags);
|
||||
#ifndef __rtems__
|
||||
int userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
|
||||
|
@ -93,6 +93,7 @@ struct trapframe;
|
||||
struct vnode;
|
||||
|
||||
struct sysentvec {
|
||||
#ifndef __rtems__
|
||||
int sv_size; /* number of entries */
|
||||
struct sysent *sv_table; /* pointer to sysent */
|
||||
u_int sv_mask; /* optional mask to index */
|
||||
@ -123,7 +124,9 @@ struct sysentvec {
|
||||
u_long);
|
||||
void (*sv_fixlimit)(struct rlimit *, int);
|
||||
u_long *sv_maxssiz;
|
||||
#endif /* __rtems__ */
|
||||
u_int sv_flags;
|
||||
#ifndef __rtems__
|
||||
void (*sv_set_syscall_retval)(struct thread *, int);
|
||||
int (*sv_fetch_syscall_args)(struct thread *);
|
||||
const char **sv_syscallnames;
|
||||
@ -137,6 +140,7 @@ struct sysentvec {
|
||||
int (*sv_trap)(struct thread *);
|
||||
u_long *sv_hwcap; /* Value passed in AT_HWCAP. */
|
||||
u_long *sv_hwcap2; /* Value passed in AT_HWCAP2. */
|
||||
#endif /* __rtems__ */
|
||||
};
|
||||
|
||||
#define SV_ILP32 0x000100 /* 32-bit executable. */
|
||||
|
@ -44,6 +44,7 @@ struct sys_exit_args {
|
||||
struct fork_args {
|
||||
register_t dummy;
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct read_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)];
|
||||
@ -62,12 +63,14 @@ struct open_args {
|
||||
struct close_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct wait4_args {
|
||||
char pid_l_[PADL_(int)]; int pid; char pid_r_[PADR_(int)];
|
||||
char status_l_[PADL_(int *)]; int * status; char status_r_[PADR_(int *)];
|
||||
char options_l_[PADL_(int)]; int options; char options_r_[PADR_(int)];
|
||||
char rusage_l_[PADL_(struct rusage *)]; struct rusage * rusage; char rusage_r_[PADR_(struct rusage *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct link_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char link_l_[PADL_(char *)]; char * link; char link_r_[PADR_(char *)];
|
||||
@ -90,12 +93,14 @@ struct chown_args {
|
||||
char uid_l_[PADL_(int)]; int uid; char uid_r_[PADR_(int)];
|
||||
char gid_l_[PADL_(int)]; int gid; char gid_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct break_args {
|
||||
char nsize_l_[PADL_(char *)]; char * nsize; char nsize_r_[PADR_(char *)];
|
||||
};
|
||||
struct getpid_args {
|
||||
register_t dummy;
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct mount_args {
|
||||
char type_l_[PADL_(char *)]; char * type; char type_r_[PADR_(char *)];
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
@ -106,6 +111,7 @@ struct unmount_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct setuid_args {
|
||||
char uid_l_[PADL_(uid_t)]; uid_t uid; char uid_r_[PADR_(uid_t)];
|
||||
};
|
||||
@ -159,7 +165,6 @@ struct getsockname_args {
|
||||
char asa_l_[PADL_(struct sockaddr *__restrict)]; struct sockaddr *__restrict asa; char asa_r_[PADR_(struct sockaddr *__restrict)];
|
||||
char alen_l_[PADL_(__socklen_t *__restrict)]; __socklen_t *__restrict alen; char alen_r_[PADR_(__socklen_t *__restrict)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct access_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char amode_l_[PADL_(int)]; int amode; char amode_r_[PADR_(int)];
|
||||
@ -172,6 +177,7 @@ struct fchflags_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char flags_l_[PADL_(u_long)]; u_long flags; char flags_r_[PADR_(u_long)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct sync_args {
|
||||
register_t dummy;
|
||||
};
|
||||
@ -223,17 +229,20 @@ struct sigaltstack_args {
|
||||
char ss_l_[PADL_(stack_t *)]; stack_t * ss; char ss_r_[PADR_(stack_t *)];
|
||||
char oss_l_[PADL_(stack_t *)]; stack_t * oss; char oss_r_[PADR_(stack_t *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct ioctl_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char com_l_[PADL_(u_long)]; u_long com; char com_r_[PADR_(u_long)];
|
||||
char data_l_[PADL_(caddr_t)]; caddr_t data; char data_r_[PADR_(caddr_t)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct reboot_args {
|
||||
char opt_l_[PADL_(int)]; int opt; char opt_r_[PADR_(int)];
|
||||
};
|
||||
struct revoke_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct symlink_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char link_l_[PADL_(char *)]; char * link; char link_r_[PADR_(char *)];
|
||||
@ -243,6 +252,7 @@ struct readlink_args {
|
||||
char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
|
||||
char count_l_[PADL_(size_t)]; size_t count; char count_r_[PADR_(size_t)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct execve_args {
|
||||
char fname_l_[PADL_(char *)]; char * fname; char fname_r_[PADR_(char *)];
|
||||
char argv_l_[PADL_(char **)]; char ** argv; char argv_r_[PADR_(char **)];
|
||||
@ -332,6 +342,7 @@ struct fcntl_args {
|
||||
char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];
|
||||
char arg_l_[PADL_(long)]; long arg; char arg_r_[PADR_(long)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct select_args {
|
||||
char nd_l_[PADL_(int)]; int nd; char nd_r_[PADR_(int)];
|
||||
char in_l_[PADL_(fd_set *)]; fd_set * in; char in_r_[PADR_(fd_set *)];
|
||||
@ -342,6 +353,7 @@ struct select_args {
|
||||
struct fsync_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct setpriority_args {
|
||||
char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
|
||||
char who_l_[PADL_(int)]; int who; char who_r_[PADR_(int)];
|
||||
@ -417,7 +429,6 @@ struct getsockopt_args {
|
||||
char avalsize_l_[PADL_(__socklen_t *)]; __socklen_t * avalsize; char avalsize_r_[PADR_(__socklen_t *)];
|
||||
#endif /* __rtems__ */
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct readv_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
|
||||
@ -428,10 +439,12 @@ struct writev_args {
|
||||
char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
|
||||
char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct settimeofday_args {
|
||||
char tv_l_[PADL_(struct timeval *)]; struct timeval * tv; char tv_r_[PADR_(struct timeval *)];
|
||||
char tzp_l_[PADL_(struct timezone *)]; struct timezone * tzp; char tzp_r_[PADR_(struct timezone *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct fchown_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char uid_l_[PADL_(int)]; int uid; char uid_r_[PADR_(int)];
|
||||
@ -441,6 +454,7 @@ struct fchmod_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct setreuid_args {
|
||||
char ruid_l_[PADL_(int)]; int ruid; char ruid_r_[PADR_(int)];
|
||||
char euid_l_[PADL_(int)]; int euid; char euid_r_[PADR_(int)];
|
||||
@ -449,10 +463,12 @@ struct setregid_args {
|
||||
char rgid_l_[PADL_(int)]; int rgid; char rgid_r_[PADR_(int)];
|
||||
char egid_l_[PADL_(int)]; int egid; char egid_r_[PADR_(int)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct rename_args {
|
||||
char from_l_[PADL_(char *)]; char * from; char from_r_[PADR_(char *)];
|
||||
char to_l_[PADL_(char *)]; char * to; char to_r_[PADR_(char *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct flock_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char how_l_[PADL_(int)]; int how; char how_r_[PADR_(int)];
|
||||
@ -485,7 +501,6 @@ struct socketpair_args {
|
||||
char protocol_l_[PADL_(int)]; int protocol; char protocol_r_[PADR_(int)];
|
||||
char rsv_l_[PADL_(int *)]; int * rsv; char rsv_r_[PADR_(int *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct mkdir_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)];
|
||||
@ -493,6 +508,7 @@ struct mkdir_args {
|
||||
struct rmdir_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct utimes_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char tptr_l_[PADL_(struct timeval *)]; struct timeval * tptr; char tptr_r_[PADR_(struct timeval *)];
|
||||
@ -522,10 +538,12 @@ struct nlm_syscall_args {
|
||||
char addr_count_l_[PADL_(int)]; int addr_count; char addr_count_r_[PADR_(int)];
|
||||
char addrs_l_[PADL_(char **)]; char ** addrs; char addrs_r_[PADR_(char **)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct nfssvc_args {
|
||||
char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
|
||||
char argp_l_[PADL_(caddr_t)]; caddr_t argp; char argp_r_[PADR_(caddr_t)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct lgetfh_args {
|
||||
char fname_l_[PADL_(char *)]; char * fname; char fname_r_[PADR_(char *)];
|
||||
char fhp_l_[PADL_(struct fhandle *)]; struct fhandle * fhp; char fhp_r_[PADR_(struct fhandle *)];
|
||||
@ -741,6 +759,7 @@ struct rfork_args {
|
||||
struct issetugid_args {
|
||||
register_t dummy;
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct lchown_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char uid_l_[PADL_(int)]; int uid; char uid_r_[PADR_(int)];
|
||||
@ -762,6 +781,7 @@ struct lchmod_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char mode_l_[PADL_(mode_t)]; mode_t mode; char mode_r_[PADR_(mode_t)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct lutimes_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char tptr_l_[PADL_(struct timeval *)]; struct timeval * tptr; char tptr_r_[PADR_(struct timeval *)];
|
||||
@ -827,6 +847,7 @@ struct setresgid_args {
|
||||
char egid_l_[PADL_(gid_t)]; gid_t egid; char egid_r_[PADR_(gid_t)];
|
||||
char sgid_l_[PADL_(gid_t)]; gid_t sgid; char sgid_r_[PADR_(gid_t)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct aio_return_args {
|
||||
char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
|
||||
};
|
||||
@ -842,6 +863,7 @@ struct aio_cancel_args {
|
||||
struct aio_error_args {
|
||||
char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct yield_args {
|
||||
register_t dummy;
|
||||
};
|
||||
@ -851,10 +873,12 @@ struct mlockall_args {
|
||||
struct munlockall_args {
|
||||
register_t dummy;
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct __getcwd_args {
|
||||
char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
|
||||
char buflen_l_[PADL_(size_t)]; size_t buflen; char buflen_r_[PADR_(size_t)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct sched_setparam_args {
|
||||
char pid_l_[PADL_(pid_t)]; pid_t pid; char pid_r_[PADR_(pid_t)];
|
||||
char param_l_[PADL_(const struct sched_param *)]; const struct sched_param * param; char param_r_[PADR_(const struct sched_param *)];
|
||||
@ -923,6 +947,7 @@ struct sigwaitinfo_args {
|
||||
char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)];
|
||||
char info_l_[PADL_(siginfo_t *)]; siginfo_t * info; char info_r_[PADR_(siginfo_t *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct __acl_get_file_args {
|
||||
char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
|
||||
char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
|
||||
@ -961,6 +986,7 @@ struct __acl_aclcheck_fd_args {
|
||||
char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
|
||||
char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct extattrctl_args {
|
||||
char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
|
||||
char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];
|
||||
@ -987,10 +1013,12 @@ struct extattr_delete_file_args {
|
||||
char attrnamespace_l_[PADL_(int)]; int attrnamespace; char attrnamespace_r_[PADR_(int)];
|
||||
char attrname_l_[PADL_(const char *)]; const char * attrname; char attrname_r_[PADR_(const char *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct aio_waitcomplete_args {
|
||||
char aiocbp_l_[PADL_(struct aiocb **)]; struct aiocb ** aiocbp; char aiocbp_r_[PADR_(struct aiocb **)];
|
||||
char timeout_l_[PADL_(struct timespec *)]; struct timespec * timeout; char timeout_r_[PADR_(struct timespec *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct getresuid_args {
|
||||
char ruid_l_[PADL_(uid_t *)]; uid_t * ruid; char ruid_r_[PADR_(uid_t *)];
|
||||
char euid_l_[PADL_(uid_t *)]; uid_t * euid; char euid_r_[PADR_(uid_t *)];
|
||||
@ -1041,11 +1069,13 @@ struct afs3_syscall_args {
|
||||
char parm5_l_[PADL_(long)]; long parm5; char parm5_r_[PADR_(long)];
|
||||
char parm6_l_[PADL_(long)]; long parm6; char parm6_r_[PADR_(long)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct nmount_args {
|
||||
char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
|
||||
char iovcnt_l_[PADL_(unsigned int)]; unsigned int iovcnt; char iovcnt_r_[PADR_(unsigned int)];
|
||||
char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct __mac_get_proc_args {
|
||||
char mac_p_l_[PADL_(struct mac *)]; struct mac * mac_p; char mac_p_r_[PADR_(struct mac *)];
|
||||
};
|
||||
@ -1074,10 +1104,12 @@ struct kenv_args {
|
||||
char value_l_[PADL_(char *)]; char * value; char value_r_[PADR_(char *)];
|
||||
char len_l_[PADL_(int)]; int len; char len_r_[PADR_(int)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct lchflags_args {
|
||||
char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
|
||||
char flags_l_[PADL_(u_long)]; u_long flags; char flags_r_[PADR_(u_long)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct uuidgen_args {
|
||||
char store_l_[PADL_(struct uuid *)]; struct uuid * store; char store_r_[PADR_(struct uuid *)];
|
||||
char count_l_[PADL_(int)]; int count; char count_r_[PADR_(int)];
|
||||
@ -1187,6 +1219,7 @@ struct swapcontext_args {
|
||||
struct swapoff_args {
|
||||
char name_l_[PADL_(const char *)]; const char * name; char name_r_[PADR_(const char *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct __acl_get_link_args {
|
||||
char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
|
||||
char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
|
||||
@ -1206,6 +1239,7 @@ struct __acl_aclcheck_link_args {
|
||||
char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
|
||||
char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct sigwait_args {
|
||||
char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)];
|
||||
char sig_l_[PADL_(int *)]; int * sig; char sig_r_[PADR_(int *)];
|
||||
@ -1349,10 +1383,12 @@ struct thr_set_name_args {
|
||||
char id_l_[PADL_(long)]; long id; char id_r_[PADR_(long)];
|
||||
char name_l_[PADL_(const char *)]; const char * name; char name_r_[PADR_(const char *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct aio_fsync_args {
|
||||
char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)];
|
||||
char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct rtprio_thread_args {
|
||||
char function_l_[PADL_(int)]; int function; char function_r_[PADR_(int)];
|
||||
char lwpid_l_[PADL_(lwpid_t)]; lwpid_t lwpid; char lwpid_r_[PADR_(lwpid_t)];
|
||||
@ -1409,6 +1445,7 @@ struct mmap_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char pos_l_[PADL_(off_t)]; off_t pos; char pos_r_[PADR_(off_t)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct lseek_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)];
|
||||
@ -1422,6 +1459,7 @@ struct ftruncate_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char length_l_[PADL_(off_t)]; off_t length; char length_r_[PADR_(off_t)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct thr_kill2_args {
|
||||
char pid_l_[PADL_(pid_t)]; pid_t pid; char pid_r_[PADR_(pid_t)];
|
||||
char id_l_[PADL_(long)]; long id; char id_r_[PADR_(long)];
|
||||
@ -1469,6 +1507,7 @@ struct faccessat_args {
|
||||
char amode_l_[PADL_(int)]; int amode; char amode_r_[PADR_(int)];
|
||||
char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct fchmodat_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
@ -1482,6 +1521,7 @@ struct fchownat_args {
|
||||
char gid_l_[PADL_(gid_t)]; gid_t gid; char gid_r_[PADR_(gid_t)];
|
||||
char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct fexecve_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char argv_l_[PADL_(char **)]; char ** argv; char argv_r_[PADR_(char **)];
|
||||
@ -1492,6 +1532,7 @@ struct futimesat_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char times_l_[PADL_(struct timeval *)]; struct timeval * times; char times_r_[PADR_(struct timeval *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct linkat_args {
|
||||
char fd1_l_[PADL_(int)]; int fd1; char fd1_r_[PADR_(int)];
|
||||
char path1_l_[PADL_(char *)]; char * path1; char path1_r_[PADR_(char *)];
|
||||
@ -1504,11 +1545,13 @@ struct mkdirat_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char mode_l_[PADL_(mode_t)]; mode_t mode; char mode_r_[PADR_(mode_t)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct mkfifoat_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char mode_l_[PADL_(mode_t)]; mode_t mode; char mode_r_[PADR_(mode_t)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct openat_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
@ -1537,6 +1580,7 @@ struct unlinkat_args {
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct posix_openpt_args {
|
||||
char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
|
||||
};
|
||||
@ -1602,6 +1646,7 @@ struct pdgetpid_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char pidp_l_[PADL_(pid_t *)]; pid_t * pidp; char pidp_r_[PADR_(pid_t *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct pselect_args {
|
||||
char nd_l_[PADL_(int)]; int nd; char nd_r_[PADR_(int)];
|
||||
char in_l_[PADL_(fd_set *)]; fd_set * in; char in_r_[PADR_(fd_set *)];
|
||||
@ -1610,6 +1655,7 @@ struct pselect_args {
|
||||
char ts_l_[PADL_(const struct timespec *)]; const struct timespec * ts; char ts_r_[PADR_(const struct timespec *)];
|
||||
char sm_l_[PADL_(const sigset_t *)]; const sigset_t * sm; char sm_r_[PADR_(const sigset_t *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct getloginclass_args {
|
||||
char namebuf_l_[PADL_(char *)]; char * namebuf; char namebuf_r_[PADR_(char *)];
|
||||
char namelen_l_[PADL_(size_t)]; size_t namelen; char namelen_r_[PADR_(size_t)];
|
||||
@ -1706,6 +1752,7 @@ struct chflagsat_args {
|
||||
char flags_l_[PADL_(u_long)]; u_long flags; char flags_r_[PADR_(u_long)];
|
||||
char atflag_l_[PADL_(int)]; int atflag; char atflag_r_[PADR_(int)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct accept4_args {
|
||||
char s_l_[PADL_(int)]; int s; char s_r_[PADR_(int)];
|
||||
char name_l_[PADL_(struct sockaddr *__restrict)]; struct sockaddr *__restrict name; char name_r_[PADR_(struct sockaddr *__restrict)];
|
||||
@ -1719,6 +1766,7 @@ struct pipe2_args {
|
||||
struct aio_mlock_args {
|
||||
char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct procctl_args {
|
||||
char idtype_l_[PADL_(idtype_t)]; idtype_t idtype; char idtype_r_[PADR_(idtype_t)];
|
||||
char id_l_[PADL_(id_t)]; id_t id; char id_r_[PADR_(id_t)];
|
||||
@ -1741,6 +1789,7 @@ struct utimensat_args {
|
||||
char times_l_[PADL_(struct timespec *)]; struct timespec * times; char times_r_[PADR_(struct timespec *)];
|
||||
char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct fdatasync_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
};
|
||||
@ -1754,10 +1803,12 @@ struct fstatat_args {
|
||||
char buf_l_[PADL_(struct stat *)]; struct stat * buf; char buf_r_[PADR_(struct stat *)];
|
||||
char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct fhstat_args {
|
||||
char u_fhp_l_[PADL_(const struct fhandle *)]; const struct fhandle * u_fhp; char u_fhp_r_[PADR_(const struct fhandle *)];
|
||||
char sb_l_[PADL_(struct stat *)]; struct stat * sb; char sb_r_[PADR_(struct stat *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct getdirentries_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
|
||||
@ -1777,17 +1828,18 @@ struct getfsstat_args {
|
||||
char bufsize_l_[PADL_(long)]; long bufsize; char bufsize_r_[PADR_(long)];
|
||||
char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)];
|
||||
};
|
||||
#ifndef __rtems__
|
||||
struct fhstatfs_args {
|
||||
char u_fhp_l_[PADL_(const struct fhandle *)]; const struct fhandle * u_fhp; char u_fhp_r_[PADR_(const struct fhandle *)];
|
||||
char buf_l_[PADL_(struct statfs *)]; struct statfs * buf; char buf_r_[PADR_(struct statfs *)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct mknodat_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
|
||||
char mode_l_[PADL_(mode_t)]; mode_t mode; char mode_r_[PADR_(mode_t)];
|
||||
char dev_l_[PADL_(dev_t)]; dev_t dev; char dev_r_[PADR_(dev_t)];
|
||||
};
|
||||
#endif /* __rtems__ */
|
||||
struct kevent_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
#ifndef __rtems__
|
||||
@ -1845,25 +1897,32 @@ struct fhreadlink_args {
|
||||
int nosys(struct thread *, struct nosys_args *);
|
||||
void sys_sys_exit(struct thread *, struct sys_exit_args *);
|
||||
int sys_fork(struct thread *, struct fork_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_read(struct thread *, struct read_args *);
|
||||
int sys_write(struct thread *, struct write_args *);
|
||||
int sys_open(struct thread *, struct open_args *);
|
||||
int sys_close(struct thread *, struct close_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_wait4(struct thread *, struct wait4_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_link(struct thread *, struct link_args *);
|
||||
int sys_unlink(struct thread *, struct unlink_args *);
|
||||
int sys_chdir(struct thread *, struct chdir_args *);
|
||||
int sys_fchdir(struct thread *, struct fchdir_args *);
|
||||
int sys_chmod(struct thread *, struct chmod_args *);
|
||||
int sys_chown(struct thread *, struct chown_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_break(struct thread *, struct break_args *);
|
||||
int sys_getpid(struct thread *, struct getpid_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_mount(struct thread *, struct mount_args *);
|
||||
int sys_unmount(struct thread *, struct unmount_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_setuid(struct thread *, struct setuid_args *);
|
||||
int sys_getuid(struct thread *, struct getuid_args *);
|
||||
int sys_geteuid(struct thread *, struct geteuid_args *);
|
||||
int sys_ptrace(struct thread *, struct ptrace_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_recvmsg(struct thread *, struct recvmsg_args *);
|
||||
int sys_sendmsg(struct thread *, struct sendmsg_args *);
|
||||
int sys_recvfrom(struct thread *, struct recvfrom_args *);
|
||||
@ -1873,6 +1932,7 @@ int sys_getsockname(struct thread *, struct getsockname_args *);
|
||||
int sys_access(struct thread *, struct access_args *);
|
||||
int sys_chflags(struct thread *, struct chflags_args *);
|
||||
int sys_fchflags(struct thread *, struct fchflags_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_sync(struct thread *, struct sync_args *);
|
||||
int sys_kill(struct thread *, struct kill_args *);
|
||||
int sys_getppid(struct thread *, struct getppid_args *);
|
||||
@ -1885,11 +1945,15 @@ int sys_getlogin(struct thread *, struct getlogin_args *);
|
||||
int sys_setlogin(struct thread *, struct setlogin_args *);
|
||||
int sys_acct(struct thread *, struct acct_args *);
|
||||
int sys_sigaltstack(struct thread *, struct sigaltstack_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_ioctl(struct thread *, struct ioctl_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_reboot(struct thread *, struct reboot_args *);
|
||||
int sys_revoke(struct thread *, struct revoke_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_symlink(struct thread *, struct symlink_args *);
|
||||
int sys_readlink(struct thread *, struct readlink_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_execve(struct thread *, struct execve_args *);
|
||||
int sys_umask(struct thread *, struct umask_args *);
|
||||
int sys_chroot(struct thread *, struct chroot_args *);
|
||||
@ -1911,33 +1975,45 @@ int sys_getitimer(struct thread *, struct getitimer_args *);
|
||||
int sys_getdtablesize(struct thread *, struct getdtablesize_args *);
|
||||
int sys_dup2(struct thread *, struct dup2_args *);
|
||||
int sys_fcntl(struct thread *, struct fcntl_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_select(struct thread *, struct select_args *);
|
||||
int sys_fsync(struct thread *, struct fsync_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_setpriority(struct thread *, struct setpriority_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_socket(struct thread *, struct socket_args *);
|
||||
int sys_connect(struct thread *, struct connect_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_getpriority(struct thread *, struct getpriority_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_bind(struct thread *, struct bind_args *);
|
||||
int sys_setsockopt(struct thread *, struct setsockopt_args *);
|
||||
int sys_listen(struct thread *, struct listen_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_gettimeofday(struct thread *, struct gettimeofday_args *);
|
||||
int sys_getrusage(struct thread *, struct getrusage_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_getsockopt(struct thread *, struct getsockopt_args *);
|
||||
int sys_readv(struct thread *, struct readv_args *);
|
||||
int sys_writev(struct thread *, struct writev_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_settimeofday(struct thread *, struct settimeofday_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_fchown(struct thread *, struct fchown_args *);
|
||||
int sys_fchmod(struct thread *, struct fchmod_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_setreuid(struct thread *, struct setreuid_args *);
|
||||
int sys_setregid(struct thread *, struct setregid_args *);
|
||||
int sys_rename(struct thread *, struct rename_args *);
|
||||
int sys_flock(struct thread *, struct flock_args *);
|
||||
int sys_mkfifo(struct thread *, struct mkfifo_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_sendto(struct thread *, struct sendto_args *);
|
||||
int sys_shutdown(struct thread *, struct shutdown_args *);
|
||||
int sys_socketpair(struct thread *, struct socketpair_args *);
|
||||
int sys_mkdir(struct thread *, struct mkdir_args *);
|
||||
int sys_rmdir(struct thread *, struct rmdir_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_utimes(struct thread *, struct utimes_args *);
|
||||
int sys_adjtime(struct thread *, struct adjtime_args *);
|
||||
int sys_setsid(struct thread *, struct setsid_args *);
|
||||
@ -1951,7 +2027,9 @@ int sys_rtprio(struct thread *, struct rtprio_args *);
|
||||
int sys_semsys(struct thread *, struct semsys_args *);
|
||||
int sys_msgsys(struct thread *, struct msgsys_args *);
|
||||
int sys_shmsys(struct thread *, struct shmsys_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_setfib(struct thread *, struct setfib_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_ntp_adjtime(struct thread *, struct ntp_adjtime_args *);
|
||||
int sys_setgid(struct thread *, struct setgid_args *);
|
||||
int sys_setegid(struct thread *, struct setegid_args *);
|
||||
@ -1966,7 +2044,9 @@ int sys_munlock(struct thread *, struct munlock_args *);
|
||||
int sys_undelete(struct thread *, struct undelete_args *);
|
||||
int sys_futimes(struct thread *, struct futimes_args *);
|
||||
int sys_getpgid(struct thread *, struct getpgid_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_poll(struct thread *, struct poll_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_semget(struct thread *, struct semget_args *);
|
||||
int sys_semop(struct thread *, struct semop_args *);
|
||||
int sys_msgget(struct thread *, struct msgget_args *);
|
||||
@ -2055,7 +2135,9 @@ int sys_extattr_delete_file(struct thread *, struct extattr_delete_file_args *);
|
||||
int sys_aio_waitcomplete(struct thread *, struct aio_waitcomplete_args *);
|
||||
int sys_getresuid(struct thread *, struct getresuid_args *);
|
||||
int sys_getresgid(struct thread *, struct getresgid_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_kqueue(struct thread *, struct kqueue_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_extattr_set_fd(struct thread *, struct extattr_set_fd_args *);
|
||||
int sys_extattr_get_fd(struct thread *, struct extattr_get_fd_args *);
|
||||
int sys_extattr_delete_fd(struct thread *, struct extattr_delete_fd_args *);
|
||||
@ -2218,7 +2300,9 @@ int sys_fstatfs(struct thread *, struct fstatfs_args *);
|
||||
int sys_getfsstat(struct thread *, struct getfsstat_args *);
|
||||
int sys_fhstatfs(struct thread *, struct fhstatfs_args *);
|
||||
int sys_mknodat(struct thread *, struct mknodat_args *);
|
||||
#endif /* __rtems__ */
|
||||
int sys_kevent(struct thread *, struct kevent_args *);
|
||||
#ifndef __rtems__
|
||||
int sys_cpuset_getdomain(struct thread *, struct cpuset_getdomain_args *);
|
||||
int sys_cpuset_setdomain(struct thread *, struct cpuset_setdomain_args *);
|
||||
int sys_getrandom(struct thread *, struct getrandom_args *);
|
||||
@ -2226,7 +2310,9 @@ int sys_getfhat(struct thread *, struct getfhat_args *);
|
||||
int sys_fhlink(struct thread *, struct fhlink_args *);
|
||||
int sys_fhlinkat(struct thread *, struct fhlinkat_args *);
|
||||
int sys_fhreadlink(struct thread *, struct fhreadlink_args *);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifndef __rtems__
|
||||
#ifdef COMPAT_43
|
||||
|
||||
struct ocreat_args {
|
||||
|
@ -413,11 +413,11 @@ copystr(const void * _Nonnull __restrict kfaddr,
|
||||
void * _Nonnull __restrict kdaddr, size_t len,
|
||||
size_t * __restrict lencopied)
|
||||
{
|
||||
if (lencopied != NULL) {
|
||||
*lencopied = len;
|
||||
}
|
||||
size_t n = strlcpy((char*)kdaddr, (const char*)kfaddr, len);
|
||||
|
||||
memcpy(kdaddr, kfaddr, len);
|
||||
if (lencopied != NULL) {
|
||||
*lencopied = n + 1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -426,11 +426,11 @@ static inline int
|
||||
copyinstr(const void * __restrict udaddr, void * __restrict kaddr,
|
||||
size_t len, size_t * __restrict lencopied)
|
||||
{
|
||||
if (lencopied != NULL) {
|
||||
*lencopied = len;
|
||||
}
|
||||
size_t n = strlcpy((char*)kaddr, (const char*)udaddr, len);
|
||||
|
||||
memcpy(kaddr, udaddr, len);
|
||||
if (lencopied != NULL) {
|
||||
*lencopied = n + 1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -340,7 +340,6 @@ struct kinfo_ofile {
|
||||
#endif
|
||||
|
||||
struct kinfo_file {
|
||||
#ifndef __rtems__
|
||||
int kf_structsize; /* Variable size of record. */
|
||||
int kf_type; /* Descriptor type. */
|
||||
int kf_fd; /* Array index. */
|
||||
@ -447,9 +446,6 @@ struct kinfo_file {
|
||||
uint64_t _kf_cap_spare; /* Space for future cap_rights_t. */
|
||||
/* Truncated before copyout in sysctl */
|
||||
char kf_path[PATH_MAX]; /* Path to file, if any. */
|
||||
#else /* __rtems__ */
|
||||
int kf_dummy;
|
||||
#endif /* __rtems__ */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include <sys/acl.h>
|
||||
#include <sys/ktr.h>
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* The vnode is the focus of all file activity in UNIX. There is a
|
||||
* unique vnode allocated for each active file, each current directory,
|
||||
@ -155,7 +154,9 @@ struct vnode {
|
||||
struct vpollinfo *v_pollinfo; /* i Poll events, p for *v_pi */
|
||||
struct label *v_label; /* MAC label for vnode */
|
||||
struct lockf *v_lockf; /* Byte-level advisory lock list */
|
||||
#ifndef __rtems__
|
||||
struct rangelock v_rl; /* Byte-range lock */
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* clustering stuff
|
||||
@ -380,7 +381,9 @@ struct vattr {
|
||||
MALLOC_DECLARE(M_VNODE);
|
||||
#endif
|
||||
|
||||
#ifndef __rtems__
|
||||
extern u_int ncsizefactor;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Convert between vnode types and inode formats (since POSIX.1
|
||||
@ -718,6 +721,7 @@ int vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio);
|
||||
int vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
|
||||
struct uio *uio);
|
||||
|
||||
#ifndef __rtems__
|
||||
#define vn_rangelock_unlock(vp, cookie) \
|
||||
rangelock_unlock(&(vp)->v_rl, (cookie), VI_MTX(vp))
|
||||
#define vn_rangelock_unlock_range(vp, cookie, start, end) \
|
||||
@ -727,6 +731,12 @@ int vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
|
||||
rangelock_rlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
|
||||
#define vn_rangelock_wlock(vp, start, end) \
|
||||
rangelock_wlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
|
||||
#else /* __rtems__ */
|
||||
#define vn_rangelock_unlock(vp, cookie)
|
||||
#define vn_rangelock_unlock_range(vp, cookie, start, end)
|
||||
#define vn_rangelock_rlock(vp, start, end) NULL
|
||||
#define vn_rangelock_wlock(vp, start, end) NULL
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int vfs_cache_lookup(struct vop_lookup_args *ap);
|
||||
void vfs_timestamp(struct timespec *);
|
||||
@ -925,6 +935,5 @@ void vn_fsid(struct vnode *vp, struct vattr *va);
|
||||
int vn_dir_check_exec(struct vnode *vp, struct componentname *cnp);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#endif /* !_SYS_VNODE_H_ */
|
||||
|
@ -3898,12 +3898,15 @@ uma_zone_reserve_kva(uma_zone_t zone, int count)
|
||||
|
||||
return (1);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* See uma.h */
|
||||
void
|
||||
uma_prealloc(uma_zone_t zone, int items)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct vm_domainset_iter di;
|
||||
#endif /* __rtems__ */
|
||||
uma_domain_t dom;
|
||||
uma_slab_t slab;
|
||||
uma_keg_t keg;
|
||||
@ -3918,8 +3921,10 @@ uma_prealloc(uma_zone_t zone, int items)
|
||||
slabs++;
|
||||
while (slabs-- > 0) {
|
||||
aflags = M_NOWAIT;
|
||||
#ifndef __rtems__
|
||||
vm_domainset_iter_policy_ref_init(&di, &keg->uk_dr, &domain,
|
||||
&aflags);
|
||||
#endif /* __rtems__ */
|
||||
for (;;) {
|
||||
slab = keg_alloc_slab(keg, zone, domain, M_WAITOK,
|
||||
aflags);
|
||||
@ -3931,16 +3936,17 @@ uma_prealloc(uma_zone_t zone, int items)
|
||||
break;
|
||||
}
|
||||
KEG_LOCK(keg);
|
||||
#ifndef __rtems__
|
||||
if (vm_domainset_iter_policy(&di, &domain) != 0) {
|
||||
KEG_UNLOCK(keg);
|
||||
vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask);
|
||||
KEG_LOCK(keg);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
}
|
||||
KEG_UNLOCK(keg);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* See uma.h */
|
||||
static void
|
||||
|
@ -96,6 +96,18 @@ int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,
|
||||
vm_prot_t prot, vm_page_t *ma, int max_count);
|
||||
int vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
|
||||
int fault_flags, int *signo, int *ucode);
|
||||
#else /* __rtems__ */
|
||||
static inline int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,
|
||||
vm_prot_t prot, vm_page_t *ma, int max_count) {
|
||||
vm_offset_t end;
|
||||
if (len == 0)
|
||||
return (0);
|
||||
end = round_page(addr + len);
|
||||
addr = trunc_page(addr);
|
||||
if (atop(end - addr) > max_count)
|
||||
panic("vm_fault_quick_hold_pages: count > max_count");
|
||||
return atop(end - addr);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
int vm_forkproc(struct thread *, struct proc *, struct thread *,
|
||||
struct vmspace *, int);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
@ -41,7 +43,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resource.h>
|
||||
#include <rtems/bsd/sys/resource.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/vmmeter.h>
|
||||
@ -106,6 +108,7 @@ vmcounter_startup(void)
|
||||
}
|
||||
SYSINIT(counter, SI_SUB_KMEM, SI_ORDER_FIRST, vmcounter_startup, NULL);
|
||||
|
||||
#ifndef __rtems__
|
||||
SYSCTL_UINT(_vm, VM_V_FREE_MIN, v_free_min,
|
||||
CTLFLAG_RW, &vm_cnt.v_free_min, 0, "Minimum low-free-pages threshold");
|
||||
SYSCTL_UINT(_vm, VM_V_FREE_TARGET, v_free_target,
|
||||
@ -559,3 +562,4 @@ vm_stats_init(void *arg __unused)
|
||||
}
|
||||
|
||||
SYSINIT(vmstats_init, SI_SUB_VM_CONF, SI_ORDER_FIRST, vm_stats_init, NULL);
|
||||
#endif /* __rtems__ */
|
||||
|
49
libbsd.py
49
libbsd.py
@ -39,6 +39,11 @@ import builder
|
||||
# Default configuration.
|
||||
#
|
||||
_defaults = {
|
||||
#
|
||||
# Global defines, added to the build of all files
|
||||
#
|
||||
'defines': [],
|
||||
|
||||
#
|
||||
# Compile flags
|
||||
#
|
||||
@ -162,6 +167,7 @@ class rtems(builder.Module):
|
||||
mm = self.manager
|
||||
self.addRTEMSKernelSourceFiles(
|
||||
[
|
||||
'fs/rootfs/rootfs.c',
|
||||
'local/bus_if.c',
|
||||
'local/cryptodev_if.c',
|
||||
'local/device_if.c',
|
||||
@ -181,6 +187,8 @@ class rtems(builder.Module):
|
||||
'rtems/rtems-bsd-get-mac-address.c',
|
||||
'rtems/rtems-bsd-get-task-priority.c',
|
||||
'rtems/rtems-bsd-get-task-stack-size.c',
|
||||
'rtems/rtems-bsd-libio.c',
|
||||
'rtems/rtems-bsd-mountroot.c',
|
||||
'rtems/rtems-bsd-syscall-api.c',
|
||||
'rtems/rtems-kernel-assert.c',
|
||||
'rtems/rtems-kernel-autoconf.c',
|
||||
@ -188,8 +196,11 @@ class rtems(builder.Module):
|
||||
'rtems/rtems-kernel-bus-dma-mbuf.c',
|
||||
'rtems/rtems-kernel-bus-root.c',
|
||||
'rtems/rtems-kernel-cam.c',
|
||||
'rtems/rtems-kernel-capability.c',
|
||||
'rtems/rtems-kernel-chunk.c',
|
||||
'rtems/rtems-kernel-delay.c',
|
||||
'rtems/rtems-kernel-dev.c',
|
||||
'rtems/rtems-kernel-dirent.c',
|
||||
'rtems/rtems-kernel-epoch.c',
|
||||
'rtems/rtems-kernel-get-file.c',
|
||||
'rtems/rtems-kernel-init.c',
|
||||
@ -203,6 +214,7 @@ class rtems(builder.Module):
|
||||
'rtems/rtems-kernel-muteximpl.c',
|
||||
'rtems/rtems-kernel-nexus.c',
|
||||
'rtems/rtems-kernel-page.c',
|
||||
'rtems/rtems-kernel-pager.c',
|
||||
'rtems/rtems-kernel-panic.c',
|
||||
'rtems/rtems-kernel-pci_bus.c',
|
||||
'rtems/rtems-kernel-pci_cfgreg.c',
|
||||
@ -215,7 +227,9 @@ class rtems(builder.Module):
|
||||
'rtems/rtems-kernel-timesupport.c',
|
||||
'rtems/rtems-kernel-termioskqueuepoll.c',
|
||||
'rtems/rtems-kernel-thread.c',
|
||||
'rtems/rtems-kernel-vfs.c',
|
||||
'rtems/rtems-kernel-vprintf.c',
|
||||
'rtems/rtems-kernel-vmem.c',
|
||||
'rtems/rtems-kernel-wpa-supplicant.c',
|
||||
'rtems/rtems-legacy-rtrequest.c',
|
||||
'rtems/rtems-legacy-newproc.c',
|
||||
@ -242,6 +256,7 @@ class rtems(builder.Module):
|
||||
'sys/dev/usb/controller/usb_otg_transceiver.c',
|
||||
'sys/dev/usb/controller/usb_otg_transceiver_dump.c',
|
||||
'sys/fs/devfs/devfs_devs.c',
|
||||
'sys/kern/vnode_if.c',
|
||||
'sys/net/if_ppp.c',
|
||||
'sys/net/ppp_tty.c',
|
||||
],
|
||||
@ -367,10 +382,13 @@ class base(builder.Module):
|
||||
'sys/contrib/ck/include/gcc/x86/ck_f_pr.h',
|
||||
'sys/contrib/ck/include/gcc/x86/ck_pr.h',
|
||||
'sys/fs/devfs/devfs_int.h',
|
||||
'sys/fs/pseudofs/pseudofs.h',
|
||||
'sys/fs/pseudofs/pseudofs_internal.h',
|
||||
'sys/security/audit/audit.h',
|
||||
'sys/security/mac/mac_framework.h',
|
||||
'sys/sys/acl.h',
|
||||
'sys/sys/aio.h',
|
||||
'sys/sys/bio.h',
|
||||
'sys/sys/blist.h',
|
||||
'sys/sys/bufobj.h',
|
||||
'sys/sys/buf_ring.h',
|
||||
@ -428,12 +446,14 @@ class base(builder.Module):
|
||||
'sys/sys/mount.h',
|
||||
'sys/sys/_mutex.h',
|
||||
'sys/sys/mutex.h',
|
||||
'sys/sys/namei.h',
|
||||
'sys/sys/nlist_aout.h',
|
||||
'sys/sys/_null.h',
|
||||
'sys/sys/nv.h',
|
||||
'sys/sys/osd.h',
|
||||
'sys/sys/pcpu.h',
|
||||
'sys/sys/_pctrie.h',
|
||||
'sys/sys/pctrie.h',
|
||||
'sys/sys/pipe.h',
|
||||
'sys/sys/priv.h',
|
||||
'sys/sys/proc.h',
|
||||
@ -468,7 +488,9 @@ class base(builder.Module):
|
||||
'sys/sys/stdint.h',
|
||||
'sys/sys/_sx.h',
|
||||
'sys/sys/sx.h',
|
||||
'sys/sys/syscallsubr.h',
|
||||
'sys/sys/sysctl.h',
|
||||
'sys/sys/sysent.h',
|
||||
'sys/sys/sysproto.h',
|
||||
'sys/sys/systm.h',
|
||||
'sys/sys/_task.h',
|
||||
@ -480,6 +502,7 @@ class base(builder.Module):
|
||||
'sys/sys/unpcb.h',
|
||||
'sys/sys/_unrhdr.h',
|
||||
'sys/sys/uuid.h',
|
||||
'sys/sys/vmem.h',
|
||||
'sys/sys/vmmeter.h',
|
||||
'sys/sys/vnode.h',
|
||||
'sys/vm/uma_dbg.h',
|
||||
@ -492,14 +515,16 @@ class base(builder.Module):
|
||||
self.addKernelSpaceSourceFiles(
|
||||
[
|
||||
'sys/contrib/ck/src/ck_epoch.c',
|
||||
'sys/fs/deadfs/dead_vnops.c',
|
||||
'sys/kern/init_main.c',
|
||||
'sys/kern/kern_condvar.c',
|
||||
'sys/kern/kern_conf.c',
|
||||
'sys/kern/kern_descrip.c',
|
||||
'sys/kern/kern_event.c',
|
||||
'sys/kern/kern_hhook.c',
|
||||
'sys/kern/kern_intr.c',
|
||||
'sys/kern/kern_ktr.c',
|
||||
'sys/kern/kern_khelp.c',
|
||||
'sys/kern/kern_ktr.c',
|
||||
'sys/kern/kern_linker.c',
|
||||
'sys/kern/kern_mbuf.c',
|
||||
'sys/kern/kern_mib.c',
|
||||
@ -526,6 +551,7 @@ class base(builder.Module):
|
||||
'sys/kern/subr_kobj.c',
|
||||
'sys/kern/subr_lock.c',
|
||||
'sys/kern/subr_pcpu.c',
|
||||
'sys/kern/subr_pctrie.c',
|
||||
'sys/kern/subr_prf.c',
|
||||
'sys/kern/subr_rman.c',
|
||||
'sys/kern/subr_sbuf.c',
|
||||
@ -543,6 +569,21 @@ class base(builder.Module):
|
||||
'sys/kern/uipc_sockbuf.c',
|
||||
'sys/kern/uipc_socket.c',
|
||||
'sys/kern/uipc_usrreq.c',
|
||||
'sys/kern/vfs_acl.c',
|
||||
'sys/kern/vfs_aio.c',
|
||||
'sys/kern/vfs_bio.c',
|
||||
'sys/kern/vfs_cache.c',
|
||||
#'sys/kern/vfs_cluster.c',
|
||||
'sys/kern/vfs_default.c',
|
||||
'sys/kern/vfs_export.c',
|
||||
#'sys/kern/vfs_extattr.c',
|
||||
'sys/kern/vfs_hash.c',
|
||||
'sys/kern/vfs_init.c',
|
||||
'sys/kern/vfs_lookup.c',
|
||||
'sys/kern/vfs_mount.c',
|
||||
'sys/kern/vfs_subr.c',
|
||||
'sys/kern/vfs_syscalls.c',
|
||||
'sys/kern/vfs_vnops.c',
|
||||
'sys/libkern/crc32.c',
|
||||
'sys/libkern/bcd.c',
|
||||
'sys/libkern/inet_ntoa.c',
|
||||
@ -550,8 +591,13 @@ class base(builder.Module):
|
||||
'sys/libkern/murmur3_32.c',
|
||||
'sys/libkern/random.c',
|
||||
'sys/fs/devfs/devfs_vnops.c',
|
||||
'sys/fs/pseudofs/pseudofs.c',
|
||||
'sys/fs/pseudofs/pseudofs_fileno.c',
|
||||
'sys/fs/pseudofs/pseudofs_vncache.c',
|
||||
'sys/fs/pseudofs/pseudofs_vnops.c',
|
||||
'sys/vm/uma_core.c',
|
||||
'sys/vm/uma_dbg.c',
|
||||
'sys/vm/vm_meter.c',
|
||||
],
|
||||
mm.generator['source']()
|
||||
)
|
||||
@ -1466,6 +1512,7 @@ class dev_nic(builder.Module):
|
||||
'sys/arm64/include/cpu.h',
|
||||
'sys/arm/include/cpufunc.h',
|
||||
'sys/i386/include/md_var.h',
|
||||
'sys/i386/include/intr_machdep.h',
|
||||
'sys/i386/include/cpufunc.h',
|
||||
'sys/x86/include/intr_machdep.h',
|
||||
'sys/x86/include/specialreg.h',
|
||||
|
91
rtemsbsd/fs/rootfs/rootfs.c
Normal file
91
rtemsbsd/fs/rootfs/rootfs.c
Normal file
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Chris Johns
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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 <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include <fs/pseudofs/pseudofs.h>
|
||||
|
||||
static struct pfs_node *rootfs_root;
|
||||
|
||||
static int
|
||||
rootfs_attr(PFS_ATTR_ARGS, int mode)
|
||||
{
|
||||
vap->va_mode = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rootfs_attr_all_rwx(PFS_ATTR_ARGS)
|
||||
{
|
||||
vap->va_mode = 0777;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_rootfs_mkdir(const char *name)
|
||||
{
|
||||
struct pfs_node *dir;
|
||||
dir = pfs_create_dir(rootfs_root, name, rootfs_attr_all_rwx, NULL, NULL,
|
||||
PFS_RDWR | PFS_NOWAIT);
|
||||
if (dir == NULL)
|
||||
return ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_rootfs_rmdir(const char *name)
|
||||
{
|
||||
struct pfs_node *dir;
|
||||
dir = pfs_find_node(rootfs_root, name);
|
||||
if (dir == NULL)
|
||||
return ENOENT;
|
||||
return pfs_destroy(dir);
|
||||
}
|
||||
|
||||
static int rootfs_init(PFS_INIT_ARGS)
|
||||
{
|
||||
rootfs_root = pi->pi_root;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rootfs_uninit(PFS_INIT_ARGS)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PSEUDOFS(rootfs, 1, VFCF_SYNTHETIC);
|
File diff suppressed because it is too large
Load Diff
@ -85,6 +85,12 @@ extern "C" {
|
||||
#define RTEMS_BSD_CFGDECL_DOMAIN_PAGE_MBUFS_SIZE RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT
|
||||
#endif
|
||||
|
||||
#if defined(RTEMS_BSD_CONFIG_DOMAIN_BIO_SIZE)
|
||||
#define RTEMS_BSD_CFGDECL_DOMAIN_BIO_SIZE RTEMS_BSD_CONFIG_DOMAIN_BIO_SIZE
|
||||
#else
|
||||
#define RTEMS_BSD_CFGDECL_DOMAIN_BIO_SIZE RTEMS_BSD_ALLOCATOR_DOMAIN_BIO_DEFAULT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* BSD Kernel modules.
|
||||
*/
|
||||
@ -222,6 +228,12 @@ extern "C" {
|
||||
uintptr_t rtems_bsd_allocator_domain_page_mbuf_size = \
|
||||
RTEMS_BSD_CFGDECL_DOMAIN_PAGE_MBUFS_SIZE;
|
||||
|
||||
/*
|
||||
* Configure the block IO buffer memory size.
|
||||
*/
|
||||
uintptr_t rtems_bsd_allocator_domain_bio_size = \
|
||||
RTEMS_BSD_CFGDECL_DOMAIN_BIO_SIZE;
|
||||
|
||||
/*
|
||||
* If a BSP configuration is requested include the Nexus bus BSP
|
||||
* configuration.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,10 +3,12 @@
|
||||
*
|
||||
* @ingroup rtems_bsd_machine
|
||||
*
|
||||
* @brief TODO.
|
||||
* @brief RTEMS FreeBSD Kernel related machine settings and defines
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Chris Johns <chrisj@rtems.org>. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
@ -40,23 +42,82 @@
|
||||
#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_KERNEL_SPACE_H_
|
||||
#define _RTEMS_BSD_MACHINE_RTEMS_BSD_KERNEL_SPACE_H_
|
||||
|
||||
/* FIXME: Update Newlib */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* FreeBSD warning control
|
||||
*/
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#pragma GCC diagnostic ignored "-Wunused-value"
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#pragma GCC diagnostic ignored "-Wunused-const-variable"
|
||||
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
|
||||
/* FIXME: start: Update Newlib */
|
||||
#define MSIZE 256
|
||||
|
||||
/* FIXME: Update Newlib */
|
||||
#define __GLOBL1(sym) __asm__(".globl " #sym)
|
||||
#define __GLOBL(sym) __GLOBL1(sym)
|
||||
|
||||
#define O_CLOEXEC 0
|
||||
#define IO_NDELAY O_NONBLOCK
|
||||
|
||||
/* FIXME: end: Update Newlib */
|
||||
|
||||
#define FSEARCH O_SEARCH
|
||||
#define O_FSYNC FSYNC
|
||||
|
||||
#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FNONBLOCK|O_DIRECT)
|
||||
#define FCNTLFLAGS (FAPPEND|FASYNC|FNONBLOCK|O_DIRECT)
|
||||
#define FHASLOCK 0
|
||||
|
||||
#define PIPE_NODIRECT
|
||||
|
||||
#define SEEK_DATA 3 /* set file offset to next data past offset */
|
||||
#define SEEK_HOLE 4 /* set file offset to next hole past offset */
|
||||
#define L_SET SEEK_SET
|
||||
#define L_INCR SEEK_CUR
|
||||
#define L_XTND SEEK_END
|
||||
#define O_FSYNC FSYNC
|
||||
#define O_SHLOCK FSHLOCK
|
||||
#define O_EXLOCK FEXLOCK
|
||||
#define POSIX_FADV_NORMAL 0 /* no special treatment */
|
||||
#define POSIX_FADV_RANDOM 1 /* expect random page references */
|
||||
#define POSIX_FADV_SEQUENTIAL 2 /* expect sequential page references */
|
||||
#define POSIX_FADV_WILLNEED 3 /* will need these pages */
|
||||
#define POSIX_FADV_DONTNEED 4 /* dont need these pages */
|
||||
#define POSIX_FADV_NOREUSE 5 /* access data only once */
|
||||
|
||||
/* Used in NFS common code */
|
||||
#define __LINUX_ERRNO_EXTENSIONS__ 1
|
||||
|
||||
#define __FreeBSD__ 1
|
||||
|
||||
/* General define to activate BSD kernel parts */
|
||||
#define _KERNEL 1
|
||||
|
||||
/*
|
||||
* Various developer tracing options. See waf --help and --freebsd-options.
|
||||
*/
|
||||
#ifndef RTEMS_BSD_DESCRIP_TRACE
|
||||
#define RTEMS_BSD_DESCRIP_TRACE (0)
|
||||
#endif
|
||||
#ifndef RTEMS_BSD_SYSCALL_TRACE
|
||||
#define RTEMS_BSD_SYSCALL_TRACE (0)
|
||||
#endif
|
||||
#ifndef RTEMS_BSD_VFS_TRACE
|
||||
#define RTEMS_BSD_VFS_TRACE (0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <machine/rtems-bsd-version.h>
|
||||
#include <machine/rtems-bsd-kernel-namespace.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -74,6 +135,8 @@ void rtems_bsd_assert_func(const char *file, int line, const char *func, const c
|
||||
|
||||
/* General definitions */
|
||||
|
||||
#define MACHINE "rtems"
|
||||
|
||||
#define MACHINE_ARCH "rtems"
|
||||
|
||||
#define M_RTEMS_HEAP 0
|
||||
@ -95,9 +158,92 @@ void rtems_bsd_assert_func(const char *file, int line, const char *func, const c
|
||||
#define EJUSTRETURN (-2) /* don't modify regs, just return */
|
||||
#define ENOIOCTL (-3) /* ioctl not handled by this layer */
|
||||
#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */
|
||||
#define ERELOOKUP (-5) /* retry the directory lookup */
|
||||
|
||||
/* error codes used in the NFS code */
|
||||
#define EBADRPC 72
|
||||
#define EPROGMISMATCH 75
|
||||
#define EAUTH 80
|
||||
#define ENOTCAPABLE 93
|
||||
|
||||
#define EDOOFUS __ELASTERROR
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
typedef unsigned short ushort; /* Sys V compatibility */
|
||||
typedef unsigned int uint; /* Sys V compatibility */
|
||||
|
||||
typedef __UINT64_TYPE__ uoff_t;
|
||||
|
||||
#define __LLONG_MAX __LONG_LONG_MAX__
|
||||
#define __OFF_MAX __LLONG_MAX
|
||||
#define OFF_MAX __OFF_MAX
|
||||
|
||||
#define F_WAIT 0x010 /* Wait until lock is granted */
|
||||
#define F_FLOCK 0x020 /* Use flock(2) semantics for lock */
|
||||
#define F_POSIX 0x040 /* Use POSIX semantics for lock */
|
||||
#define F_REMOTE 0x080 /* Lock owner is remote NFS client */
|
||||
#define F_NOINTR 0x100 /* Ignore signals when waiting */
|
||||
|
||||
#define _PC_ACL_EXTENDED 59
|
||||
#define _PC_ACL_PATH_MAX 60
|
||||
#define _PC_CAP_PRESENT 61
|
||||
#define _PC_INF_PRESENT 62
|
||||
#define _PC_MAC_PRESENT 63
|
||||
#define _PC_ACL_NFS4 64
|
||||
|
||||
#define FFLAGS(oflags) ((oflags) + 1)
|
||||
#define OFLAGS(fflags) ((fflags) - 1)
|
||||
|
||||
#define buffer_arena NULL
|
||||
extern struct vmem *rtems_bsd_transient_arena;
|
||||
#define transient_arena rtems_bsd_transient_arena
|
||||
|
||||
struct uma_zone;
|
||||
extern struct uma_zone* ncl_pbuf_zone;
|
||||
struct uma_zone* pbuf_zsecond_create(char *name, int max);
|
||||
|
||||
/*
|
||||
* Device dev_t handling
|
||||
*/
|
||||
int rtems_bsd__major(dev_t _d);
|
||||
int rtems_bsd__minor(dev_t _d);
|
||||
dev_t rtems_bsd__makedev(int _M, int _m);
|
||||
#define major(d) rtems_bsd__major(d)
|
||||
#define minor(d) rtems_bsd__minor(d)
|
||||
#define makedev(M, m) rtems_bsd__makedev((M), (m))
|
||||
|
||||
/*
|
||||
* VM, avoid bringing the headers across
|
||||
*/
|
||||
#define VM_OBJECT_WLOCK(object)
|
||||
#define VM_OBJECT_WUNLOCK(object)
|
||||
|
||||
/*
|
||||
* From freebsd-oirg/sys/sys/dirent.h
|
||||
*/
|
||||
#define _GENERIC_DIRLEN(namlen) \
|
||||
((__offsetof(struct dirent, d_name) + (namlen) + 1 + 7) & ~7)
|
||||
#define _GENERIC_DIRSIZ(dp) _GENERIC_DIRLEN((dp)->d_namlen)
|
||||
|
||||
/*
|
||||
* From signalvar.h
|
||||
*/
|
||||
#define SIGISMEMBER(set, signo) (0)
|
||||
|
||||
/*
|
||||
* Special knote status bit to indicate the kn_fp is an iop.
|
||||
*/
|
||||
#define KN_FP_IS_IOP 0x10000000
|
||||
|
||||
/*
|
||||
* Ensure that padding bytes are zeroed and that the name is NUL-terminated.
|
||||
*/
|
||||
struct dirent;
|
||||
void dirent_terminate(struct dirent *dp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
330
rtemsbsd/include/machine/rtems-bsd-libio.h
Normal file
330
rtemsbsd/include/machine/rtems-bsd-libio.h
Normal file
@ -0,0 +1,330 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_machine
|
||||
*
|
||||
* @brief LibIO interface for FreeBSD filedesc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Chrs Johns. All rights reserved.
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_LIBIO_H_
|
||||
#define _RTEMS_BSD_MACHINE_RTEMS_BSD_LIBIO_H_
|
||||
|
||||
#include <sys/event.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <machine/rtems-bsd-vfs.h>
|
||||
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/libio_.h>
|
||||
#include <rtems/seterr.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct rtems_bsd_vfs_loc;
|
||||
|
||||
extern const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_nodeops;
|
||||
extern const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_imfsnodeops;
|
||||
extern const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_dirops;
|
||||
extern const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_fileops;
|
||||
|
||||
static int inline rtems_bsd_error_to_status_and_errno(int error)
|
||||
{
|
||||
if (error == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(error);
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
rtems_bsd_libio_fflag_to_flags(u_int fflag)
|
||||
{
|
||||
uint32_t libio_flags = 0;
|
||||
|
||||
if ((fflag & FREAD) == FREAD) {
|
||||
libio_flags |= LIBIO_FLAGS_READ;
|
||||
}
|
||||
|
||||
if ((fflag & FWRITE) == FWRITE) {
|
||||
libio_flags |= LIBIO_FLAGS_WRITE;
|
||||
}
|
||||
|
||||
if ((fflag & FNONBLOCK) == FNONBLOCK) {
|
||||
libio_flags |= LIBIO_FLAGS_NO_DELAY;
|
||||
}
|
||||
|
||||
return (libio_flags);
|
||||
}
|
||||
|
||||
static inline u_int
|
||||
rtems_bsd_libio_flags_to_fflag(uint32_t libio_flags)
|
||||
{
|
||||
u_int fflag = 0;
|
||||
|
||||
if ((libio_flags & LIBIO_FLAGS_READ) == LIBIO_FLAGS_READ) {
|
||||
fflag |= FREAD;
|
||||
}
|
||||
|
||||
if ((libio_flags & LIBIO_FLAGS_WRITE) == LIBIO_FLAGS_WRITE) {
|
||||
fflag |= FWRITE;
|
||||
}
|
||||
|
||||
if ((libio_flags & LIBIO_FLAGS_NO_DELAY) == LIBIO_FLAGS_NO_DELAY) {
|
||||
fflag |= FNONBLOCK;
|
||||
}
|
||||
|
||||
return (fflag);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
rtems_bsd_is_libbsd_nvops(rtems_libio_t *iop)
|
||||
{
|
||||
return (iop->pathinfo.handlers == &rtems_bsd_sysgen_dirops ||
|
||||
iop->pathinfo.handlers == &rtems_bsd_sysgen_fileops);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
rtems_bsd_is_libbsd_descriptor(rtems_libio_t *iop)
|
||||
{
|
||||
return (iop->pathinfo.handlers == &rtems_bsd_sysgen_nodeops ||
|
||||
rtems_bsd_is_libbsd_nvops(iop));
|
||||
}
|
||||
|
||||
static inline rtems_libio_t *
|
||||
rtems_bsd_libio_loc_to_iop(const rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
return (rtems_libio_t *)RTEMS_DECONST(
|
||||
rtems_filesystem_location_info_t *, loc)
|
||||
->node_access;
|
||||
}
|
||||
|
||||
struct socket;
|
||||
|
||||
static inline struct socket *
|
||||
rtems_bsd_libio_imfs_loc_to_so(const rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
return (struct socket *)RTEMS_DECONST(
|
||||
rtems_filesystem_location_info_t *, loc)
|
||||
->node_access_2;
|
||||
}
|
||||
|
||||
static struct vnode *
|
||||
rtems_bsd_libio_loc_to_vnode(const rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
return (struct vnode *)RTEMS_DECONST(
|
||||
rtems_filesystem_location_info_t *, loc)
|
||||
->node_access;
|
||||
}
|
||||
|
||||
static struct vnode *
|
||||
rtems_bsd_libio_loc_to_vnode_dir(const rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
return (struct vnode *)RTEMS_DECONST(
|
||||
rtems_filesystem_location_info_t *, loc)
|
||||
->node_access_2;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rtems_bsd_libio_iop_free(rtems_libio_t *iop)
|
||||
{
|
||||
rtems_libio_free(iop);
|
||||
}
|
||||
|
||||
static int
|
||||
rtems_bsd_libio_iop_to_descriptor(rtems_libio_t *iop)
|
||||
{
|
||||
return (int)iop->data0;
|
||||
}
|
||||
|
||||
static struct vnode *
|
||||
rtems_bsd_libio_iop_to_vnode(rtems_libio_t *iop)
|
||||
{
|
||||
return rtems_bsd_libio_loc_to_vnode(&iop->pathinfo);
|
||||
}
|
||||
|
||||
static int
|
||||
rtems_bsd_libio_fd_to_descriptor(int fd)
|
||||
{
|
||||
return rtems_bsd_libio_iop_to_descriptor(rtems_libio_iop(fd));
|
||||
}
|
||||
|
||||
static inline struct file *
|
||||
rtems_bsd_libio_iop_to_file_hold(rtems_libio_t *iop, struct thread *td)
|
||||
{
|
||||
struct file *fp;
|
||||
int error = fget_unlocked(td->td_proc->p_fd,
|
||||
rtems_bsd_libio_iop_to_descriptor(iop), NULL, &fp, NULL);
|
||||
if (error != 0) {
|
||||
fp = NULL;
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
static inline int
|
||||
rtems_bsd_file_to_libio_fd(struct file *fp)
|
||||
{
|
||||
return fp->f_io - rtems_libio_iops;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rtems_bsd_libio_iop_set_bsd_descriptor(rtems_libio_t *iop, int fd)
|
||||
{
|
||||
iop->data0 = fd;
|
||||
/* if not vnops the fstat passes a loc, need to get the iop to get the
|
||||
* fp */
|
||||
if (!rtems_bsd_is_libbsd_nvops(iop)) {
|
||||
iop->pathinfo.node_access = iop;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
rtems_bsd_libio_iop_set_bsd_file(rtems_libio_t *iop, struct file *fp)
|
||||
{
|
||||
fp->f_io = iop;
|
||||
}
|
||||
|
||||
/*
|
||||
* The fd is a libio file descriptor.
|
||||
*
|
||||
* Return -1 if the descriptor is closed or not valid. The descriptor is not
|
||||
* held.
|
||||
*
|
||||
* If open hold the descriptor. If the descriptor referneces a BSD
|
||||
* descriptor return the BSD descriptor else return the libio descriptor.
|
||||
*
|
||||
* Optionally return the iop in *iopp if the descriptor if a libio descriptor
|
||||
* else return NULL.
|
||||
*/
|
||||
static inline int
|
||||
rtems_bsd_libio_iop_hold(int fd, rtems_libio_t **iopp)
|
||||
{
|
||||
rtems_libio_t *iop = NULL;
|
||||
unsigned int flags = 0;
|
||||
int ffd = -1;
|
||||
if (fd < rtems_libio_number_iops) {
|
||||
iop = rtems_libio_iop(fd);
|
||||
flags = rtems_libio_iop_hold(iop);
|
||||
if ((flags & LIBIO_FLAGS_OPEN) != 0) {
|
||||
if (rtems_bsd_is_libbsd_descriptor(iop)) {
|
||||
ffd = rtems_bsd_libio_iop_to_descriptor(iop);
|
||||
if (iopp != NULL) {
|
||||
*iopp = NULL;
|
||||
}
|
||||
} else {
|
||||
ffd = fd;
|
||||
if (iopp != NULL) {
|
||||
*iopp = iop;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rtems_libio_iop_drop(iop);
|
||||
}
|
||||
if (RTEMS_BSD_DESCRIP_TRACE)
|
||||
flags = iop->flags;
|
||||
} else {
|
||||
*iopp = NULL;
|
||||
}
|
||||
if (RTEMS_BSD_DESCRIP_TRACE)
|
||||
printf("bsd: iop: hold: fd=%d ffd=%d refs=%d iop=%p by %p\n",
|
||||
fd, ffd, flags >> 12, iop, __builtin_return_address(0));
|
||||
return ffd;
|
||||
}
|
||||
|
||||
static inline int
|
||||
rtems_bsd_libio_iop_drop(int fd)
|
||||
{
|
||||
if (RTEMS_BSD_DESCRIP_TRACE)
|
||||
printf("bsd: iop: drop: fd=%d refs=%d by %p\n", fd,
|
||||
rtems_libio_iop(fd)->flags >> 12,
|
||||
__builtin_return_address(0));
|
||||
rtems_libio_iop_drop(rtems_libio_iop(fd));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
rtems_bsd_libio_fo_poll(int fd, struct file *fp, int events,
|
||||
struct ucred *active_cred, struct thread *td)
|
||||
{
|
||||
int error;
|
||||
if (fp == NULL) {
|
||||
rtems_libio_t *iop = rtems_libio_iop(fd);
|
||||
error = (*iop->pathinfo.handlers->poll_h)(iop, events);
|
||||
} else {
|
||||
error = (*fp->f_ops->fo_poll)(fp, events, active_cred, td);
|
||||
fd = rtems_bsd_file_to_libio_fd(fp);
|
||||
}
|
||||
rtems_bsd_libio_iop_drop(fd);
|
||||
return error;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rtems_bsd_libio_iop_to_knote(struct knote *kn, rtems_libio_t *iop)
|
||||
{
|
||||
kn->kn_fp = (struct file *)iop;
|
||||
}
|
||||
|
||||
static inline struct kqueue *
|
||||
rtems_bsd_libio_knote_to_kq(struct knote *kn)
|
||||
{
|
||||
struct kqueue *kq = kn->kn_kq;
|
||||
if ((kn->kn_status & KN_FP_IS_IOP) == 0) {
|
||||
if (kq != kn->kn_fp->f_data)
|
||||
panic("libio kq wrong\n");
|
||||
}
|
||||
return kq;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an iop with null file system mount or NULL is ENFILE.
|
||||
*/
|
||||
rtems_libio_t *rtems_bsd_libio_iop_allocate(void);
|
||||
|
||||
/*
|
||||
* Returns the libio descriptor or -1 if ENFILE.
|
||||
*/
|
||||
int rtems_bsd_libio_iop_allocate_with_file(
|
||||
struct thread *td, int fd, const rtems_filesystem_file_handlers_r *ops);
|
||||
|
||||
/*
|
||||
* Set the BSD file descriptor in the iop. Returns 0 if successful or an error
|
||||
* number,
|
||||
*/
|
||||
int rtems_bsd_libio_iop_set_bsd_fd(struct thread *td, int fd,
|
||||
rtems_libio_t *iop, const rtems_filesystem_file_handlers_r *ops);
|
||||
|
||||
/*
|
||||
* Set the vnode in the libio location.
|
||||
*/
|
||||
void rtems_bsd_libio_loc_set_vnode(
|
||||
rtems_filesystem_location_info_t *loc, struct vnode *vn);
|
||||
void rtems_bsd_libio_loc_set_vnode_dir(
|
||||
rtems_filesystem_location_info_t *loc, struct vnode *dvn);
|
||||
|
||||
#endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_LIBIO_H_ */
|
@ -49,6 +49,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
@ -61,6 +62,8 @@ void *rtems_bsd_page_alloc(uintptr_t size_in_bytes, int wait);
|
||||
|
||||
void rtems_bsd_page_free(void *addr);
|
||||
|
||||
void vm_pager_bufferinit(void);
|
||||
|
||||
static inline void **
|
||||
rtems_bsd_page_get_object_entry(void *addr)
|
||||
{
|
||||
|
82
rtemsbsd/include/machine/rtems-bsd-vfs.h
Normal file
82
rtemsbsd/include/machine/rtems-bsd-vfs.h
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_machine
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 Chris Johns <chris@contemporary.software>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_VFS_H_
|
||||
#define _RTEMS_BSD_MACHINE_RTEMS_BSD_VFS_H_
|
||||
|
||||
#include <rtems/libio.h>
|
||||
|
||||
extern const rtems_filesystem_operations_table rtems_bsd_vfsops;
|
||||
|
||||
int rtems_bsd_vfs_mount_init(rtems_filesystem_mount_table_entry_t *mt_entry);
|
||||
|
||||
void rtems_bsd_vfs_mt_entry_lock(
|
||||
const rtems_filesystem_mount_table_entry_t *mt_entry);
|
||||
void rtems_bsd_vfs_mt_entry_unlock(
|
||||
const rtems_filesystem_mount_table_entry_t *mt_entry);
|
||||
void rtems_bsd_vfs_eval_path(rtems_filesystem_eval_path_context_t *ctx);
|
||||
bool rtems_bsd_vfs_are_nodes_equal(const rtems_filesystem_location_info_t *a,
|
||||
const rtems_filesystem_location_info_t *b);
|
||||
int rtems_bsd_vfs_link(const rtems_filesystem_location_info_t *parentloc,
|
||||
const rtems_filesystem_location_info_t *targetloc, const char *name,
|
||||
size_t namelen);
|
||||
int rtems_bsd_vfs_fchmod(
|
||||
const rtems_filesystem_location_info_t *loc, mode_t mode);
|
||||
int rtems_bsd_vfs_chown(
|
||||
const rtems_filesystem_location_info_t *loc, uid_t owner, gid_t group);
|
||||
int rtems_bsd_vfs_clonenode(rtems_filesystem_location_info_t *loc);
|
||||
void rtems_bsd_vfs_freenode(const rtems_filesystem_location_info_t *loc);
|
||||
int rtems_bsd_vfs_mount(rtems_filesystem_mount_table_entry_t *mt_entry);
|
||||
int rtems_bsd_vfs_fsmount_me(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry, const void *data);
|
||||
int rtems_bsd_vfs_unmount(rtems_filesystem_mount_table_entry_t *mt_entry);
|
||||
void rtems_bsd_vfs_fsunmount_me(rtems_filesystem_mount_table_entry_t *mt_entry);
|
||||
int rtems_bsd_vfs_mknod(const rtems_filesystem_location_info_t *parentloc,
|
||||
const char *name, size_t namelen, mode_t mode, dev_t dev);
|
||||
int rtems_bsd_vfs_rmnod(const rtems_filesystem_location_info_t *parentloc,
|
||||
const rtems_filesystem_location_info_t *loc);
|
||||
int rtems_bsd_vfs_utimens(
|
||||
const rtems_filesystem_location_info_t *loc, time_t actime, time_t modtime);
|
||||
int rtems_bsd_vfs_symlink(const rtems_filesystem_location_info_t *parentloc,
|
||||
const char *name, size_t namelen, const char *target);
|
||||
ssize_t rtems_bsd_vfs_readlink(
|
||||
const rtems_filesystem_location_info_t *loc, char *buf, size_t bufsize);
|
||||
int rtems_bsd_vfs_rename(const rtems_filesystem_location_info_t *oldparentloc,
|
||||
const rtems_filesystem_location_info_t *oldloc,
|
||||
const rtems_filesystem_location_info_t *newparentloc, const char *name,
|
||||
size_t namelen);
|
||||
int rtems_bsd_vfs_statvfs(
|
||||
const rtems_filesystem_location_info_t *loc, struct statvfs *buf);
|
||||
|
||||
#endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_VFS_H_ */
|
@ -58,6 +58,12 @@ extern "C" {
|
||||
*/
|
||||
#define RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT (8 * 1024 * 1024)
|
||||
|
||||
/*
|
||||
* The default block IO buffer memory size. Do not change, use
|
||||
* RTEMS_BSD_CONFIG_DOMAIN_BIO_SIZE to override for your application.
|
||||
*/
|
||||
#define RTEMS_BSD_ALLOCATOR_DOMAIN_BIO_DEFAULT (4 * 1024 * 1024)
|
||||
|
||||
typedef enum {
|
||||
RTEMS_BSD_RES_IRQ = 1,
|
||||
RTEMS_BSD_RES_MEMORY = 3
|
||||
@ -165,6 +171,7 @@ size_t rtems_bsd_get_task_stack_size(const char *name);
|
||||
typedef enum {
|
||||
RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE,
|
||||
RTEMS_BSD_ALLOCATOR_DOMAIN_MBUF,
|
||||
RTEMS_BSD_ALLOCATOR_DOMAIN_BIO,
|
||||
RTEMS_BSD_ALLOCATOR_DOMAIN_MALLOC
|
||||
} rtems_bsd_allocator_domain;
|
||||
|
||||
@ -175,6 +182,13 @@ typedef enum {
|
||||
*/
|
||||
extern uintptr_t rtems_bsd_allocator_domain_page_mbuf_size;
|
||||
|
||||
/**
|
||||
* @brief The size for the block IO default buffer memory.
|
||||
*
|
||||
* Applications may set this value to change the value returned by the default.
|
||||
*/
|
||||
extern uintptr_t rtems_bsd_allocator_domain_bio_size;
|
||||
|
||||
/**
|
||||
* @brief Returns the size for a specific allocator domain.
|
||||
*
|
||||
|
0
rtemsbsd/include/rtems/bsd/local/opt_pseudofs.h
Normal file
0
rtemsbsd/include/rtems/bsd/local/opt_pseudofs.h
Normal file
0
rtemsbsd/include/rtems/bsd/local/opt_swap.h
Normal file
0
rtemsbsd/include/rtems/bsd/local/opt_swap.h
Normal file
0
rtemsbsd/include/rtems/bsd/local/opt_watchdog.h
Normal file
0
rtemsbsd/include/rtems/bsd/local/opt_watchdog.h
Normal file
1951
rtemsbsd/include/rtems/bsd/local/vnode_if.h
Normal file
1951
rtemsbsd/include/rtems/bsd/local/vnode_if.h
Normal file
File diff suppressed because it is too large
Load Diff
84
rtemsbsd/include/rtems/bsd/local/vnode_if_newproto.h
Normal file
84
rtemsbsd/include/rtems/bsd/local/vnode_if_newproto.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is produced automatically.
|
||||
* Do not modify anything in here by hand.
|
||||
*
|
||||
* Created from $FreeBSD$
|
||||
*/
|
||||
|
||||
|
||||
struct vop_vector {
|
||||
struct vop_vector *vop_default;
|
||||
vop_bypass_t *vop_bypass;
|
||||
vop_islocked_t *vop_islocked;
|
||||
vop_lookup_t *vop_lookup;
|
||||
vop_cachedlookup_t *vop_cachedlookup;
|
||||
vop_create_t *vop_create;
|
||||
vop_whiteout_t *vop_whiteout;
|
||||
vop_mknod_t *vop_mknod;
|
||||
vop_open_t *vop_open;
|
||||
vop_close_t *vop_close;
|
||||
vop_access_t *vop_access;
|
||||
vop_accessx_t *vop_accessx;
|
||||
vop_getattr_t *vop_getattr;
|
||||
vop_setattr_t *vop_setattr;
|
||||
vop_markatime_t *vop_markatime;
|
||||
vop_read_t *vop_read;
|
||||
vop_write_t *vop_write;
|
||||
vop_ioctl_t *vop_ioctl;
|
||||
vop_poll_t *vop_poll;
|
||||
vop_kqfilter_t *vop_kqfilter;
|
||||
vop_revoke_t *vop_revoke;
|
||||
vop_fsync_t *vop_fsync;
|
||||
vop_remove_t *vop_remove;
|
||||
vop_link_t *vop_link;
|
||||
vop_rename_t *vop_rename;
|
||||
vop_mkdir_t *vop_mkdir;
|
||||
vop_rmdir_t *vop_rmdir;
|
||||
vop_symlink_t *vop_symlink;
|
||||
vop_readdir_t *vop_readdir;
|
||||
vop_readlink_t *vop_readlink;
|
||||
vop_inactive_t *vop_inactive;
|
||||
vop_reclaim_t *vop_reclaim;
|
||||
vop_lock1_t *vop_lock1;
|
||||
vop_unlock_t *vop_unlock;
|
||||
vop_bmap_t *vop_bmap;
|
||||
vop_strategy_t *vop_strategy;
|
||||
vop_getwritemount_t *vop_getwritemount;
|
||||
vop_print_t *vop_print;
|
||||
vop_pathconf_t *vop_pathconf;
|
||||
vop_advlock_t *vop_advlock;
|
||||
vop_advlockasync_t *vop_advlockasync;
|
||||
vop_advlockpurge_t *vop_advlockpurge;
|
||||
vop_reallocblks_t *vop_reallocblks;
|
||||
vop_getpages_t *vop_getpages;
|
||||
vop_getpages_async_t *vop_getpages_async;
|
||||
vop_putpages_t *vop_putpages;
|
||||
vop_getacl_t *vop_getacl;
|
||||
vop_setacl_t *vop_setacl;
|
||||
vop_aclcheck_t *vop_aclcheck;
|
||||
vop_closeextattr_t *vop_closeextattr;
|
||||
vop_getextattr_t *vop_getextattr;
|
||||
vop_listextattr_t *vop_listextattr;
|
||||
vop_openextattr_t *vop_openextattr;
|
||||
vop_deleteextattr_t *vop_deleteextattr;
|
||||
vop_setextattr_t *vop_setextattr;
|
||||
vop_setlabel_t *vop_setlabel;
|
||||
vop_vptofh_t *vop_vptofh;
|
||||
vop_vptocnp_t *vop_vptocnp;
|
||||
vop_allocate_t *vop_allocate;
|
||||
vop_advise_t *vop_advise;
|
||||
vop_unp_bind_t *vop_unp_bind;
|
||||
vop_unp_connect_t *vop_unp_connect;
|
||||
vop_unp_detach_t *vop_unp_detach;
|
||||
vop_is_text_t *vop_is_text;
|
||||
vop_set_text_t *vop_set_text;
|
||||
vop_unset_text_t *vop_unset_text;
|
||||
vop_get_writecount_t *vop_get_writecount;
|
||||
vop_add_writecount_t *vop_add_writecount;
|
||||
vop_fdatasync_t *vop_fdatasync;
|
||||
vop_spare1_t *vop_spare1;
|
||||
vop_spare2_t *vop_spare2;
|
||||
vop_spare3_t *vop_spare3;
|
||||
vop_spare4_t *vop_spare4;
|
||||
vop_spare5_t *vop_spare5;
|
||||
};
|
224
rtemsbsd/include/rtems/bsd/local/vnode_if_typedef.h
Normal file
224
rtemsbsd/include/rtems/bsd/local/vnode_if_typedef.h
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* This file is produced automatically.
|
||||
* Do not modify anything in here by hand.
|
||||
*
|
||||
* Created from $FreeBSD$
|
||||
*/
|
||||
|
||||
|
||||
struct vop_islocked_args;
|
||||
typedef int vop_islocked_t(struct vop_islocked_args *);
|
||||
|
||||
struct vop_lookup_args;
|
||||
typedef int vop_lookup_t(struct vop_lookup_args *);
|
||||
|
||||
struct vop_cachedlookup_args;
|
||||
typedef int vop_cachedlookup_t(struct vop_cachedlookup_args *);
|
||||
|
||||
struct vop_create_args;
|
||||
typedef int vop_create_t(struct vop_create_args *);
|
||||
|
||||
struct vop_whiteout_args;
|
||||
typedef int vop_whiteout_t(struct vop_whiteout_args *);
|
||||
|
||||
struct vop_mknod_args;
|
||||
typedef int vop_mknod_t(struct vop_mknod_args *);
|
||||
|
||||
struct vop_open_args;
|
||||
typedef int vop_open_t(struct vop_open_args *);
|
||||
|
||||
struct vop_close_args;
|
||||
typedef int vop_close_t(struct vop_close_args *);
|
||||
|
||||
struct vop_access_args;
|
||||
typedef int vop_access_t(struct vop_access_args *);
|
||||
|
||||
struct vop_accessx_args;
|
||||
typedef int vop_accessx_t(struct vop_accessx_args *);
|
||||
|
||||
struct vop_getattr_args;
|
||||
typedef int vop_getattr_t(struct vop_getattr_args *);
|
||||
|
||||
struct vop_setattr_args;
|
||||
typedef int vop_setattr_t(struct vop_setattr_args *);
|
||||
|
||||
struct vop_markatime_args;
|
||||
typedef int vop_markatime_t(struct vop_markatime_args *);
|
||||
|
||||
struct vop_read_args;
|
||||
typedef int vop_read_t(struct vop_read_args *);
|
||||
|
||||
struct vop_write_args;
|
||||
typedef int vop_write_t(struct vop_write_args *);
|
||||
|
||||
struct vop_ioctl_args;
|
||||
typedef int vop_ioctl_t(struct vop_ioctl_args *);
|
||||
|
||||
struct vop_poll_args;
|
||||
typedef int vop_poll_t(struct vop_poll_args *);
|
||||
|
||||
struct vop_kqfilter_args;
|
||||
typedef int vop_kqfilter_t(struct vop_kqfilter_args *);
|
||||
|
||||
struct vop_revoke_args;
|
||||
typedef int vop_revoke_t(struct vop_revoke_args *);
|
||||
|
||||
struct vop_fsync_args;
|
||||
typedef int vop_fsync_t(struct vop_fsync_args *);
|
||||
|
||||
struct vop_remove_args;
|
||||
typedef int vop_remove_t(struct vop_remove_args *);
|
||||
|
||||
struct vop_link_args;
|
||||
typedef int vop_link_t(struct vop_link_args *);
|
||||
|
||||
struct vop_rename_args;
|
||||
typedef int vop_rename_t(struct vop_rename_args *);
|
||||
|
||||
struct vop_mkdir_args;
|
||||
typedef int vop_mkdir_t(struct vop_mkdir_args *);
|
||||
|
||||
struct vop_rmdir_args;
|
||||
typedef int vop_rmdir_t(struct vop_rmdir_args *);
|
||||
|
||||
struct vop_symlink_args;
|
||||
typedef int vop_symlink_t(struct vop_symlink_args *);
|
||||
|
||||
struct vop_readdir_args;
|
||||
typedef int vop_readdir_t(struct vop_readdir_args *);
|
||||
|
||||
struct vop_readlink_args;
|
||||
typedef int vop_readlink_t(struct vop_readlink_args *);
|
||||
|
||||
struct vop_inactive_args;
|
||||
typedef int vop_inactive_t(struct vop_inactive_args *);
|
||||
|
||||
struct vop_reclaim_args;
|
||||
typedef int vop_reclaim_t(struct vop_reclaim_args *);
|
||||
|
||||
struct vop_lock1_args;
|
||||
typedef int vop_lock1_t(struct vop_lock1_args *);
|
||||
|
||||
struct vop_unlock_args;
|
||||
typedef int vop_unlock_t(struct vop_unlock_args *);
|
||||
|
||||
struct vop_bmap_args;
|
||||
typedef int vop_bmap_t(struct vop_bmap_args *);
|
||||
|
||||
struct vop_strategy_args;
|
||||
typedef int vop_strategy_t(struct vop_strategy_args *);
|
||||
|
||||
struct vop_getwritemount_args;
|
||||
typedef int vop_getwritemount_t(struct vop_getwritemount_args *);
|
||||
|
||||
struct vop_print_args;
|
||||
typedef int vop_print_t(struct vop_print_args *);
|
||||
|
||||
struct vop_pathconf_args;
|
||||
typedef int vop_pathconf_t(struct vop_pathconf_args *);
|
||||
|
||||
struct vop_advlock_args;
|
||||
typedef int vop_advlock_t(struct vop_advlock_args *);
|
||||
|
||||
struct vop_advlockasync_args;
|
||||
typedef int vop_advlockasync_t(struct vop_advlockasync_args *);
|
||||
|
||||
struct vop_advlockpurge_args;
|
||||
typedef int vop_advlockpurge_t(struct vop_advlockpurge_args *);
|
||||
|
||||
struct vop_reallocblks_args;
|
||||
typedef int vop_reallocblks_t(struct vop_reallocblks_args *);
|
||||
|
||||
struct vop_getpages_args;
|
||||
typedef int vop_getpages_t(struct vop_getpages_args *);
|
||||
|
||||
struct vop_getpages_async_args;
|
||||
typedef int vop_getpages_async_t(struct vop_getpages_async_args *);
|
||||
|
||||
struct vop_putpages_args;
|
||||
typedef int vop_putpages_t(struct vop_putpages_args *);
|
||||
|
||||
struct vop_getacl_args;
|
||||
typedef int vop_getacl_t(struct vop_getacl_args *);
|
||||
|
||||
struct vop_setacl_args;
|
||||
typedef int vop_setacl_t(struct vop_setacl_args *);
|
||||
|
||||
struct vop_aclcheck_args;
|
||||
typedef int vop_aclcheck_t(struct vop_aclcheck_args *);
|
||||
|
||||
struct vop_closeextattr_args;
|
||||
typedef int vop_closeextattr_t(struct vop_closeextattr_args *);
|
||||
|
||||
struct vop_getextattr_args;
|
||||
typedef int vop_getextattr_t(struct vop_getextattr_args *);
|
||||
|
||||
struct vop_listextattr_args;
|
||||
typedef int vop_listextattr_t(struct vop_listextattr_args *);
|
||||
|
||||
struct vop_openextattr_args;
|
||||
typedef int vop_openextattr_t(struct vop_openextattr_args *);
|
||||
|
||||
struct vop_deleteextattr_args;
|
||||
typedef int vop_deleteextattr_t(struct vop_deleteextattr_args *);
|
||||
|
||||
struct vop_setextattr_args;
|
||||
typedef int vop_setextattr_t(struct vop_setextattr_args *);
|
||||
|
||||
struct vop_setlabel_args;
|
||||
typedef int vop_setlabel_t(struct vop_setlabel_args *);
|
||||
|
||||
struct vop_vptofh_args;
|
||||
typedef int vop_vptofh_t(struct vop_vptofh_args *);
|
||||
|
||||
struct vop_vptocnp_args;
|
||||
typedef int vop_vptocnp_t(struct vop_vptocnp_args *);
|
||||
|
||||
struct vop_allocate_args;
|
||||
typedef int vop_allocate_t(struct vop_allocate_args *);
|
||||
|
||||
struct vop_advise_args;
|
||||
typedef int vop_advise_t(struct vop_advise_args *);
|
||||
|
||||
struct vop_unp_bind_args;
|
||||
typedef int vop_unp_bind_t(struct vop_unp_bind_args *);
|
||||
|
||||
struct vop_unp_connect_args;
|
||||
typedef int vop_unp_connect_t(struct vop_unp_connect_args *);
|
||||
|
||||
struct vop_unp_detach_args;
|
||||
typedef int vop_unp_detach_t(struct vop_unp_detach_args *);
|
||||
|
||||
struct vop_is_text_args;
|
||||
typedef int vop_is_text_t(struct vop_is_text_args *);
|
||||
|
||||
struct vop_set_text_args;
|
||||
typedef int vop_set_text_t(struct vop_set_text_args *);
|
||||
|
||||
struct vop_unset_text_args;
|
||||
typedef int vop_unset_text_t(struct vop_unset_text_args *);
|
||||
|
||||
struct vop_get_writecount_args;
|
||||
typedef int vop_get_writecount_t(struct vop_get_writecount_args *);
|
||||
|
||||
struct vop_add_writecount_args;
|
||||
typedef int vop_add_writecount_t(struct vop_add_writecount_args *);
|
||||
|
||||
struct vop_fdatasync_args;
|
||||
typedef int vop_fdatasync_t(struct vop_fdatasync_args *);
|
||||
|
||||
struct vop_spare1_args;
|
||||
typedef int vop_spare1_t(struct vop_spare1_args *);
|
||||
|
||||
struct vop_spare2_args;
|
||||
typedef int vop_spare2_t(struct vop_spare2_args *);
|
||||
|
||||
struct vop_spare3_args;
|
||||
typedef int vop_spare3_t(struct vop_spare3_args *);
|
||||
|
||||
struct vop_spare4_args;
|
||||
typedef int vop_spare4_t(struct vop_spare4_args *);
|
||||
|
||||
struct vop_spare5_args;
|
||||
typedef int vop_spare5_t(struct vop_spare5_args *);
|
||||
|
51
rtemsbsd/include/rtems/bsd/rootfs.h
Normal file
51
rtemsbsd/include/rtems/bsd/rootfs.h
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 20206 Chris Johns. All rights reserved.
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _RTEMS_BSD_ROOTFS_H_
|
||||
#define _RTEMS_BSD_ROOTFS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Short cut to creating a directory in the root file system.
|
||||
*/
|
||||
int rtems_bsd_rootfs_mkdir(const char *name);
|
||||
int rtems_bsd_rootfs_rmdir(const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _RTEMS_BSD_ROOTFS_H_ */
|
@ -1 +0,0 @@
|
||||
/* EMPTY */
|
@ -1 +0,0 @@
|
||||
/* EMPTY */
|
@ -1 +0,0 @@
|
||||
/* EMPTY */
|
@ -1 +1,16 @@
|
||||
/* EMPTY */
|
||||
#ifndef RTEMS_VM_OBJCT_H
|
||||
#define RTEMS_VM_OBJCT_H
|
||||
|
||||
/*
|
||||
* Helpers to perform conversion between vm_object page indexes and offsets.
|
||||
* IDX_TO_OFF() converts an index into an offset.
|
||||
* OFF_TO_IDX() converts an offset into an index.
|
||||
* OBJ_MAX_SIZE specifies the maximum page index corresponding to the
|
||||
* maximum unsigned offset.
|
||||
*/
|
||||
#define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT)
|
||||
#define OFF_TO_IDX(off) ((vm_pindex_t)(((vm_ooffset_t)(off)) >> PAGE_SHIFT))
|
||||
#define UOFF_TO_IDX(off) OFF_TO_IDX(off)
|
||||
#define OBJ_MAX_SIZE (OFF_TO_IDX(UINT64_MAX) + 1)
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,20 @@
|
||||
#ifndef RTEMS_VM_PAGER_H
|
||||
#define RTEMS_VM_PAGER_H
|
||||
|
||||
/*
|
||||
* get/put return values
|
||||
* OK operation was successful
|
||||
* BAD specified data was out of the accepted range
|
||||
* FAIL specified data was in range, but doesn't exist
|
||||
* PEND operations was initiated but not completed
|
||||
* ERROR error while accessing data that is in range and exists
|
||||
* AGAIN temporary resource shortage prevented operation from happening
|
||||
*/
|
||||
#define VM_PAGER_OK 0
|
||||
#define VM_PAGER_BAD 1
|
||||
#define VM_PAGER_FAIL 2
|
||||
#define VM_PAGER_PEND 3
|
||||
#define VM_PAGER_ERROR 4
|
||||
#define VM_PAGER_AGAIN 5
|
||||
|
||||
#endif
|
@ -40,4 +40,7 @@
|
||||
|
||||
#include <rtems/bsd/bsd.h>
|
||||
|
||||
uintptr_t rtems_bsd_allocator_domain_page_mbuf_size = RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT;
|
||||
uintptr_t rtems_bsd_allocator_domain_page_mbuf_size =
|
||||
RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT;
|
||||
uintptr_t rtems_bsd_allocator_domain_bio_size =
|
||||
RTEMS_BSD_ALLOCATOR_DOMAIN_BIO_DEFAULT;
|
||||
|
@ -45,13 +45,16 @@ rtems_bsd_get_allocator_domain_size(rtems_bsd_allocator_domain domain)
|
||||
uintptr_t size;
|
||||
|
||||
switch (domain) {
|
||||
case RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE:
|
||||
case RTEMS_BSD_ALLOCATOR_DOMAIN_MBUF:
|
||||
size = rtems_bsd_allocator_domain_page_mbuf_size;
|
||||
break;
|
||||
default:
|
||||
size = 0;
|
||||
break;
|
||||
case RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE:
|
||||
case RTEMS_BSD_ALLOCATOR_DOMAIN_MBUF:
|
||||
size = rtems_bsd_allocator_domain_page_mbuf_size;
|
||||
break;
|
||||
case RTEMS_BSD_ALLOCATOR_DOMAIN_BIO:
|
||||
size = rtems_bsd_allocator_domain_bio_size;
|
||||
break;
|
||||
default:
|
||||
size = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return (size);
|
||||
|
193
rtemsbsd/rtems/rtems-bsd-libio.c
Normal file
193
rtemsbsd/rtems/rtems-bsd-libio.c
Normal file
@ -0,0 +1,193 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2020 Chris Johns. All Rights Reserved.
|
||||
*
|
||||
* 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 FREEBSD PROJECT ``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 FREEBSD PROJECT 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 <sys/param.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include <machine/rtems-bsd-libio.h>
|
||||
|
||||
#include <rtems/libio.h>
|
||||
|
||||
rtems_libio_t *
|
||||
rtems_bsd_libio_iop_allocate(void)
|
||||
{
|
||||
rtems_libio_t *iop = rtems_libio_allocate();
|
||||
if (iop != NULL) {
|
||||
iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry;
|
||||
rtems_filesystem_location_add_to_mt_entry(&iop->pathinfo);
|
||||
}
|
||||
return iop;
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_libio_iop_allocate_with_file(
|
||||
struct thread *td, int fd, const rtems_filesystem_file_handlers_r *ops)
|
||||
{
|
||||
rtems_libio_t *iop = rtems_bsd_libio_iop_allocate();
|
||||
int iofd = -1;
|
||||
if (iop != NULL) {
|
||||
int error = rtems_bsd_libio_iop_set_bsd_fd(td, fd, iop, ops);
|
||||
/*
|
||||
* The fp is held and needs to be dropped and that drops the
|
||||
* iop.
|
||||
*/
|
||||
if (error == 0) {
|
||||
rtems_libio_iop_hold(iop);
|
||||
iofd = rtems_libio_iop_to_descriptor(iop);
|
||||
} else {
|
||||
rtems_libio_free(iop);
|
||||
}
|
||||
}
|
||||
return iofd;
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_libio_iop_set_bsd_fd(struct thread *td, int fd, rtems_libio_t *iop,
|
||||
const rtems_filesystem_file_handlers_r *ops)
|
||||
{
|
||||
struct filedesc *fdp = td->td_proc->p_fd;
|
||||
int error;
|
||||
FILEDESC_XLOCK(fdp);
|
||||
if (fd < fdp->fd_nfiles) {
|
||||
struct file *fp = fget_locked(fdp, fd);
|
||||
if (fp != NULL) {
|
||||
rtems_bsd_libio_iop_set_bsd_file(iop, fp);
|
||||
rtems_libio_iop_flags_set(iop,
|
||||
LIBIO_FLAGS_OPEN |
|
||||
rtems_bsd_libio_fflag_to_flags(fp->f_flag));
|
||||
if (ops != NULL)
|
||||
iop->pathinfo.handlers = ops;
|
||||
rtems_bsd_libio_iop_set_bsd_descriptor(iop, fd);
|
||||
error = 0;
|
||||
} else {
|
||||
error = EBADF;
|
||||
}
|
||||
} else {
|
||||
error = EBADF;
|
||||
}
|
||||
FILEDESC_XUNLOCK(fdp);
|
||||
return error;
|
||||
}
|
||||
|
||||
void
|
||||
rtems_bsd_libio_loc_set_vnode(
|
||||
rtems_filesystem_location_info_t *loc, struct vnode *vp)
|
||||
{
|
||||
struct vnode *old = loc->node_access;
|
||||
int hc = 0;
|
||||
int rc = 0;
|
||||
if (vp != NULL) {
|
||||
hc = vp->v_holdcnt;
|
||||
rc = vrefcnt(vp);
|
||||
}
|
||||
int old_hc = 0;
|
||||
int old_rc = 0;
|
||||
if (old != NULL) {
|
||||
old_hc = old->v_holdcnt;
|
||||
old_rc = vrefcnt(old);
|
||||
}
|
||||
if (vp != old) {
|
||||
if (old != NULL)
|
||||
vrele(old);
|
||||
if (vp != NULL)
|
||||
VREF(vp);
|
||||
loc->node_access = vp;
|
||||
}
|
||||
int new_hc = 0;
|
||||
int new_rc = 0;
|
||||
if (vp != NULL) {
|
||||
new_hc = vp->v_holdcnt;
|
||||
new_rc = vrefcnt(vp);
|
||||
}
|
||||
int old_new_hc = 0;
|
||||
int old_new_rc = 0;
|
||||
if (old != NULL) {
|
||||
old_new_hc = old->v_holdcnt;
|
||||
old_new_rc = vrefcnt(old);
|
||||
}
|
||||
if (RTEMS_BSD_DESCRIP_TRACE || true)
|
||||
printf(
|
||||
"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,
|
||||
old_new_hc, old_new_rc);
|
||||
}
|
||||
|
||||
void
|
||||
rtems_bsd_libio_loc_set_vnode_dir(
|
||||
rtems_filesystem_location_info_t *loc, struct vnode *dvp)
|
||||
{
|
||||
struct vnode *old = loc->node_access_2;
|
||||
int hc = 0;
|
||||
int rc = 0;
|
||||
if (dvp != NULL) {
|
||||
hc = dvp->v_holdcnt;
|
||||
rc = vrefcnt(dvp);
|
||||
}
|
||||
int old_hc = 0;
|
||||
int old_rc = 0;
|
||||
if (old != NULL) {
|
||||
old_hc = old->v_holdcnt;
|
||||
old_rc = vrefcnt(old);
|
||||
}
|
||||
if (dvp != old) {
|
||||
if (old != NULL)
|
||||
vrele(old);
|
||||
if (dvp != NULL)
|
||||
VREF(dvp);
|
||||
loc->node_access_2 = dvp;
|
||||
}
|
||||
int new_hc = 0;
|
||||
int new_rc = 0;
|
||||
if (dvp != NULL) {
|
||||
new_hc = dvp->v_holdcnt;
|
||||
new_rc = vrefcnt(dvp);
|
||||
}
|
||||
int old_new_hc = 0;
|
||||
int old_new_rc = 0;
|
||||
if (old != NULL) {
|
||||
old_new_hc = old->v_holdcnt;
|
||||
old_new_rc = vrefcnt(old);
|
||||
}
|
||||
if (RTEMS_BSD_DESCRIP_TRACE)
|
||||
printf(
|
||||
"bsd: lio: set-vode-dir loc=%p vn=%p (%d/%d)->(%d/%d) old=%p (%d/%d)->(%d/%d)\n",
|
||||
loc, dvp, hc, rc, new_hc, new_rc, old, old_hc, old_rc,
|
||||
old_new_hc, old_new_rc);
|
||||
}
|
124
rtemsbsd/rtems/rtems-bsd-mountroot.c
Normal file
124
rtemsbsd/rtems/rtems-bsd-mountroot.c
Normal file
@ -0,0 +1,124 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup FileSystems
|
||||
*
|
||||
* @brief Mount a root file system.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 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 <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
struct vnode *rootvnode;
|
||||
|
||||
MALLOC_DECLARE(M_MOUNT);
|
||||
|
||||
static void
|
||||
set_rootvnode(struct mount *mp)
|
||||
{
|
||||
struct proc *p;
|
||||
int error;
|
||||
|
||||
error = VFS_ROOT(mp, LK_EXCLUSIVE, &rootvnode);
|
||||
if (error != 0)
|
||||
panic("Cannot find root vnode");
|
||||
|
||||
VOP_UNLOCK(rootvnode, 0);
|
||||
|
||||
p = curthread->td_proc;
|
||||
FILEDESC_XLOCK(p->p_fd);
|
||||
|
||||
if (p->p_fd->fd_cdir != NULL)
|
||||
vrele(p->p_fd->fd_cdir);
|
||||
p->p_fd->fd_cdir = rootvnode;
|
||||
VREF(rootvnode);
|
||||
|
||||
if (p->p_fd->fd_rdir != NULL)
|
||||
vrele(p->p_fd->fd_rdir);
|
||||
p->p_fd->fd_rdir = rootvnode;
|
||||
VREF(rootvnode);
|
||||
|
||||
FILEDESC_XUNLOCK(p->p_fd);
|
||||
}
|
||||
|
||||
static void
|
||||
bsd_mountroot(const char *fstype)
|
||||
{
|
||||
struct vfsoptlist *opts;
|
||||
struct vfsconf *vfsp;
|
||||
struct mount *mp;
|
||||
struct ucred *cred;
|
||||
int error;
|
||||
|
||||
cred = crget();
|
||||
cred->cr_uidinfo = uifind(0);
|
||||
cred->cr_ruidinfo = uifind(0);
|
||||
|
||||
vfsp = vfs_byname(fstype);
|
||||
if (vfsp != NULL) {
|
||||
mp = vfs_mount_alloc(NULLVP, vfsp, "/", cred);
|
||||
|
||||
crfree(cred);
|
||||
|
||||
error = VFS_MOUNT(mp);
|
||||
if (error != 0)
|
||||
panic("Cannot mount root file system: %d", error);
|
||||
|
||||
error = VFS_STATFS(mp, &mp->mnt_stat);
|
||||
if (error != 0)
|
||||
panic("Cannot stat root file system: %d", error);
|
||||
|
||||
opts = malloc(sizeof(struct vfsoptlist), M_MOUNT, M_WAITOK);
|
||||
TAILQ_INIT(opts);
|
||||
mp->mnt_opt = opts;
|
||||
|
||||
mtx_lock(&mountlist_mtx);
|
||||
TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list);
|
||||
mtx_unlock(&mountlist_mtx);
|
||||
|
||||
set_rootvnode(mp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bsd_rootfs_init(const void *dummy)
|
||||
{
|
||||
bsd_mountroot("rootfs");
|
||||
}
|
||||
SYSINIT(bsdroot, SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, bsd_rootfs_init, NULL);
|
File diff suppressed because it is too large
Load Diff
71
rtemsbsd/rtems/rtems-kernel-capability.c
Normal file
71
rtemsbsd/rtems/rtems-kernel-capability.c
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Chris Johns
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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 <sys/types.h>
|
||||
#include <sys/caprights.h>
|
||||
|
||||
cap_rights_t cap_no_rights;
|
||||
|
||||
#define RTEMS_BSD_CAP_ALIAS(var, tar) \
|
||||
extern int __attribute__((alias("_bsd_" #var))) _bsd_##tar;
|
||||
|
||||
#ifdef INVARIANT_SUPPORT
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_rights_is_valid);
|
||||
#endif
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_accept_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_bind_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_connect_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_event_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_fcntl_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_fstat_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_fsync_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_ftruncate_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_getpeername_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_getsockname_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_getsockopt_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_ioctl_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_listen_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_mkdirat_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_mknodat_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_read_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_recv_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_renameat_source_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_renameat_target_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_seek_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_setsockopt_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_shutdown_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_symlinkat_rights);
|
||||
RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_write_rights);
|
64
rtemsbsd/rtems/rtems-kernel-dev.c
Normal file
64
rtemsbsd/rtems/rtems-kernel-dev.c
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief Handle the major, minor and makedev support
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1991, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 <sys/types.h>
|
||||
|
||||
int
|
||||
rtems_bsd__major(dev_t _d)
|
||||
{
|
||||
return (((_d >> 32) & 0xffffff00) | ((_d >> 8) & 0xff));
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd__minor(dev_t _d)
|
||||
{
|
||||
return (((_d >> 24) & 0xff00) | (_d & 0xffff00ff));
|
||||
}
|
||||
|
||||
dev_t
|
||||
rtems_bsd__makedev(int _M, int _m)
|
||||
{
|
||||
return (((dev_t)(_M & 0xffffff00) << 32) | ((_M & 0xff) << 8) |
|
||||
((dev_t)(_m & 0xff00) << 24) | (_m & 0xffff00ff));
|
||||
}
|
52
rtemsbsd/rtems/rtems-kernel-dirent.c
Normal file
52
rtemsbsd/rtems/rtems-kernel-dirent.c
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009, 2015 embedded brains GmbH
|
||||
* All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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 <sys/dirent.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
dirent_terminate(struct dirent *dp)
|
||||
{
|
||||
memset(dp->d_name + dp->d_namlen, 0,
|
||||
dp->d_reclen - (__offsetof(struct dirent, d_name) + dp->d_namlen));
|
||||
}
|
@ -38,30 +38,37 @@
|
||||
*/
|
||||
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
#include <machine/rtems-bsd-thread.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/kbio.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/kbio.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/jail.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/sysent.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <machine/rtems-bsd-page.h>
|
||||
#include <machine/rtems-bsd-thread.h>
|
||||
|
||||
#include <dev/kbd/kbdreg.h>
|
||||
|
||||
#include <net80211/ieee80211_freebsd.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <rtems/bsd/bsd.h>
|
||||
#include <rtems/libio_.h>
|
||||
#include <rtems/malloc.h>
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
SYSINIT_REFERENCE(configure1);
|
||||
SYSINIT_REFERENCE(module);
|
||||
@ -98,25 +105,47 @@ sbintime_t sbt_timethreshold;
|
||||
sbintime_t sbt_tickthreshold;
|
||||
struct bintime tc_tick_bt;
|
||||
sbintime_t tc_tick_sbt;
|
||||
int maxproc;
|
||||
int tc_precexp;
|
||||
int maxproc;
|
||||
int maxfiles;
|
||||
int maxfilesperproc;
|
||||
int ngroups_max;
|
||||
int unmapped_buf_allowed;
|
||||
caddr_t unmapped_base;
|
||||
long maxbcache;
|
||||
int bio_transient_maxcnt;
|
||||
struct sx allproc_lock;
|
||||
struct vmem *rtems_bsd_transient_arena;
|
||||
int nbuf; /* The number of buffer headers */
|
||||
int nswbuf; /* Number of swap I/O buffer headers. */
|
||||
void (*nlminfo_release_p)(struct proc *p);
|
||||
struct sysentvec rtems_sysvec;
|
||||
|
||||
static SYSCTL_NODE(_kern, OID_AUTO, smp, CTLFLAG_RD|CTLFLAG_CAPRD, NULL,
|
||||
"Kernel SMP");
|
||||
static SYSCTL_NODE(
|
||||
_kern, OID_AUTO, smp, CTLFLAG_RD | CTLFLAG_CAPRD, NULL, "Kernel SMP");
|
||||
|
||||
static int maxid_maxcpus;
|
||||
|
||||
SYSCTL_INT(_kern_smp, OID_AUTO, maxid, CTLFLAG_RD|CTLFLAG_CAPRD,
|
||||
SYSCTL_INT(_kern_smp, OID_AUTO, maxid, CTLFLAG_RD | CTLFLAG_CAPRD,
|
||||
&maxid_maxcpus, 0, "Max CPU ID.");
|
||||
|
||||
SYSCTL_INT(_kern_smp, OID_AUTO, maxcpus, CTLFLAG_RD|CTLFLAG_CAPRD,
|
||||
SYSCTL_INT(_kern_smp, OID_AUTO, maxcpus, CTLFLAG_RD | CTLFLAG_CAPRD,
|
||||
&maxid_maxcpus, 0, "Max number of CPUs that the system was compiled for.");
|
||||
|
||||
static void
|
||||
cpu_startup(void *dummy)
|
||||
{
|
||||
kern_vfs_bio_buffer_alloc(unmapped_base, maxbcache);
|
||||
bufinit();
|
||||
vm_pager_bufferinit();
|
||||
}
|
||||
SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
|
||||
|
||||
/*
|
||||
* Create a single process. RTEMS is a single address, single process OS.
|
||||
*/
|
||||
static void
|
||||
proc0_init(void* dummy)
|
||||
proc0_init(void *dummy)
|
||||
{
|
||||
struct proc *p = &proc0;
|
||||
struct ucred *newcred;
|
||||
@ -127,7 +156,7 @@ proc0_init(void* dummy)
|
||||
newcred = crget();
|
||||
newcred->cr_uid = 0;
|
||||
newcred->cr_ruid = 0;
|
||||
newcred->cr_ngroups = 1; /* group 0 */
|
||||
newcred->cr_ngroups = 1; /* group 0 */
|
||||
newcred->cr_groups[0] = 0;
|
||||
newcred->cr_rgid = 0;
|
||||
tmpuinfo.ui_uid = 1;
|
||||
@ -137,8 +166,15 @@ proc0_init(void* dummy)
|
||||
newcred->cr_ruidinfo = uifind(0);
|
||||
p->p_ucred = newcred;
|
||||
p->p_pid = getpid();
|
||||
p->p_fd = NULL;
|
||||
p->p_fd = fdinit(NULL, false);
|
||||
p->p_fdtol = NULL;
|
||||
rtems_sysvec.sv_flags = SV_ABI_FREEBSD;
|
||||
#ifdef __LP64__
|
||||
rtems_sysvec.sv_flags |= SV_LP64;
|
||||
#else
|
||||
rtems_sysvec.sv_flags |= SV_ILP32;
|
||||
#endif
|
||||
p->p_sysent = &rtems_sysvec;
|
||||
uuid_generate(uuid);
|
||||
uuid_unparse(uuid, prison0.pr_hostuuid);
|
||||
}
|
||||
@ -170,17 +206,27 @@ rtems_bsd_initialize(void)
|
||||
bt_tickthreshold = bt_timethreshold;
|
||||
sbt_timethreshold = bttosbt(bt_timethreshold);
|
||||
sbt_tickthreshold = bttosbt(bt_tickthreshold);
|
||||
maxid_maxcpus = (int) rtems_scheduler_get_processor_maximum();
|
||||
maxid_maxcpus = (int)rtems_scheduler_get_processor_maximum();
|
||||
bio_transient_maxcnt = 1024;
|
||||
sx_init(&allproc_lock, "allproc");
|
||||
|
||||
maxfiles = rtems_libio_number_iops;
|
||||
maxfilesperproc = maxfiles;
|
||||
maxproc = 16;
|
||||
ngroups_max = 4;
|
||||
|
||||
maxbcache = rtems_bsd_get_allocator_domain_size(
|
||||
RTEMS_BSD_ALLOCATOR_DOMAIN_BIO);
|
||||
unmapped_base = (caddr_t)rtems_heap_allocate_aligned_with_boundary(
|
||||
maxbcache, CACHE_LINE_SIZE, 0);
|
||||
if (unmapped_base == NULL) {
|
||||
return RTEMS_UNSATISFIED;
|
||||
}
|
||||
|
||||
mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
|
||||
sc = rtems_timer_initiate_server(
|
||||
rtems_bsd_get_task_priority(name),
|
||||
rtems_bsd_get_task_stack_size(name),
|
||||
RTEMS_DEFAULT_ATTRIBUTES
|
||||
);
|
||||
sc = rtems_timer_initiate_server(rtems_bsd_get_task_priority(name),
|
||||
rtems_bsd_get_task_stack_size(name), RTEMS_DEFAULT_ATTRIBUTES);
|
||||
if (sc != RTEMS_SUCCESSFUL) {
|
||||
return RTEMS_UNSATISFIED;
|
||||
}
|
||||
@ -191,7 +237,8 @@ rtems_bsd_initialize(void)
|
||||
#ifdef KTR
|
||||
ktr_verbose = 10;
|
||||
ktr_mask = KTR_ALL;
|
||||
ktr_mask = KTR_GEN | KTR_LOCK | KTR_VFS | KTR_VOP | KTR_BUF | KTR_MALLOC | KTR_SYSC | KTR_RUNQ;
|
||||
ktr_mask = KTR_GEN | KTR_LOCK | KTR_VFS | KTR_VOP | KTR_BUF |
|
||||
KTR_MALLOC | KTR_SYSC | KTR_RUNQ;
|
||||
#endif
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
|
171
rtemsbsd/rtems/rtems-kernel-pager.c
Normal file
171
rtemsbsd/rtems/rtems-kernel-pager.c
Normal file
@ -0,0 +1,171 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Chris Johns <chris@contemporary.software>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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 <sys/param.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/vmem.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/uma.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
#define B_MAXPHYS 0x00200000 /* nitems(b_pages[]) = atop(MAXPHYS). */
|
||||
#define PBUF_PAGES (atop(maxphys) + 1)
|
||||
#define MAXPHYS (128 * 1024)
|
||||
#define NSWBUF_MIN 16
|
||||
|
||||
static u_long maxphys; /* max raw I/O transfer size */
|
||||
static int nswbuf_max;
|
||||
|
||||
vmem_t *kernel_arena;
|
||||
uma_zone_t pbuf_zone;
|
||||
uma_zone_t ncl_pbuf_zone;
|
||||
|
||||
vm_offset_t
|
||||
kva_alloc(vm_size_t size)
|
||||
{
|
||||
vm_offset_t addr;
|
||||
|
||||
size = round_page(size);
|
||||
if (vmem_alloc(kernel_arena, size, M_BESTFIT | M_NOWAIT, &addr))
|
||||
return (0);
|
||||
|
||||
return (addr);
|
||||
}
|
||||
|
||||
static int
|
||||
pbuf_ctor(void *mem, int size, void *arg, int flags)
|
||||
{
|
||||
struct buf *bp = mem;
|
||||
|
||||
bp->b_vp = NULL;
|
||||
bp->b_bufobj = NULL;
|
||||
|
||||
/* copied from initpbuf() */
|
||||
bp->b_rcred = NOCRED;
|
||||
bp->b_wcred = NOCRED;
|
||||
bp->b_qindex = 0; /* On no queue (QUEUE_NONE) */
|
||||
bp->b_data = bp->b_kvabase;
|
||||
bp->b_xflags = 0;
|
||||
bp->b_flags = B_MAXPHYS;
|
||||
bp->b_ioflags = 0;
|
||||
bp->b_iodone = NULL;
|
||||
bp->b_error = 0;
|
||||
BUF_LOCK(bp, LK_EXCLUSIVE, NULL);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
pbuf_dtor(void *mem, int size, void *arg)
|
||||
{
|
||||
struct buf *bp = mem;
|
||||
|
||||
if (bp->b_rcred != NOCRED) {
|
||||
crfree(bp->b_rcred);
|
||||
bp->b_rcred = NOCRED;
|
||||
}
|
||||
if (bp->b_wcred != NOCRED) {
|
||||
crfree(bp->b_wcred);
|
||||
bp->b_wcred = NOCRED;
|
||||
}
|
||||
|
||||
BUF_UNLOCK(bp);
|
||||
}
|
||||
|
||||
static int
|
||||
pbuf_init(void *mem, int size, int flags)
|
||||
{
|
||||
struct buf *bp = mem;
|
||||
|
||||
bp->b_kvabase = (void *)kva_alloc(ptoa(PBUF_PAGES));
|
||||
if (bp->b_kvabase == NULL)
|
||||
return (ENOMEM);
|
||||
bp->b_kvasize = ptoa(PBUF_PAGES);
|
||||
BUF_LOCKINIT(bp);
|
||||
LIST_INIT(&bp->b_dep);
|
||||
bp->b_rcred = bp->b_wcred = NOCRED;
|
||||
bp->b_xflags = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
vm_pager_bufferinit(void)
|
||||
{
|
||||
/* Main zone for paging bufs. */
|
||||
pbuf_zone = uma_zcreate("pbuf",
|
||||
sizeof(struct buf) + PBUF_PAGES * sizeof(vm_page_t), pbuf_ctor,
|
||||
pbuf_dtor, pbuf_init, NULL, UMA_ALIGN_CACHE, UMA_ZONE_NOFREE);
|
||||
/* Few systems may still use this zone directly, so it needs a limit. */
|
||||
nswbuf_max += uma_zone_set_max(pbuf_zone, NSWBUF_MIN);
|
||||
}
|
||||
|
||||
uma_zone_t
|
||||
pbuf_zsecond_create(char *name, int max)
|
||||
{
|
||||
uma_zone_t zone;
|
||||
|
||||
zone = uma_zsecond_create(
|
||||
name, pbuf_ctor, pbuf_dtor, NULL, NULL, pbuf_zone);
|
||||
/*
|
||||
* uma_prealloc() rounds up to items per slab. If we would prealloc
|
||||
* immediately on every pbuf_zsecond_create(), we may accumulate too
|
||||
* much of difference between hard limit and prealloced items, which
|
||||
* means wasted memory.
|
||||
*/
|
||||
if (nswbuf_max > 0)
|
||||
nswbuf_max += uma_zone_set_max(zone, max);
|
||||
else
|
||||
uma_prealloc(pbuf_zone, uma_zone_set_max(zone, max));
|
||||
|
||||
return (zone);
|
||||
}
|
||||
|
||||
struct buf *
|
||||
getpbuf(int *pfreecnt)
|
||||
{
|
||||
(void)pfreecnt;
|
||||
return uma_zalloc(ncl_pbuf_zone, M_WAITOK);
|
||||
}
|
||||
|
||||
void
|
||||
relpbuf(struct buf *bp, int *pfreecnt)
|
||||
{
|
||||
(void)pfreecnt;
|
||||
uma_zfree(ncl_pbuf_zone, bp);
|
||||
}
|
40
rtemsbsd/rtems/rtems-kernel-param.c
Normal file
40
rtemsbsd/rtems/rtems-kernel-param.c
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Chris Johns <chris@contemporary.software>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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 <sys/types.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
int ngroups_max; /* max # of supplemental groups */
|
969
rtemsbsd/rtems/rtems-kernel-vfs.c
Normal file
969
rtemsbsd/rtems/rtems-kernel-vfs.c
Normal file
@ -0,0 +1,969 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief VFS to RTEMS LibIO interface.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Chris Johns. All rights reserved.
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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 <sys/param.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/capsicum.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/syscallsubr.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/seterr.h>
|
||||
|
||||
const rtems_filesystem_operations_table rtems_bsd_vfsops = {
|
||||
.lock_h = rtems_bsd_vfs_mt_entry_lock,
|
||||
.unlock_h = rtems_bsd_vfs_mt_entry_unlock,
|
||||
.eval_path_h = rtems_bsd_vfs_eval_path,
|
||||
.link_h = rtems_bsd_vfs_link,
|
||||
.are_nodes_equal_h = rtems_bsd_vfs_are_nodes_equal,
|
||||
.mknod_h = rtems_bsd_vfs_mknod,
|
||||
.rmnod_h = rtems_bsd_vfs_rmnod,
|
||||
.fchmod_h = rtems_bsd_vfs_fchmod,
|
||||
.chown_h = rtems_bsd_vfs_chown,
|
||||
.clonenod_h = rtems_bsd_vfs_clonenode,
|
||||
.freenod_h = rtems_bsd_vfs_freenode,
|
||||
.mount_h = rtems_bsd_vfs_mount,
|
||||
.unmount_h = rtems_bsd_vfs_unmount,
|
||||
.fsunmount_me_h = rtems_bsd_vfs_fsunmount_me,
|
||||
.utimens_h = rtems_bsd_vfs_utimens,
|
||||
.symlink_h = rtems_bsd_vfs_symlink,
|
||||
.readlink_h = rtems_bsd_vfs_readlink,
|
||||
.rename_h = rtems_bsd_vfs_rename,
|
||||
.statvfs_h = rtems_bsd_vfs_statvfs
|
||||
};
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_mount_init(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
{
|
||||
mt_entry->fs_info = NULL;
|
||||
mt_entry->no_regular_file_mknod = true;
|
||||
mt_entry->ops = &rtems_bsd_vfsops;
|
||||
mt_entry->mt_fs_root->location.node_access = 0;
|
||||
mt_entry->mt_fs_root->location.handlers = &rtems_bsd_sysgen_dirops;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
rtems_bsd_vfs_loc_vnode_hold(
|
||||
rtems_filesystem_location_info_t *loc, struct vnode *vp)
|
||||
{
|
||||
if (vp != NULL) {
|
||||
VREF(vp);
|
||||
if (RTEMS_BSD_VFS_TRACE)
|
||||
printf("bsd: vfs: loc: hold loc=%p vn=%p\n", loc, vp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rtems_bsd_vfs_loc_vnode_drop(
|
||||
rtems_filesystem_location_info_t *loc, struct vnode *vp)
|
||||
{
|
||||
if (vp != NULL) {
|
||||
vrele(vp);
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: loc: drop loc=%p vn=%p\n", loc, vp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rtems_bsd_vfs_loc_hold(rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
if (loc != NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE)
|
||||
printf("bsd: vfs: loc: hold loc=%p vn=%p vdp=%p\n", loc,
|
||||
rtems_bsd_libio_loc_to_vnode(loc),
|
||||
rtems_bsd_libio_loc_to_vnode_dir(loc));
|
||||
rtems_bsd_vfs_loc_vnode_hold(
|
||||
loc, rtems_bsd_libio_loc_to_vnode(loc));
|
||||
rtems_bsd_vfs_loc_vnode_hold(
|
||||
loc, rtems_bsd_libio_loc_to_vnode_dir(loc));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rtems_bsd_vfs_loc_drop(rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
if (loc != NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE)
|
||||
printf("bsd: vfs: loc: drop loc=%p vn=%p vdp=%p\n", loc,
|
||||
rtems_bsd_libio_loc_to_vnode(loc),
|
||||
rtems_bsd_libio_loc_to_vnode_dir(loc));
|
||||
rtems_bsd_libio_loc_set_vnode(loc, NULL);
|
||||
rtems_bsd_libio_loc_set_vnode_dir(loc, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rtems_bsd_vfs_mt_entry_lock(
|
||||
const rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
{
|
||||
struct vnode *vp = rtems_bsd_libio_loc_to_vnode(
|
||||
&mt_entry->mt_fs_root->location);
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: lock: vn=%p\n", vp);
|
||||
}
|
||||
VREF(vp);
|
||||
}
|
||||
|
||||
void
|
||||
rtems_bsd_vfs_mt_entry_unlock(
|
||||
const rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
{
|
||||
struct vnode *vp = rtems_bsd_libio_loc_to_vnode(
|
||||
&mt_entry->mt_fs_root->location);
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: unlock: vn=%p\n", vp);
|
||||
}
|
||||
vrele(vp);
|
||||
}
|
||||
|
||||
static void
|
||||
rtems_bsd_vfs_componentname(struct componentname *cnd, u_long nameiop,
|
||||
char *name, u_int namelen, struct ucred *cred)
|
||||
{
|
||||
memset(cnd, 0, sizeof(*cnd));
|
||||
cnd->cn_nameiop = nameiop;
|
||||
cnd->cn_nameptr = name;
|
||||
cnd->cn_namelen = namelen;
|
||||
cnd->cn_cred = cred;
|
||||
}
|
||||
|
||||
static int
|
||||
rtems_bsd_vfs_vnode_componentname(struct componentname *cnd, struct vnode *vp,
|
||||
u_long nameiop, char *name, u_int namelen, struct ucred *cred)
|
||||
{
|
||||
struct vnode *tvp;
|
||||
const u_int namemax = namelen - 1;
|
||||
char *namep;
|
||||
int error;
|
||||
name[namemax] = '\0';
|
||||
namelen = namemax;
|
||||
tvp = vp;
|
||||
error = vn_vptocnp(&tvp, NULL, name, &namelen);
|
||||
if (error == 0) {
|
||||
name = &name[namelen];
|
||||
namelen = namemax - namelen;
|
||||
} else {
|
||||
name = NULL;
|
||||
namelen = 0;
|
||||
}
|
||||
rtems_bsd_vfs_componentname(cnd, nameiop, name, namelen, cred);
|
||||
return error;
|
||||
}
|
||||
|
||||
static bool
|
||||
rtems_bsd_vfs_vnode_is_directory(
|
||||
rtems_filesystem_eval_path_context_t *ctx, void *arg)
|
||||
{
|
||||
struct vnode *vp = *((struct vnode **)arg);
|
||||
return vp->v_type == VDIR;
|
||||
}
|
||||
|
||||
static rtems_filesystem_eval_path_generic_status
|
||||
rtems_bsd_vfs_eval_token(rtems_filesystem_eval_path_context_t *ctx, void *arg,
|
||||
const char *token, size_t tokenlen)
|
||||
{
|
||||
rtems_filesystem_location_info_t *currentloc;
|
||||
struct thread *td = curthread;
|
||||
struct filedesc *fdp = td->td_proc->p_fd;
|
||||
struct nameidata nd;
|
||||
struct vnode **vpp = arg;
|
||||
struct vnode *vp;
|
||||
struct vnode *dvp;
|
||||
struct vnode *cdir;
|
||||
struct vnode *rdir;
|
||||
char ntoken[NAME_MAX + 1];
|
||||
u_long op = LOOKUP;
|
||||
u_long flags = 0;
|
||||
int eval_flags;
|
||||
bool no_more_path;
|
||||
rtems_filesystem_location_info_t *rootloc;
|
||||
int error;
|
||||
|
||||
currentloc = rtems_filesystem_eval_path_get_currentloc(ctx);
|
||||
no_more_path = !rtems_filesystem_eval_path_has_path(ctx);
|
||||
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: eval_token: t=%s:%d vp=%p\n", token, tokenlen,
|
||||
*vpp);
|
||||
}
|
||||
|
||||
if (tokenlen > NAME_MAX) {
|
||||
rtems_filesystem_eval_path_error(ctx, E2BIG);
|
||||
return RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE;
|
||||
}
|
||||
|
||||
if (rtems_filesystem_is_current_directory(token, tokenlen)) {
|
||||
rtems_filesystem_eval_path_clear_token(ctx);
|
||||
return no_more_path ?
|
||||
RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE :
|
||||
RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Have we reached the root vnode. Note the namei call will
|
||||
* successfully lookup `..` when we are at the mount point
|
||||
* because VFS mounts are held under the root pseudofs file
|
||||
* system.
|
||||
*/
|
||||
rootloc = ¤tloc->mt_entry->mt_fs_root->location;
|
||||
if (*vpp == rtems_bsd_libio_loc_to_vnode(rootloc)) {
|
||||
if (rtems_filesystem_is_parent_directory(token, tokenlen)) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf(
|
||||
"bsd: vfs: parent from root: vp=%p rvp=%p\n",
|
||||
*vpp,
|
||||
rtems_bsd_libio_loc_to_vnode(rootloc));
|
||||
}
|
||||
rtems_filesystem_eval_path_put_back_token(ctx);
|
||||
return RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
eval_flags = rtems_filesystem_eval_path_get_flags(ctx);
|
||||
flags |= (eval_flags & RTEMS_FS_FOLLOW_LINK) != 0 ? FOLLOW : NOFOLLOW;
|
||||
|
||||
if (no_more_path && ((eval_flags & RTEMS_FS_MAKE) != 0)) {
|
||||
op = CREATE;
|
||||
flags |= LOCKPARENT;
|
||||
}
|
||||
|
||||
flags |= WANTPARENT;
|
||||
|
||||
FILEDESC_XLOCK(fdp);
|
||||
rdir = fdp->fd_rdir;
|
||||
cdir = fdp->fd_cdir;
|
||||
fdp->fd_rdir = rootvnode;
|
||||
fdp->fd_cdir = *vpp;
|
||||
vref(*vpp);
|
||||
FILEDESC_XUNLOCK(fdp);
|
||||
|
||||
bcopy(token, ntoken, tokenlen);
|
||||
ntoken[tokenlen] = '\0';
|
||||
|
||||
NDINIT_ATVP(&nd, op, flags, UIO_USERSPACE, ntoken, *vpp, td);
|
||||
error = namei(&nd);
|
||||
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf(
|
||||
"bsd: vfs: eval_token: namei=%d:%s token=%s cwd=%p vp=%p dvp=%p mp=%p %s\n",
|
||||
error, strerror(error), ntoken, *vpp, nd.ni_vp, nd.ni_dvp,
|
||||
nd.ni_vp ? nd.ni_vp->v_mountedhere : NULL,
|
||||
no_more_path ? "no-more-path" : "more-path");
|
||||
}
|
||||
|
||||
if (error != 0) {
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
rtems_filesystem_eval_path_error(ctx, error);
|
||||
return RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE;
|
||||
}
|
||||
|
||||
FILEDESC_XLOCK(fdp);
|
||||
fdp->fd_rdir = rdir;
|
||||
fdp->fd_cdir = cdir;
|
||||
FILEDESC_XUNLOCK(fdp);
|
||||
|
||||
/*
|
||||
* If there is no more path and this is the last token and the lookup
|
||||
* with CREATE failed to find a vnode it does not exist and needs to be
|
||||
* created. Leave the currentloc where it is.
|
||||
*/
|
||||
if (nd.ni_vp != NULL) {
|
||||
rtems_bsd_libio_loc_set_vnode(currentloc, nd.ni_vp);
|
||||
rtems_bsd_libio_loc_set_vnode_dir(currentloc, nd.ni_dvp);
|
||||
}
|
||||
|
||||
*vpp = nd.ni_vp;
|
||||
|
||||
NDFREE(&nd, 0);
|
||||
|
||||
if (*vpp == rtems_bsd_libio_loc_to_vnode(rootloc)) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf(
|
||||
"bsd: vfs: eval_token: cross-mount vp=%p rvp=%p\n",
|
||||
*vpp, rtems_bsd_libio_loc_to_vnode(rootloc));
|
||||
}
|
||||
rtems_filesystem_eval_path_clear_token(ctx);
|
||||
return RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE;
|
||||
}
|
||||
|
||||
if (*vpp != NULL) {
|
||||
rtems_filesystem_eval_path_clear_token(ctx);
|
||||
}
|
||||
|
||||
return no_more_path ? RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE :
|
||||
RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE;
|
||||
}
|
||||
|
||||
static const rtems_filesystem_eval_path_generic_config
|
||||
rtems_bsd_vfs_eval_config = {
|
||||
.is_directory = rtems_bsd_vfs_vnode_is_directory,
|
||||
.eval_token = rtems_bsd_vfs_eval_token
|
||||
};
|
||||
|
||||
void
|
||||
rtems_bsd_vfs_eval_path(rtems_filesystem_eval_path_context_t *ctx)
|
||||
{
|
||||
rtems_filesystem_location_info_t *currentloc;
|
||||
struct vnode *vp;
|
||||
|
||||
errno = 0;
|
||||
|
||||
currentloc = rtems_filesystem_eval_path_get_currentloc(ctx);
|
||||
vp = rtems_bsd_libio_loc_to_vnode(currentloc);
|
||||
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: eval_path: t=%s:%d (%s) cloc=%p\n",
|
||||
ctx->token, ctx->tokenlen, ctx->path, vp);
|
||||
}
|
||||
|
||||
/*
|
||||
* For locking
|
||||
*/
|
||||
rtems_bsd_libio_loc_set_vnode(currentloc, vp);
|
||||
rtems_bsd_libio_loc_set_vnode_dir(currentloc, vp);
|
||||
|
||||
rtems_filesystem_eval_path_generic(
|
||||
ctx, &vp, &rtems_bsd_vfs_eval_config);
|
||||
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: eval_path: e=%d:%s vp=%p cloc=%p lookup=%p\n",
|
||||
errno, strerror(errno), vp,
|
||||
rtems_bsd_libio_loc_to_vnode(currentloc),
|
||||
rtems_bsd_libio_loc_to_vnode_dir(currentloc));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
rtems_bsd_vfs_are_nodes_equal(const rtems_filesystem_location_info_t *a,
|
||||
const rtems_filesystem_location_info_t *b)
|
||||
{
|
||||
struct vnode *avp = rtems_bsd_libio_loc_to_vnode(a);
|
||||
struct vnode *bvp = rtems_bsd_libio_loc_to_vnode(b);
|
||||
struct vnode *advp = rtems_bsd_libio_loc_to_vnode_dir(a);
|
||||
struct vnode *bdvp = rtems_bsd_libio_loc_to_vnode_dir(b);
|
||||
bool eq;
|
||||
if (advp != NULL && bdvp != NULL) {
|
||||
eq = avp == bvp && advp == bdvp;
|
||||
} else {
|
||||
eq = avp == bvp;
|
||||
}
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf(
|
||||
"bsd: vfs: nodes_equal: %s vn:%s (%p == %p) dvn:%s (%p == %p)\n",
|
||||
eq ? "EQ" : "NE", avp == bvp ? "equal" : "not-equal", avp,
|
||||
bvp, advp == bdvp ? "equal" : "not-equal", advp, bdvp);
|
||||
}
|
||||
return eq;
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_clonenode(rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
rtems_bsd_vfs_loc_hold(loc);
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
|
||||
struct vnode *dvp = rtems_bsd_libio_loc_to_vnode_dir(loc);
|
||||
printf("bsd: vfs: clonenode: %p vn=%p dvp=%p\n", loc, vp, dvp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rtems_bsd_vfs_freenode(const rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
|
||||
struct vnode *dp = rtems_bsd_libio_loc_to_vnode_dir(loc);
|
||||
printf("bsd: vfs: freenode: %p vn=%p dp=%p\n", loc, vp, dp);
|
||||
}
|
||||
rtems_bsd_vfs_loc_drop(
|
||||
RTEMS_DECONST(rtems_filesystem_location_info_t *, loc));
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_link(const rtems_filesystem_location_info_t *targetdirloc,
|
||||
const rtems_filesystem_location_info_t *sourceloc, const char *name,
|
||||
size_t namelen)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
struct mount *mp;
|
||||
struct vnode *tdvp = rtems_bsd_libio_loc_to_vnode(targetdirloc);
|
||||
struct vnode *svp = rtems_bsd_libio_loc_to_vnode(sourceloc);
|
||||
struct componentname cn;
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf(
|
||||
"bsd: vfs: link tdvn=%p svn=%p name=%s\n", tdvp, svp, name);
|
||||
}
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: link: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
if (svp->v_mount != tdvp->v_mount) {
|
||||
if (RTEMS_BSD_VFS_TRACE)
|
||||
printf("bsd: vfs: link: crossmounts\n");
|
||||
error = EXDEV;
|
||||
goto out;
|
||||
}
|
||||
vref(tdvp);
|
||||
vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY);
|
||||
error = vn_start_write(tdvp, &mp, V_NOWAIT);
|
||||
if (error != 0) {
|
||||
vput(tdvp);
|
||||
error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH);
|
||||
if (error == 0)
|
||||
error = EAGAIN;
|
||||
goto out;
|
||||
}
|
||||
rtems_bsd_vfs_componentname(
|
||||
&cn, LOOKUP, RTEMS_DECONST(char *, name), namelen, td->td_ucred);
|
||||
error = VOP_LINK(tdvp, svp, &cn);
|
||||
VOP_UNLOCK(tdvp, 0);
|
||||
out:
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: fchmod: vn=%p mode=%x\n", vp, mode);
|
||||
}
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: fchmod: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
error = setfmode(td, NULL, vp, mode);
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_chown(
|
||||
const rtems_filesystem_location_info_t *loc, uid_t owner, gid_t group)
|
||||
{
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: chown: vn=%p owner=%d group=%d\n", vp, owner,
|
||||
group);
|
||||
}
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: chown: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
error = setfown(td, NULL, vp, owner, group);
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_mount(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
{
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: mount\n");
|
||||
}
|
||||
error = EOPNOTSUPP;
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_fsmount_me(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
struct mount_args *args = (struct mount_args *)data;
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: fsmount_me\n");
|
||||
}
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: fsmount_me: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
error = sys_mount(td, args);
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: fsmount_me: error=%d %s\n", error,
|
||||
strerror(error));
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_unmount(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
{
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: unmount\n");
|
||||
}
|
||||
error = EOPNOTSUPP;
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
void
|
||||
rtems_bsd_vfs_fsunmount_me(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
{
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: fsunmount_me: %p\n",
|
||||
rtems_bsd_libio_loc_to_vnode(
|
||||
&mt_entry->mt_fs_root->location));
|
||||
}
|
||||
rtems_bsd_vfs_loc_drop(&mt_entry->mt_fs_root->location);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_mknod(const rtems_filesystem_location_info_t *parentloc,
|
||||
const char *name, size_t namelen, mode_t mode, dev_t dev)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
struct filedesc *fdp = td->td_proc->p_fd;
|
||||
struct vnode *vn = rtems_bsd_libio_loc_to_vnode(parentloc);
|
||||
char *path = RTEMS_DECONST(char *, name);
|
||||
int error;
|
||||
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: mknod: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
const char *type;
|
||||
if ((mode & S_IFMT) == S_IFREG)
|
||||
type = "REG";
|
||||
else if ((mode & S_IFMT) == S_IFDIR)
|
||||
type = "DIR";
|
||||
else
|
||||
type = "DEV";
|
||||
printf(
|
||||
"bsd: vfs: mknod: mode=%s name=%s (%d) mode=%08x dev=%08llx parent=%p\n",
|
||||
type, name, namelen, mode, dev, vn);
|
||||
}
|
||||
|
||||
fdp->fd_cdir = vn;
|
||||
|
||||
switch (mode & S_IFMT) {
|
||||
case S_IFREG:
|
||||
error = 0;
|
||||
break;
|
||||
case S_IFDIR:
|
||||
VREF(vn);
|
||||
error = kern_mkdirat(td, AT_FDCWD, path, UIO_USERSPACE, mode);
|
||||
vrele(vn);
|
||||
break;
|
||||
default:
|
||||
VREF(vn);
|
||||
error = kern_mknodat(
|
||||
td, AT_FDCWD, path, UIO_USERSPACE, mode, dev);
|
||||
vrele(vn);
|
||||
break;
|
||||
}
|
||||
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf(
|
||||
"bsd: vfs: mknod: error=%s (%d)\n", strerror(error), error);
|
||||
}
|
||||
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_rmnod(const rtems_filesystem_location_info_t *parentloc,
|
||||
const rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
struct mount *mp;
|
||||
struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
|
||||
struct vnode *dvp = rtems_bsd_libio_loc_to_vnode(parentloc);
|
||||
struct vnode *tvp;
|
||||
struct componentname cn;
|
||||
char name[255];
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: rmnod vn=%p at=%p\n", vp, dvp);
|
||||
}
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: rmnod: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
error = rtems_bsd_vfs_vnode_componentname(
|
||||
&cn, vp, DELETE, name, sizeof(name), td->td_ucred);
|
||||
if (error != 0) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf(
|
||||
"bsd: vfs: rmnod: componentname lookup: (%d) %s\n",
|
||||
error, strerror(error));
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: rmnod name=%s\n", cn.cn_nameptr);
|
||||
}
|
||||
vref(vp);
|
||||
restart:
|
||||
bwillwrite();
|
||||
if (vp->v_vflag & VV_ROOT) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
if (vn_start_write(dvp, &mp, V_NOWAIT) != 0) {
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) !=
|
||||
0) {
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
goto restart;
|
||||
}
|
||||
vfs_notify_upper(vp, VFS_NOTIFY_UPPER_UNLINK);
|
||||
error = VOP_RMDIR(dvp, vp, &cn);
|
||||
vn_finished_write(mp);
|
||||
out:
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_utimens(
|
||||
const rtems_filesystem_location_info_t *loc, time_t actime, time_t modtime)
|
||||
{
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: utimens\n");
|
||||
}
|
||||
error = EOPNOTSUPP;
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_symlink(const rtems_filesystem_location_info_t *targetdirloc,
|
||||
const char *name, size_t namelen, const char *target)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
struct filedesc *fdp;
|
||||
struct mount *mp;
|
||||
struct vnode *tdvp = rtems_bsd_libio_loc_to_vnode(targetdirloc);
|
||||
struct vattr vattr;
|
||||
struct nameidata nd;
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: symlink tdvn=%p name=%s target=%s\n", tdvp,
|
||||
name, target);
|
||||
}
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: symlink: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
fdp = td->td_proc->p_fd;
|
||||
fdp->fd_cdir = tdvp;
|
||||
restart:
|
||||
bwillwrite();
|
||||
NDINIT_ATRIGHTS(&nd, CREATE,
|
||||
LOCKPARENT | SAVENAME | AUDITVNODE1 | NOCACHE, UIO_SYSSPACE, name,
|
||||
AT_FDCWD, &cap_symlinkat_rights, td);
|
||||
error = namei(&nd);
|
||||
if (error != 0) {
|
||||
goto out;
|
||||
}
|
||||
if (nd.ni_vp != NULL) {
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
if (nd.ni_vp == nd.ni_dvp)
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
vput(nd.ni_dvp);
|
||||
vrele(nd.ni_vp);
|
||||
error = EEXIST;
|
||||
goto out;
|
||||
}
|
||||
error = vn_start_write(nd.ni_dvp, &mp, V_NOWAIT);
|
||||
if (error != 0) {
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
vput(nd.ni_dvp);
|
||||
error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH);
|
||||
if (error != 0) {
|
||||
goto out;
|
||||
}
|
||||
goto restart;
|
||||
}
|
||||
VATTR_NULL(&vattr);
|
||||
vattr.va_mode = ACCESSPERMS & ~td->td_proc->p_fd->fd_cmask;
|
||||
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr,
|
||||
RTEMS_DECONST(char *, target));
|
||||
if (error != 0) {
|
||||
goto out;
|
||||
}
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
vput(nd.ni_dvp);
|
||||
vn_finished_write(mp);
|
||||
out:
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
rtems_bsd_vfs_readlink(
|
||||
const rtems_filesystem_location_info_t *loc, char *buf, size_t bufsize)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
|
||||
struct iovec aiov;
|
||||
struct uio auio;
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: readlink vn=%p\n", vp);
|
||||
}
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: readlink: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
if (vp->v_type != VLNK && (vp->v_vflag & VV_READLINK) == 0) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
aiov.iov_base = buf;
|
||||
aiov.iov_len = bufsize;
|
||||
auio.uio_iov = &aiov;
|
||||
auio.uio_iovcnt = 1;
|
||||
auio.uio_offset = 0;
|
||||
auio.uio_rw = UIO_READ;
|
||||
auio.uio_segflg = UIO_SYSSPACE;
|
||||
auio.uio_td = td;
|
||||
auio.uio_resid = bufsize;
|
||||
error = VOP_READLINK(vp, &auio, td->td_ucred);
|
||||
td->td_retval[0] = bufsize - auio.uio_resid;
|
||||
out:
|
||||
VOP_UNLOCK(vp, 0);
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_rename(const rtems_filesystem_location_info_t *oldparentloc,
|
||||
const rtems_filesystem_location_info_t *oldloc,
|
||||
const rtems_filesystem_location_info_t *newparentloc, const char *name,
|
||||
size_t namelen)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
struct mount *mp;
|
||||
struct vnode *olddvp = rtems_bsd_libio_loc_to_vnode(oldparentloc);
|
||||
struct vnode *oldvp = rtems_bsd_libio_loc_to_vnode(oldloc);
|
||||
struct vnode *newdvp = rtems_bsd_libio_loc_to_vnode(newparentloc);
|
||||
struct vnode *fvp;
|
||||
struct vnode *tdvp;
|
||||
struct vnode *tvp;
|
||||
struct nameidata fromnd;
|
||||
struct nameidata tond;
|
||||
struct componentname cn;
|
||||
char fromname[255];
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: rename from=%p/%p to=%p/%s\n", olddvp, oldvp,
|
||||
newdvp, name);
|
||||
}
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: rename: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
error = rtems_bsd_vfs_vnode_componentname(
|
||||
&cn, oldvp, DELETE, fromname, sizeof(fromname), td->td_ucred);
|
||||
if (error != 0) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf(
|
||||
"bsd: vfs: rename: componentname lookup: %p: (%d) %s\n",
|
||||
oldvp, error, strerror(error));
|
||||
}
|
||||
goto out2;
|
||||
}
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: rename fromname=%s\n", cn.cn_nameptr);
|
||||
}
|
||||
again:
|
||||
bwillwrite();
|
||||
NDINIT_ATVP(&fromnd, DELETE, WANTPARENT | SAVESTART | AUDITVNODE1,
|
||||
UIO_SYSSPACE, cn.cn_nameptr, olddvp, td);
|
||||
error = namei(&fromnd);
|
||||
if (error != 0) {
|
||||
goto out2;
|
||||
}
|
||||
fvp = fromnd.ni_vp;
|
||||
NDINIT_ATVP(&tond, RENAME,
|
||||
LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | AUDITVNODE2,
|
||||
UIO_SYSSPACE, name, newdvp, td);
|
||||
if (fromnd.ni_vp->v_type == VDIR)
|
||||
tond.ni_cnd.cn_flags |= WILLBEDIR;
|
||||
error = namei(&tond);
|
||||
if (error != 0) {
|
||||
/* Translate error code for rename("dir1", "dir2/."). */
|
||||
if (error == EISDIR && fvp->v_type == VDIR)
|
||||
error = EINVAL;
|
||||
NDFREE(&fromnd, NDF_ONLY_PNBUF);
|
||||
vrele(fromnd.ni_dvp);
|
||||
vrele(fvp);
|
||||
goto out1;
|
||||
}
|
||||
tdvp = tond.ni_dvp;
|
||||
tvp = tond.ni_vp;
|
||||
error = vn_start_write(fvp, &mp, V_NOWAIT);
|
||||
if (error != 0) {
|
||||
NDFREE(&fromnd, NDF_ONLY_PNBUF);
|
||||
NDFREE(&tond, NDF_ONLY_PNBUF);
|
||||
if (tvp != NULL)
|
||||
vput(tvp);
|
||||
if (tdvp == tvp)
|
||||
vrele(tdvp);
|
||||
else
|
||||
vput(tdvp);
|
||||
vrele(fromnd.ni_dvp);
|
||||
vrele(fvp);
|
||||
vrele(tond.ni_startdir);
|
||||
if (fromnd.ni_startdir != NULL)
|
||||
vrele(fromnd.ni_startdir);
|
||||
error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
goto again;
|
||||
}
|
||||
if (tvp != NULL) {
|
||||
if (fvp->v_type == VDIR && tvp->v_type != VDIR) {
|
||||
error = ENOTDIR;
|
||||
goto out;
|
||||
} else if (fvp->v_type != VDIR && tvp->v_type == VDIR) {
|
||||
error = EISDIR;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if (fvp == tdvp) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
out:
|
||||
if (error == 0) {
|
||||
error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
|
||||
tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
|
||||
NDFREE(&fromnd, NDF_ONLY_PNBUF);
|
||||
NDFREE(&tond, NDF_ONLY_PNBUF);
|
||||
} else {
|
||||
NDFREE(&fromnd, NDF_ONLY_PNBUF);
|
||||
NDFREE(&tond, NDF_ONLY_PNBUF);
|
||||
if (tvp != NULL)
|
||||
vput(tvp);
|
||||
if (tdvp == tvp)
|
||||
vrele(tdvp);
|
||||
else
|
||||
vput(tdvp);
|
||||
vrele(fromnd.ni_dvp);
|
||||
vrele(fvp);
|
||||
}
|
||||
vrele(tond.ni_startdir);
|
||||
vn_finished_write(mp);
|
||||
out1:
|
||||
if (fromnd.ni_startdir)
|
||||
vrele(fromnd.ni_startdir);
|
||||
if (error == -1)
|
||||
error = 0;
|
||||
out2:
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
int
|
||||
rtems_bsd_vfs_statvfs(
|
||||
const rtems_filesystem_location_info_t *loc, struct statvfs *buf)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
|
||||
struct statfs *sp;
|
||||
struct mount *mp;
|
||||
int error;
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: statvfs\n");
|
||||
}
|
||||
if (td == NULL) {
|
||||
if (RTEMS_BSD_VFS_TRACE) {
|
||||
printf("bsd: vfs: statvfs: no curthread\n");
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(ENOMEM);
|
||||
}
|
||||
mp = vp->v_mount;
|
||||
sp = &mp->mnt_stat;
|
||||
sp->f_version = STATFS_VERSION;
|
||||
sp->f_namemax = NAME_MAX;
|
||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
error = VFS_STATFS(mp, sp);
|
||||
if (error == 0) {
|
||||
buf->f_bsize = sp->f_bsize;
|
||||
buf->f_frsize = sp->f_bsize;
|
||||
buf->f_blocks = sp->f_blocks;
|
||||
buf->f_bfree = sp->f_bfree;
|
||||
buf->f_bavail = sp->f_bavail;
|
||||
buf->f_files = sp->f_files;
|
||||
buf->f_ffree = sp->f_ffree;
|
||||
buf->f_fsid = sp->f_fsid.val[0];
|
||||
buf->f_flag = sp->f_flags;
|
||||
buf->f_namemax = sp->f_namemax;
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
55
rtemsbsd/rtems/rtems-kernel-vmem.c
Normal file
55
rtemsbsd/rtems/rtems-kernel-vmem.c
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Chris Johns <chris@contemporary.software>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 AUTHOR 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 AUTHOR 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 <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/vmem.h>
|
||||
|
||||
static MALLOC_DEFINE(M_VMEM, "vmem", "VMEM buffers");
|
||||
|
||||
int
|
||||
vmem_alloc(vmem_t *vm, vmem_size_t size, int flags, vmem_addr_t *addrp)
|
||||
{
|
||||
*addrp = malloc(size, M_VMEM, M_WAITOK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
vmem_free(vmem_t *vm, vmem_addr_t addr, vmem_size_t size)
|
||||
{
|
||||
free((void *)addr, M_VMEM);
|
||||
}
|
@ -35,6 +35,7 @@
|
||||
#include <sys/conf.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/poll.h>
|
||||
@ -42,6 +43,8 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <machine/rtems-bsd-libio.h>
|
||||
|
||||
#include <fs/devfs/devfs_int.h>
|
||||
|
||||
#include <machine/pcpu.h>
|
||||
@ -72,17 +75,25 @@ static int
|
||||
devfs_imfs_open(rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
|
||||
{
|
||||
struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = NULL;
|
||||
struct cdevsw *dsw = NULL;
|
||||
struct file *fpop;
|
||||
struct cdevsw *dsw;
|
||||
int error, ref;
|
||||
int fd = -1;
|
||||
|
||||
if (td != NULL) {
|
||||
if (cdev == NULL) {
|
||||
error = ENXIO;
|
||||
goto err;
|
||||
}
|
||||
error = falloc(td, &fp, &fd, oflag);
|
||||
if (error != 0)
|
||||
goto err;
|
||||
finit(fp, FREAD | FWRITE, DTYPE_DEV, NULL, NULL);
|
||||
rtems_libio_iop_hold(iop);
|
||||
rtems_bsd_libio_iop_set_bsd_descriptor(iop, fd);
|
||||
rtems_bsd_libio_iop_set_bsd_file(iop, fp);
|
||||
if (cdev->si_flags & SI_ALIAS) {
|
||||
cdev = cdev->si_parent;
|
||||
}
|
||||
@ -91,11 +102,6 @@ devfs_imfs_open(rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
|
||||
error = ENXIO;
|
||||
goto err;
|
||||
}
|
||||
if (fp == NULL) {
|
||||
dev_relthread(cdev, ref);
|
||||
error = ENXIO;
|
||||
goto err;
|
||||
}
|
||||
fpop = td->td_fpop;
|
||||
curthread->td_fpop = fp;
|
||||
fp->f_cdevpriv = NULL;
|
||||
@ -104,12 +110,19 @@ devfs_imfs_open(rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
|
||||
if (error != 0)
|
||||
devfs_clear_cdevpriv();
|
||||
curthread->td_fpop = fpop;
|
||||
dev_relthread(cdev, ref);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
err:
|
||||
if (dsw != NULL)
|
||||
dev_relthread(cdev, ref);
|
||||
if (td != NULL && fp != NULL) {
|
||||
if (error != 0)
|
||||
fdclose(td, fp, fd);
|
||||
else
|
||||
fdrop(fp, td);
|
||||
}
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
@ -117,11 +130,11 @@ static int
|
||||
devfs_imfs_close(rtems_libio_t *iop)
|
||||
{
|
||||
struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
int flags = rtems_libio_to_fcntl_flags(iop->flags);
|
||||
struct file *fp = NULL;
|
||||
struct cdevsw *dsw = NULL;
|
||||
struct file *fpop;
|
||||
struct cdevsw *dsw;
|
||||
int error, ref;
|
||||
|
||||
if (td != NULL) {
|
||||
@ -132,6 +145,11 @@ devfs_imfs_close(rtems_libio_t *iop)
|
||||
if (cdev->si_flags & SI_ALIAS) {
|
||||
cdev = cdev->si_parent;
|
||||
}
|
||||
fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
|
||||
if (fp == NULL) {
|
||||
error = EBADF;
|
||||
goto err;
|
||||
}
|
||||
dsw = dev_refthread(cdev, &ref);
|
||||
if (dsw == NULL) {
|
||||
error = ENXIO;
|
||||
@ -141,7 +159,6 @@ devfs_imfs_close(rtems_libio_t *iop)
|
||||
curthread->td_fpop = fp;
|
||||
error = dsw->d_close(cdev, flags, 0, td);
|
||||
curthread->td_fpop = fpop;
|
||||
dev_relthread(cdev, ref);
|
||||
if (fp->f_cdevpriv != NULL)
|
||||
devfs_fpdrop(fp);
|
||||
} else {
|
||||
@ -149,6 +166,10 @@ devfs_imfs_close(rtems_libio_t *iop)
|
||||
}
|
||||
|
||||
err:
|
||||
if (dsw != NULL)
|
||||
dev_relthread(cdev, ref);
|
||||
if (td != NULL && fp != NULL)
|
||||
fdrop(fp, td);
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
@ -157,7 +178,6 @@ devfs_imfs_readv(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
|
||||
ssize_t total)
|
||||
{
|
||||
struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct uio uio = {
|
||||
.uio_iov = __DECONST(struct iovec *, iov),
|
||||
@ -168,8 +188,9 @@ devfs_imfs_readv(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
|
||||
.uio_rw = UIO_READ,
|
||||
.uio_td = td
|
||||
};
|
||||
struct file *fp = NULL;
|
||||
struct cdevsw *dsw = NULL;
|
||||
struct file *fpop;
|
||||
struct cdevsw *dsw;
|
||||
int error, ref;
|
||||
|
||||
if (td != NULL) {
|
||||
@ -180,6 +201,11 @@ devfs_imfs_readv(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
|
||||
if (cdev->si_flags & SI_ALIAS) {
|
||||
cdev = cdev->si_parent;
|
||||
}
|
||||
fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
|
||||
if (fp == NULL) {
|
||||
error = EBADF;
|
||||
goto err;
|
||||
}
|
||||
dsw = dev_refthread(cdev, &ref);
|
||||
if (dsw == NULL) {
|
||||
error = ENXIO;
|
||||
@ -190,12 +216,15 @@ devfs_imfs_readv(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
|
||||
error = dsw->d_read(cdev, &uio,
|
||||
rtems_libio_to_fcntl_flags(iop->flags));
|
||||
td->td_fpop = fpop;
|
||||
dev_relthread(cdev, ref);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
err:
|
||||
if (dsw != NULL)
|
||||
dev_relthread(cdev, ref);
|
||||
if (td != NULL && fp != NULL)
|
||||
fdrop(fp, td);
|
||||
if (error == 0) {
|
||||
return (total - uio.uio_resid);
|
||||
} else {
|
||||
@ -219,7 +248,6 @@ devfs_imfs_writev(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
|
||||
ssize_t total)
|
||||
{
|
||||
struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct uio uio = {
|
||||
.uio_iov = __DECONST(struct iovec *, iov),
|
||||
@ -230,8 +258,9 @@ devfs_imfs_writev(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
|
||||
.uio_rw = UIO_WRITE,
|
||||
.uio_td = td
|
||||
};
|
||||
struct file *fp = NULL;
|
||||
struct cdevsw *dsw = NULL;
|
||||
struct file *fpop;
|
||||
struct cdevsw *dsw;
|
||||
int error, ref;
|
||||
|
||||
if (td != NULL) {
|
||||
@ -242,6 +271,11 @@ devfs_imfs_writev(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
|
||||
if (cdev->si_flags & SI_ALIAS) {
|
||||
cdev = cdev->si_parent;
|
||||
}
|
||||
fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
|
||||
if (fp == NULL) {
|
||||
error = EBADF;
|
||||
goto err;
|
||||
}
|
||||
dsw = dev_refthread(cdev, &ref);
|
||||
if (dsw == NULL) {
|
||||
error = ENXIO;
|
||||
@ -252,12 +286,15 @@ devfs_imfs_writev(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
|
||||
error = dsw->d_write(cdev, &uio,
|
||||
rtems_libio_to_fcntl_flags(iop->flags));
|
||||
td->td_fpop = fpop;
|
||||
dev_relthread(cdev, ref);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
err:
|
||||
if (dsw != NULL)
|
||||
dev_relthread(cdev, ref);
|
||||
if (td != NULL && fp != NULL)
|
||||
fdrop(fp, td);
|
||||
if (error == 0) {
|
||||
return (total - uio.uio_resid);
|
||||
} else {
|
||||
@ -280,10 +317,10 @@ static int
|
||||
devfs_imfs_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
|
||||
{
|
||||
struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct thread *td = rtems_bsd_get_curthread_or_null();
|
||||
struct file *fp = NULL;
|
||||
struct cdevsw *dsw = NULL;
|
||||
struct file *fpop;
|
||||
struct cdevsw *dsw;
|
||||
int error, ref;
|
||||
int flags = rtems_libio_to_fcntl_flags(iop->flags);
|
||||
|
||||
@ -295,6 +332,11 @@ devfs_imfs_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
|
||||
if (cdev->si_flags & SI_ALIAS) {
|
||||
cdev = cdev->si_parent;
|
||||
}
|
||||
fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
|
||||
if (fp == NULL) {
|
||||
error = EBADF;
|
||||
goto err;
|
||||
}
|
||||
dsw = dev_refthread(cdev, &ref);
|
||||
if (dsw == NULL) {
|
||||
error = ENXIO;
|
||||
@ -305,12 +347,15 @@ devfs_imfs_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
|
||||
error = dsw->d_ioctl(cdev, request, buffer, flags,
|
||||
td);
|
||||
td->td_fpop = fpop;
|
||||
dev_relthread(cdev, ref);
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
|
||||
err:
|
||||
if (dsw != NULL)
|
||||
dev_relthread(cdev, ref);
|
||||
if (td != NULL && fp != NULL)
|
||||
fdrop(fp, td);
|
||||
return rtems_bsd_error_to_status_and_errno(error);
|
||||
}
|
||||
|
||||
@ -333,28 +378,43 @@ static int
|
||||
devfs_imfs_poll(rtems_libio_t *iop, int events)
|
||||
{
|
||||
struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct thread *td = rtems_bsd_get_curthread_or_wait_forever();
|
||||
struct file *fp = NULL;
|
||||
struct cdevsw *dsw = NULL;
|
||||
struct file *fpop;
|
||||
struct cdevsw *dsw;
|
||||
int error, ref;
|
||||
|
||||
if (cdev == NULL) {
|
||||
return POLLERR;
|
||||
if (td != 0) {
|
||||
if (cdev == NULL) {
|
||||
error = POLLERR;
|
||||
goto err;
|
||||
}
|
||||
if (cdev->si_flags & SI_ALIAS) {
|
||||
cdev = cdev->si_parent;
|
||||
}
|
||||
fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
|
||||
if (fp == NULL) {
|
||||
error = EBADF;
|
||||
goto err;
|
||||
}
|
||||
dsw = dev_refthread(cdev, &ref);
|
||||
if (dsw == NULL) {
|
||||
error = POLLERR;
|
||||
goto err;
|
||||
}
|
||||
fpop = td->td_fpop;
|
||||
curthread->td_fpop = fp;
|
||||
error = dsw->d_poll(cdev, events, td);
|
||||
td->td_fpop = fpop;
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
if (cdev->si_flags & SI_ALIAS) {
|
||||
cdev = cdev->si_parent;
|
||||
}
|
||||
dsw = dev_refthread(cdev, &ref);
|
||||
if (dsw == NULL) {
|
||||
return POLLERR;
|
||||
}
|
||||
fpop = td->td_fpop;
|
||||
curthread->td_fpop = fp;
|
||||
error = dsw->d_poll(cdev, events, td);
|
||||
td->td_fpop = fpop;
|
||||
dev_relthread(cdev, ref);
|
||||
|
||||
err:
|
||||
if (dsw != NULL)
|
||||
dev_relthread(cdev, ref);
|
||||
if (td != NULL && fp != NULL)
|
||||
fdrop(fp, td);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -362,28 +422,41 @@ static int
|
||||
devfs_imfs_kqfilter(rtems_libio_t *iop, struct knote *kn)
|
||||
{
|
||||
struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
|
||||
struct file *fp = rtems_bsd_iop_to_fp(iop);
|
||||
struct thread *td = rtems_bsd_get_curthread_or_wait_forever();
|
||||
struct file *fp = NULL;
|
||||
struct cdevsw *dsw = NULL;
|
||||
struct file *fpop;
|
||||
struct cdevsw *dsw;
|
||||
int error, ref;
|
||||
|
||||
if (cdev == NULL) {
|
||||
return EINVAL;
|
||||
if (td != 0) {
|
||||
if (cdev == NULL) {
|
||||
error = EINVAL;
|
||||
}
|
||||
fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
|
||||
if (fp == NULL) {
|
||||
error = EBADF;
|
||||
goto err;
|
||||
}
|
||||
if (cdev->si_flags & SI_ALIAS) {
|
||||
cdev = cdev->si_parent;
|
||||
}
|
||||
dsw = dev_refthread(cdev, &ref);
|
||||
if (dsw == NULL) {
|
||||
error = EINVAL;
|
||||
}
|
||||
fpop = td->td_fpop;
|
||||
curthread->td_fpop = fp;
|
||||
error = dsw->d_kqfilter(cdev, kn);
|
||||
td->td_fpop = fpop;
|
||||
} else {
|
||||
error = ENOMEM;
|
||||
}
|
||||
if (cdev->si_flags & SI_ALIAS) {
|
||||
cdev = cdev->si_parent;
|
||||
}
|
||||
dsw = dev_refthread(cdev, &ref);
|
||||
if (dsw == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
fpop = td->td_fpop;
|
||||
curthread->td_fpop = fp;
|
||||
error = dsw->d_kqfilter(cdev, kn);
|
||||
td->td_fpop = fpop;
|
||||
dev_relthread(cdev, ref);
|
||||
|
||||
err:
|
||||
if (dsw != NULL)
|
||||
dev_relthread(cdev, ref);
|
||||
if (td != NULL && fp != NULL)
|
||||
fdrop(fp, td);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
4763
rtemsbsd/sys/kern/vnode_if.c
Normal file
4763
rtemsbsd/sys/kern/vnode_if.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -34,6 +34,13 @@ static void default_wait_for_link_up( const char *name )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Work around the need for this declr and not being able to include sys/ioctl.h.
|
||||
*
|
||||
* rtems/bdbuf.h have a call to it
|
||||
*/
|
||||
int ioctl(int fd, unsigned long request, ...);
|
||||
|
||||
static void default_set_self_prio( rtems_task_priority prio )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
@ -50,9 +50,6 @@
|
||||
|
||||
#define TEST_NAME "LIBBSD SOFTWARE INTERRUPT 1"
|
||||
|
||||
uintptr_t rtems_bsd_allocator_domain_page_mbuf_size =
|
||||
RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT;
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
@ -65,6 +65,8 @@
|
||||
#include <rtems/bsd/modules.h>
|
||||
#include <rtems/libcsupport.h>
|
||||
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#define TEST_NAME "LIBBSD SYSCALLS 1"
|
||||
|
||||
typedef void (*no_mem_test_body)(int fd);
|
||||
@ -94,6 +96,7 @@ static socket_test socket_tests[] = {
|
||||
{ PF_INET, SOCK_DGRAM, 0, 0 },
|
||||
{ PF_INET, SOCK_SEQPACKET, 0, EPROTOTYPE },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_3PC, 0 },
|
||||
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_ADFS, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_AH, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_AHIP, 0 },
|
||||
@ -104,6 +107,7 @@ static socket_test socket_tests[] = {
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_BLT, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_BRSATMON, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_CARP, 0 },
|
||||
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_CFTP, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_CHAOS, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_CMTP, 0 },
|
||||
@ -112,6 +116,7 @@ static socket_test socket_tests[] = {
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_DDP, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_DGP, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_DSTOPTS, 0 },
|
||||
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_EGP, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_EMCON, 0 },
|
||||
{ PF_INET, SOCK_RAW, IPPROTO_ENCAP, 0 },
|
||||
@ -368,7 +373,7 @@ test_sockets(void)
|
||||
size_t n = sizeof(socket_tests) / sizeof(socket_tests[0]);
|
||||
size_t i;
|
||||
|
||||
puts("test sockets");
|
||||
puts("Test Sockets");
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
const socket_test *st = &socket_tests[i];
|
||||
@ -441,7 +446,8 @@ no_mem_socket_fstat(int fd)
|
||||
int rv;
|
||||
|
||||
rv = fstat(fd, &st);
|
||||
assert(rv == 0);
|
||||
assert(rv == -1);
|
||||
assert(errno == ENOMEM);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -450,7 +456,8 @@ no_mem_socket_shutdown(int fd)
|
||||
int rv;
|
||||
|
||||
rv = shutdown(fd, SHUT_RDWR);
|
||||
assert(rv == 0);
|
||||
assert(rv == -1);
|
||||
assert(errno == ENOMEM);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1591,12 +1598,12 @@ test_kqueue_unsupported_ops(void)
|
||||
errno = 0;
|
||||
n = read(kq, &buf[0], sizeof(buf));
|
||||
assert(n == -1);
|
||||
assert(errno == ENOTSUP);
|
||||
assert(errno == EOPNOTSUPP);
|
||||
|
||||
errno = 0;
|
||||
n = write(kq, &buf[0], sizeof(buf));
|
||||
assert(n == -1);
|
||||
assert(errno == ENOTSUP);
|
||||
assert(errno == EOPNOTSUPP);
|
||||
|
||||
errno = 0;
|
||||
rv = ioctl(kq, 0);
|
||||
@ -1636,7 +1643,8 @@ no_mem_kqueue_fstat(int fd)
|
||||
int rv;
|
||||
|
||||
rv = fstat(fd, &st);
|
||||
assert(rv == 0);
|
||||
assert(rv == -1);
|
||||
assert(errno == ENOMEM);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -278,6 +278,16 @@ test_kthread_add(void)
|
||||
static void
|
||||
test_rtems_bsd_get_curthread_or_null(void)
|
||||
{
|
||||
#ifdef TEST_IS_BROKEN
|
||||
/*
|
||||
* This part of test relies on nothing calling
|
||||
* rtems_bsd_get_current.*() before getting here so the workspace
|
||||
* can be consumed and the allocation fails. Changes in other
|
||||
* areas of libbsd have resulted in `Init` having a struct thread
|
||||
* object allocated.
|
||||
*
|
||||
* Maybe creating a new thread and using that would be a more stable test.
|
||||
*/
|
||||
rtems_resource_snapshot snapshot;
|
||||
void *greedy;
|
||||
|
||||
@ -290,12 +300,12 @@ test_rtems_bsd_get_curthread_or_null(void)
|
||||
rtems_workspace_greedy_free(greedy);
|
||||
|
||||
rtems_resource_snapshot_take(&snapshot);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
test_main(void)
|
||||
{
|
||||
|
||||
main_task_id = rtems_task_self();
|
||||
|
||||
/*
|
||||
|
@ -48,9 +48,6 @@
|
||||
|
||||
#define TEST_NAME "LIBBSD TIMEOUT 1"
|
||||
|
||||
uintptr_t rtems_bsd_allocator_domain_page_mbuf_size =
|
||||
RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT;
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
4
wscript
4
wscript
@ -145,7 +145,9 @@ def options(opt):
|
||||
action="store",
|
||||
default="",
|
||||
dest="freebsd_options",
|
||||
help="Set FreeBSD options (developer option).")
|
||||
help="Set FreeBSD options (developer option). Supported: " + \
|
||||
"bootverbose,verbose_sysinit,debug_locks,ktr,ktr_verbose," + \
|
||||
"rtems_bsd_descrip_trace,rtems_bsd_syscall_trace,rtems_bsd_vfs_trace")
|
||||
opt.add_option(
|
||||
"--optimization",
|
||||
action="store",
|
||||
|
Loading…
x
Reference in New Issue
Block a user