Use default PID value for all process identifiers

This commit is contained in:
Sebastian Huber 2013-10-10 15:00:20 +02:00
parent 549488b572
commit cc5f4b2705
13 changed files with 67 additions and 80 deletions

View File

@ -56,7 +56,6 @@ LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-condvar.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-conf.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-copyinout.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-delay.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-descrip.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-file.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-init.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-init-with-irq.c

View File

@ -613,7 +613,6 @@ rtems.addRTEMSSourceFiles(
'rtems/rtems-bsd-conf.c',
'rtems/rtems-bsd-copyinout.c',
'rtems/rtems-bsd-delay.c',
'rtems/rtems-bsd-descrip.c',
'rtems/rtems-bsd-get-file.c',
'rtems/rtems-bsd-init.c',
'rtems/rtems-bsd-init-with-irq.c',

View File

@ -1490,7 +1490,11 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
bcopy(&pr->rule, rule, sizeof(struct pf_rule));
#ifdef __FreeBSD__
rule->cuid = td->td_ucred->cr_ruid;
#ifndef __rtems__
rule->cpid = td->td_proc ? td->td_proc->p_pid : 0;
#else /* __rtems__ */
rule->cpid = BSD_DEFAULT_PID;
#endif /* __rtems__ */
#else
rule->cuid = p->p_cred->p_ruid;
rule->cpid = p->p_pid;
@ -1760,7 +1764,11 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
bcopy(&pcr->rule, newrule, sizeof(struct pf_rule));
#ifdef __FreeBSD__
newrule->cuid = td->td_ucred->cr_ruid;
#ifndef __rtems__
newrule->cpid = td->td_proc ? td->td_proc->p_pid : 0;
#else /* __rtems__ */
newrule->cpid = BSD_DEFAULT_PID;
#endif /* __rtems__ */
#else
newrule->cuid = p->p_cred->p_ruid;
newrule->cpid = p->p_pid;

View File

@ -491,7 +491,11 @@ tapopen(struct cdev *dev, int flag, int mode, struct thread *td)
}
bcopy(IF_LLADDR(tp->tap_ifp), tp->ether_addr, sizeof(tp->ether_addr));
#ifndef __rtems__
tp->tap_pid = td->td_proc->p_pid;
#else /* __rtems__ */
tp->tap_pid = BSD_DEFAULT_PID;
#endif /* __rtems__ */
tp->tap_flags |= TAP_OPEN;
ifp = tp->tap_ifp;

View File

