Deprecate the msgsys(), semsys(), and shmsys() system calls by moving
them under COMPAT_FREEBSD[4567]. Starting with FreeBSD 5.0 the SYSV IPC API was implemented via direct system calls (e.g. msgctl(), msgget(), etc.) rather than indirecting through the var-args *sys() system calls. The shmsys() system call was already effectively deprecated for all but COMPAT_FREEBSD4 already as its implementation for the !COMPAT_FREEBSD4 case was to simply invoke nosys().
This commit is contained in:
parent
f95dcaae42
commit
45f48220bb
@ -334,15 +334,12 @@
|
||||
struct rtprio *rtp); }
|
||||
167 AUE_NULL UNIMPL nosys
|
||||
168 AUE_NULL UNIMPL nosys
|
||||
; 169 is initialized by the SYSVSEM code if present or loaded
|
||||
169 AUE_SEMSYS NOSTD { int semsys(int which, int a2, int a3, \
|
||||
int a4, int a5); }
|
||||
; XXX should be { int semsys(int which, ...); }
|
||||
; 170 is initialized by the SYSVMSG code if present or loaded
|
||||
170 AUE_MSGSYS NOSTD { int msgsys(int which, int a2, int a3, \
|
||||
int a4, int a5, int a6); }
|
||||
; XXX should be { int msgsys(int which, ...); }
|
||||
; 171 is initialized by the SYSVSHM code if present or loaded
|
||||
171 AUE_SHMSYS NOSTD { int shmsys(int which, int a2, int a3, \
|
||||
int a4); }
|
||||
; XXX should be { int shmsys(int which, ...); }
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_compat.h"
|
||||
#include "opt_sysvipc.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -85,12 +86,6 @@ static int sysvmsg_modload(struct module *, int, void *);
|
||||
|
||||
static void msg_freehdr(struct msg *msghdr);
|
||||
|
||||
/* XXX casting to (sy_call_t *) is bogus, as usual. */
|
||||
static sy_call_t *msgcalls[] = {
|
||||
(sy_call_t *)msgctl, (sy_call_t *)msgget,
|
||||
(sy_call_t *)msgsnd, (sy_call_t *)msgrcv
|
||||
};
|
||||
|
||||
#ifndef MSGSSZ
|
||||
#define MSGSSZ 8 /* Each segment must be 2^N long */
|
||||
#endif
|
||||
@ -308,7 +303,6 @@ static moduledata_t sysvmsg_mod = {
|
||||
NULL
|
||||
};
|
||||
|
||||
SYSCALL_MODULE_HELPER(msgsys);
|
||||
SYSCALL_MODULE_HELPER(msgctl);
|
||||
SYSCALL_MODULE_HELPER(msgget);
|
||||
SYSCALL_MODULE_HELPER(msgsnd);
|
||||
@ -317,33 +311,6 @@ SYSCALL_MODULE_HELPER(msgrcv);
|
||||
DECLARE_MODULE(sysvmsg, sysvmsg_mod, SI_SUB_SYSV_MSG, SI_ORDER_FIRST);
|
||||
MODULE_VERSION(sysvmsg, 1);
|
||||
|
||||
/*
|
||||
* Entry point for all MSG calls.
|
||||
*/
|
||||
int
|
||||
msgsys(td, uap)
|
||||
struct thread *td;
|
||||
/* XXX actually varargs. */
|
||||
struct msgsys_args /* {
|
||||
int which;
|
||||
int a2;
|
||||
int a3;
|
||||
int a4;
|
||||
int a5;
|
||||
int a6;
|
||||
} */ *uap;
|
||||
{
|
||||
int error;
|
||||
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
|
||||
return (ENOSYS);
|
||||
if (uap->which < 0 ||
|
||||
uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
|
||||
return (EINVAL);
|
||||
error = (*msgcalls[uap->which])(td, &uap->a2);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static void
|
||||
msg_freehdr(msghdr)
|
||||
struct msg *msghdr;
|
||||
@ -1289,3 +1256,42 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, &msginfo.msgseg, 0,
|
||||
"Number of message segments");
|
||||
SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLFLAG_RD,
|
||||
NULL, 0, sysctl_msqids, "", "Message queue IDs");
|
||||
|
||||
#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
|
||||
defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
|
||||
SYSCALL_MODULE_HELPER(msgsys);
|
||||
|
||||
/* XXX casting to (sy_call_t *) is bogus, as usual. */
|
||||
static sy_call_t *msgcalls[] = {
|
||||
(sy_call_t *)msgctl, (sy_call_t *)msgget,
|
||||
(sy_call_t *)msgsnd, (sy_call_t *)msgrcv
|
||||
};
|
||||
|
||||
/*
|
||||
* Entry point for all MSG calls.
|
||||
*/
|
||||
int
|
||||
msgsys(td, uap)
|
||||
struct thread *td;
|
||||
/* XXX actually varargs. */
|
||||
struct msgsys_args /* {
|
||||
int which;
|
||||
int a2;
|
||||
int a3;
|
||||
int a4;
|
||||
int a5;
|
||||
int a6;
|
||||
} */ *uap;
|
||||
{
|
||||
int error;
|
||||
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
|
||||
return (ENOSYS);
|
||||
if (uap->which < 0 ||
|
||||
uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
|
||||
return (EINVAL);
|
||||
error = (*msgcalls[uap->which])(td, &uap->a2);
|
||||
return (error);
|
||||
}
|
||||
#endif /* COMPAT_FREEBSD4 || COMPAT_FREEBSD5 || COMPAT_FREEBSD6 ||
|
||||
COMPAT_FREEBSD7 */
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_compat.h"
|
||||
#include "opt_sysvipc.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -90,12 +91,6 @@ static int semundo_adjust(struct thread *td, struct sem_undo **supptr,
|
||||
int semid, int semseq, int semnum, int adjval);
|
||||
static void semundo_clear(int semid, int semnum);
|
||||
|
||||
/* XXX casting to (sy_call_t *) is bogus, as usual. */
|
||||
static sy_call_t *semcalls[] = {
|
||||
(sy_call_t *)__semctl, (sy_call_t *)semget,
|
||||
(sy_call_t *)semop
|
||||
};
|
||||
|
||||
static struct mtx sem_mtx; /* semaphore global lock */
|
||||
static struct mtx sem_undo_mtx;
|
||||
static int semtot = 0;
|
||||
@ -317,7 +312,6 @@ static moduledata_t sysvsem_mod = {
|
||||
NULL
|
||||
};
|
||||
|
||||
SYSCALL_MODULE_HELPER(semsys);
|
||||
SYSCALL_MODULE_HELPER(__semctl);
|
||||
SYSCALL_MODULE_HELPER(semget);
|
||||
SYSCALL_MODULE_HELPER(semop);
|
||||
@ -325,32 +319,6 @@ SYSCALL_MODULE_HELPER(semop);
|
||||
DECLARE_MODULE(sysvsem, sysvsem_mod, SI_SUB_SYSV_SEM, SI_ORDER_FIRST);
|
||||
MODULE_VERSION(sysvsem, 1);
|
||||
|
||||
/*
|
||||
* Entry point for all SEM calls.
|
||||
*/
|
||||
int
|
||||
semsys(td, uap)
|
||||
struct thread *td;
|
||||
/* XXX actually varargs. */
|
||||
struct semsys_args /* {
|
||||
int which;
|
||||
int a2;
|
||||
int a3;
|
||||
int a4;
|
||||
int a5;
|
||||
} */ *uap;
|
||||
{
|
||||
int error;
|
||||
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
|
||||
return (ENOSYS);
|
||||
if (uap->which < 0 ||
|
||||
uap->which >= sizeof(semcalls)/sizeof(semcalls[0]))
|
||||
return (EINVAL);
|
||||
error = (*semcalls[uap->which])(td, &uap->a2);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new sem_undo structure for a process
|
||||
* (returns ptr to structure or NULL if no more room)
|
||||
@ -1345,3 +1313,41 @@ sysctl_sema(SYSCTL_HANDLER_ARGS)
|
||||
return (SYSCTL_OUT(req, sema,
|
||||
sizeof(struct semid_kernel) * seminfo.semmni));
|
||||
}
|
||||
|
||||
#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
|
||||
defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
|
||||
SYSCALL_MODULE_HELPER(semsys);
|
||||
|
||||
/* XXX casting to (sy_call_t *) is bogus, as usual. */
|
||||
static sy_call_t *semcalls[] = {
|
||||
(sy_call_t *)__semctl, (sy_call_t *)semget,
|
||||
(sy_call_t *)semop
|
||||
};
|
||||
|
||||
/*
|
||||
* Entry point for all SEM calls.
|
||||
*/
|
||||
int
|
||||
semsys(td, uap)
|
||||
struct thread *td;
|
||||
/* XXX actually varargs. */
|
||||
struct semsys_args /* {
|
||||
int which;
|
||||
int a2;
|
||||
int a3;
|
||||
int a4;
|
||||
int a5;
|
||||
} */ *uap;
|
||||
{
|
||||
int error;
|
||||
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
|
||||
return (ENOSYS);
|
||||
if (uap->which < 0 ||
|
||||
uap->which >= sizeof(semcalls)/sizeof(semcalls[0]))
|
||||
return (EINVAL);
|
||||
error = (*semcalls[uap->which])(td, &uap->a2);
|
||||
return (error);
|
||||
}
|
||||
#endif /* COMPAT_FREEBSD4 || COMPAT_FREEBSD5 || COMPAT_FREEBSD6 ||
|
||||
COMPAT_FREEBSD7 */
|
||||
|
@ -96,25 +96,11 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
static MALLOC_DEFINE(M_SHM, "shm", "SVID compatible shared memory segments");
|
||||
|
||||
#if defined(__i386__) && (defined(COMPAT_FREEBSD4) || defined(COMPAT_43))
|
||||
struct oshmctl_args;
|
||||
static int oshmctl(struct thread *td, struct oshmctl_args *uap);
|
||||
#endif
|
||||
|
||||
static int shmget_allocate_segment(struct thread *td,
|
||||
struct shmget_args *uap, int mode);
|
||||
static int shmget_existing(struct thread *td, struct shmget_args *uap,
|
||||
int mode, int segnum);
|
||||
|
||||
#if defined(__i386__) && (defined(COMPAT_FREEBSD4) || defined(COMPAT_43))
|
||||
/* XXX casting to (sy_call_t *) is bogus, as usual. */
|
||||
static sy_call_t *shmcalls[] = {
|
||||
(sy_call_t *)shmat, (sy_call_t *)oshmctl,
|
||||
(sy_call_t *)shmdt, (sy_call_t *)shmget,
|
||||
(sy_call_t *)shmctl
|
||||
};
|
||||
#endif
|
||||
|
||||
#define SHMSEG_FREE 0x0200
|
||||
#define SHMSEG_REMOVED 0x0400
|
||||
#define SHMSEG_ALLOCATED 0x0800
|
||||
@ -447,78 +433,6 @@ shmat(td, uap)
|
||||
return kern_shmat(td, uap->shmid, uap->shmaddr, uap->shmflg);
|
||||
}
|
||||
|
||||
#if defined(__i386__) && (defined(COMPAT_FREEBSD4) || defined(COMPAT_43))
|
||||
struct oshmid_ds {
|
||||
struct ipc_perm shm_perm; /* operation perms */
|
||||
int shm_segsz; /* size of segment (bytes) */
|
||||
u_short shm_cpid; /* pid, creator */
|
||||
u_short shm_lpid; /* pid, last operation */
|
||||
short shm_nattch; /* no. of current attaches */
|
||||
time_t shm_atime; /* last attach time */
|
||||
time_t shm_dtime; /* last detach time */
|
||||
time_t shm_ctime; /* last change time */
|
||||
void *shm_handle; /* internal handle for shm segment */
|
||||
};
|
||||
|
||||
struct oshmctl_args {
|
||||
int shmid;
|
||||
int cmd;
|
||||
struct oshmid_ds *ubuf;
|
||||
};
|
||||
static int
|
||||
oshmctl(td, uap)
|
||||
struct thread *td;
|
||||
struct oshmctl_args *uap;
|
||||
{
|
||||
#ifdef COMPAT_43
|
||||
int error = 0;
|
||||
struct shmid_kernel *shmseg;
|
||||
struct oshmid_ds outbuf;
|
||||
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
|
||||
return (ENOSYS);
|
||||
mtx_lock(&Giant);
|
||||
shmseg = shm_find_segment_by_shmid(uap->shmid);
|
||||
if (shmseg == NULL) {
|
||||
error = EINVAL;
|
||||
goto done2;
|
||||
}
|
||||
switch (uap->cmd) {
|
||||
case IPC_STAT:
|
||||
error = ipcperm(td, &shmseg->u.shm_perm, IPC_R);
|
||||
if (error)
|
||||
goto done2;
|
||||
#ifdef MAC
|
||||
error = mac_sysvshm_check_shmctl(td->td_ucred, shmseg, uap->cmd);
|
||||
if (error != 0)
|
||||
goto done2;
|
||||
#endif
|
||||
outbuf.shm_perm = shmseg->u.shm_perm;
|
||||
outbuf.shm_segsz = shmseg->u.shm_segsz;
|
||||
outbuf.shm_cpid = shmseg->u.shm_cpid;
|
||||
outbuf.shm_lpid = shmseg->u.shm_lpid;
|
||||
outbuf.shm_nattch = shmseg->u.shm_nattch;
|
||||
outbuf.shm_atime = shmseg->u.shm_atime;
|
||||
outbuf.shm_dtime = shmseg->u.shm_dtime;
|
||||
outbuf.shm_ctime = shmseg->u.shm_ctime;
|
||||
outbuf.shm_handle = shmseg->u.shm_internal;
|
||||
error = copyout(&outbuf, uap->ubuf, sizeof(outbuf));
|
||||
if (error)
|
||||
goto done2;
|
||||
break;
|
||||
default:
|
||||
error = shmctl(td, (struct shmctl_args *)uap);
|
||||
break;
|
||||
}
|
||||
done2:
|
||||
mtx_unlock(&Giant);
|
||||
return (error);
|
||||
#else
|
||||
return (EINVAL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
kern_shmctl(td, shmid, cmd, buf, bufsz)
|
||||
struct thread *td;
|
||||
@ -839,34 +753,6 @@ done2:
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
shmsys(td, uap)
|
||||
struct thread *td;
|
||||
/* XXX actually varargs. */
|
||||
struct shmsys_args /* {
|
||||
int which;
|
||||
int a2;
|
||||
int a3;
|
||||
int a4;
|
||||
} */ *uap;
|
||||
{
|
||||
#if defined(__i386__) && (defined(COMPAT_FREEBSD4) || defined(COMPAT_43))
|
||||
int error;
|
||||
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
|
||||
return (ENOSYS);
|
||||
if (uap->which < 0 ||
|
||||
uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0]))
|
||||
return (EINVAL);
|
||||
mtx_lock(&Giant);
|
||||
error = (*shmcalls[uap->which])(td, &uap->a2);
|
||||
mtx_unlock(&Giant);
|
||||
return (error);
|
||||
#else
|
||||
return (nosys(td, NULL));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
shmfork_myhook(p1, p2)
|
||||
struct proc *p1, *p2;
|
||||
@ -991,6 +877,112 @@ sysctl_shmsegs(SYSCTL_HANDLER_ARGS)
|
||||
return (SYSCTL_OUT(req, shmsegs, shmalloced * sizeof(shmsegs[0])));
|
||||
}
|
||||
|
||||
#if defined(__i386__) && (defined(COMPAT_FREEBSD4) || defined(COMPAT_43))
|
||||
struct oshmid_ds {
|
||||
struct ipc_perm_old shm_perm; /* operation perms */
|
||||
int shm_segsz; /* size of segment (bytes) */
|
||||
u_short shm_cpid; /* pid, creator */
|
||||
u_short shm_lpid; /* pid, last operation */
|
||||
short shm_nattch; /* no. of current attaches */
|
||||
time_t shm_atime; /* last attach time */
|
||||
time_t shm_dtime; /* last detach time */
|
||||
time_t shm_ctime; /* last change time */
|
||||
void *shm_handle; /* internal handle for shm segment */
|
||||
};
|
||||
|
||||
struct oshmctl_args {
|
||||
int shmid;
|
||||
int cmd;
|
||||
struct oshmid_ds *ubuf;
|
||||
};
|
||||
|
||||
static int
|
||||
oshmctl(td, uap)
|
||||
struct thread *td;
|
||||
struct oshmctl_args *uap;
|
||||
{
|
||||
#ifdef COMPAT_43
|
||||
int error = 0;
|
||||
struct shmid_kernel *shmseg;
|
||||
struct oshmid_ds outbuf;
|
||||
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
|
||||
return (ENOSYS);
|
||||
mtx_lock(&Giant);
|
||||
shmseg = shm_find_segment_by_shmid(uap->shmid);
|
||||
if (shmseg == NULL) {
|
||||
error = EINVAL;
|
||||
goto done2;
|
||||
}
|
||||
switch (uap->cmd) {
|
||||
case IPC_STAT:
|
||||
error = ipcperm(td, &shmseg->u.shm_perm, IPC_R);
|
||||
if (error)
|
||||
goto done2;
|
||||
#ifdef MAC
|
||||
error = mac_sysvshm_check_shmctl(td->td_ucred, shmseg, uap->cmd);
|
||||
if (error != 0)
|
||||
goto done2;
|
||||
#endif
|
||||
ipcperm_new2old(&shmseg->u.shm_perm, &outbuf.shm_perm);
|
||||
outbuf.shm_segsz = shmseg->u.shm_segsz;
|
||||
outbuf.shm_cpid = shmseg->u.shm_cpid;
|
||||
outbuf.shm_lpid = shmseg->u.shm_lpid;
|
||||
outbuf.shm_nattch = shmseg->u.shm_nattch;
|
||||
outbuf.shm_atime = shmseg->u.shm_atime;
|
||||
outbuf.shm_dtime = shmseg->u.shm_dtime;
|
||||
outbuf.shm_ctime = shmseg->u.shm_ctime;
|
||||
outbuf.shm_handle = shmseg->object;
|
||||
error = copyout(&outbuf, uap->ubuf, sizeof(outbuf));
|
||||
if (error)
|
||||
goto done2;
|
||||
break;
|
||||
default:
|
||||
error = freebsd7_shmctl(td, (struct shmctl_args *)uap);
|
||||
break;
|
||||
}
|
||||
done2:
|
||||
mtx_unlock(&Giant);
|
||||
return (error);
|
||||
#else
|
||||
return (EINVAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* XXX casting to (sy_call_t *) is bogus, as usual. */
|
||||
static sy_call_t *shmcalls[] = {
|
||||
(sy_call_t *)shmat, (sy_call_t *)oshmctl,
|
||||
(sy_call_t *)shmdt, (sy_call_t *)shmget,
|
||||
(sy_call_t *)shmctl
|
||||
};
|
||||
|
||||
int
|
||||
shmsys(td, uap)
|
||||
struct thread *td;
|
||||
/* XXX actually varargs. */
|
||||
struct shmsys_args /* {
|
||||
int which;
|
||||
int a2;
|
||||
int a3;
|
||||
int a4;
|
||||
} */ *uap;
|
||||
{
|
||||
int error;
|
||||
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
|
||||
return (ENOSYS);
|
||||
if (uap->which < 0 ||
|
||||
uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0]))
|
||||
return (EINVAL);
|
||||
mtx_lock(&Giant);
|
||||
error = (*shmcalls[uap->which])(td, &uap->a2);
|
||||
mtx_unlock(&Giant);
|
||||
return (error);
|
||||
}
|
||||
|
||||
SYSCALL_MODULE_HELPER(shmsys);
|
||||
#endif /* i386 && (COMPAT_FREEBSD4 || COMPAT_43) */
|
||||
|
||||
static int
|
||||
sysvshm_modload(struct module *module, int cmd, void *arg)
|
||||
{
|
||||
@ -1018,7 +1010,6 @@ static moduledata_t sysvshm_mod = {
|
||||
NULL
|
||||
};
|
||||
|
||||
SYSCALL_MODULE_HELPER(shmsys);
|
||||
SYSCALL_MODULE_HELPER(shmat);
|
||||
SYSCALL_MODULE_HELPER(shmctl);
|
||||
SYSCALL_MODULE_HELPER(shmdt);
|
||||
|
Loading…
x
Reference in New Issue
Block a user