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

@@ -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_ */