@ -421,11 +421,19 @@ tunopen(struct cdev *dev, int flag, int mode, struct thread *td)
* with a simple busy flag?
*/
mtx_lock(&tp->tun_mtx);
#ifndef __rtems__
if (tp->tun_pid != 0 && tp->tun_pid != td->td_proc->p_pid) {
#else /* __rtems__ */
if (tp->tun_pid != 0 && tp->tun_pid != BSD_DEFAULT_PID) {
#endif /* __rtems__ */
mtx_unlock(&tp->tun_mtx);
return (EBUSY);
}
#ifndef __rtems__
tp->tun_pid = td->td_proc->p_pid;
#else /* __rtems__ */
tp->tun_pid = BSD_DEFAULT_PID;
#endif /* __rtems__ */
tp->tun_flags |= TUN_OPEN;
ifp = TUN2IFP(tp);
@ -754,7 +762,11 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
break;
case TUNSIFPID:
mtx_lock(&tp->tun_mtx);
tp->tun_pid = curthread->td_proc->p_pid;
#ifndef __rtems__
tp->tun_pid = curthread->td_proc->p_pid;
#else /* __rtems__ */
tp->tun_pid = BSD_DEFAULT_PID;
#endif /* __rtems__ */
mtx_unlock(&tp->tun_mtx);
break;
case FIONBIO:

View File

@ -544,7 +544,11 @@ route_output(struct mbuf *m, struct socket *so)
info.rti_info[RTAX_DST] = NULL;
senderr(EPROTONOSUPPORT);
}
#ifndef __rtems__
rtm->rtm_pid = curproc->p_pid;
#else /* __rtems__ */
rtm->rtm_pid = BSD_DEFAULT_PID;
#endif /* __rtems__ */
bzero(&info, sizeof(info));
info.rti_addrs = rtm->rtm_addrs;
if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) {

View File

@ -576,7 +576,6 @@ struct proc {
struct cv p_pwait; /* (*) wait cv for exit/exec */
#else /* __rtems__ */
struct ucred *p_ucred; /* (c) Process owner's identity. */
rtems_id p_pid;
#endif /* __rtems__ */
};

View File

@ -59,9 +59,40 @@ struct sigio {
SLIST_HEAD(sigiolst, sigio);
#ifndef __rtems__
pid_t fgetown(struct sigio **sigiop);
int fsetown(pid_t pgid, struct sigio **sigiop);
void funsetown(struct sigio **sigiop);
void funsetownlst(struct sigiolst *sigiolst);
#else /* __rtems__ */
static inline pid_t
fgetown(struct sigio **sigiop)
{
(void) sigiop;
return BSD_DEFAULT_PID;
}
static inline int
fsetown(pid_t pgid, struct sigio **sigiop)
{
(void) pgid;
(void) sigiop;
return (0);
}
static inline void
funsetown(struct sigio **sigiop)
{
(void) sigiop;
}
static inline void
funsetownlst(struct sigiolst *sigiolst)
{
(void) sigiolst;
}
#endif /* __rtems__ */
#endif /* _SYS_SIGIO_H_ */

View File

@ -53,6 +53,9 @@ the current Git submodule commit is this
* Multiple routing tables are not supported. Every FIB value is set to zero
(= BSD_DEFAULT_FIB).
* Process identifiers are not supported. Every PID value is set to zero
(= BSD_DEFAULT_PID).
* Sebastian Huber and Joel Sherrill discussed the need for a a basic USB
functionality test that is known to work on qemu pc.

View File

@ -138,6 +138,8 @@ void rtems_bsd_assert_func(const char *file, int line, const char *func, const c
#define BSD_DEFAULT_FIB 0
#define BSD_DEFAULT_PID 0
extern rtems_chain_control rtems_bsd_lock_chain;
extern rtems_chain_control rtems_bsd_mtx_chain;

View File

@ -1,74 +0,0 @@
/**
* @file
*
* @ingroup rtems_bsd_rtems
*
* @brief TODO.
*/
/*
* Copyright (c) 2012 On-Line Applications Research Corporation (OAR).
* 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-config.h>
#include <rtems/bsd/sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/domain.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/filio.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <rtems/bsd/sys/lock.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/priv.h>
#include <sys/proc.h>
/*
* This routine is not supported in the RTEMS interface
*/
void
funsetown(struct sigio **sigiop)
{
/* XXX sigiop isn't supported by process for rtems */
}
/*
* This routine is not supported in the RTEMS interface
*/
int
fsetown(pid_t pgid, struct sigio **sigiop)
{
/* XXX sigiop isn't supported by process for rtems */
return 0;
}

View File

@ -38,6 +38,7 @@
*/
#include <machine/rtems-bsd-config.h>
#include <machine/rtems-bsd-thread.h>
#include <rtems/bsd/sys/types.h>
#include <rtems/bsd/sys/param.h>
@ -662,7 +663,7 @@ kern_sendit(td, s, mp, flags, control, segflg)
/* Generation of SIGPIPE can be controlled per socket */
if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) &&
!(flags & MSG_NOSIGNAL)) {
killinfo(td->td_proc->p_pid, SIGPIPE, NULL);
killinfo(rtems_bsd_get_task_id(td), SIGPIPE, NULL);
}
}
if (error == 0)

View File

@ -216,7 +216,6 @@ rtems_bsd_threads_init(void *arg __unused)
FIXME_ucred.cr_ngroups = 1; /* group 0 */
FIXME_proc.p_ucred = crhold(&FIXME_ucred);
FIXME_proc.p_pid = getpid();
}
SYSINIT(rtems_bsd_threads, SI_SUB_INTRINSIC, SI_ORDER_ANY, rtems_bsd_threads_init, NULL);