MCPcopy Create free account
hub / github.com/F-Stack/f-stack / oshmctl

Function oshmctl

freebsd/kern/sysv_shm.c:1294–1342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1292};
1293
1294static int
1295oshmctl(struct thread *td, struct oshmctl_args *uap)
1296{
1297#ifdef COMPAT_43
1298 int error = 0;
1299 struct prison *rpr;
1300 struct shmid_kernel *shmseg;
1301 struct oshmid_ds outbuf;
1302
1303 rpr = shm_find_prison(td->td_ucred);
1304 if (rpr == NULL)
1305 return (ENOSYS);
1306 if (uap->cmd != IPC_STAT) {
1307 return (freebsd7_shmctl(td,
1308 (struct freebsd7_shmctl_args *)uap));
1309 }
1310 SYSVSHM_LOCK();
1311 shmseg = shm_find_segment(rpr, uap->shmid, true);
1312 if (shmseg == NULL) {
1313 SYSVSHM_UNLOCK();
1314 return (EINVAL);
1315 }
1316 error = ipcperm(td, &shmseg->u.shm_perm, IPC_R);
1317 if (error != 0) {
1318 SYSVSHM_UNLOCK();
1319 return (error);
1320 }
1321#ifdef MAC
1322 error = mac_sysvshm_check_shmctl(td->td_ucred, shmseg, uap->cmd);
1323 if (error != 0) {
1324 SYSVSHM_UNLOCK();
1325 return (error);
1326 }
1327#endif
1328 ipcperm_new2old(&shmseg->u.shm_perm, &outbuf.shm_perm);
1329 outbuf.shm_segsz = shmseg->u.shm_segsz;
1330 outbuf.shm_cpid = shmseg->u.shm_cpid;
1331 outbuf.shm_lpid = shmseg->u.shm_lpid;
1332 outbuf.shm_nattch = shmseg->u.shm_nattch;
1333 outbuf.shm_atime = shmseg->u.shm_atime;
1334 outbuf.shm_dtime = shmseg->u.shm_dtime;
1335 outbuf.shm_ctime = shmseg->u.shm_ctime;
1336 outbuf.shm_handle = shmseg->object;
1337 SYSVSHM_UNLOCK();
1338 return (copyout(&outbuf, uap->ubuf, sizeof(outbuf)));
1339#else
1340 return (EINVAL);
1341#endif
1342}
1343
1344/* XXX casting to (sy_call_t *) is bogus, as usual. */
1345static sy_call_t *shmcalls[] = {

Callers

nothing calls this directly

Calls 7

shm_find_prisonFunction · 0.85
freebsd7_shmctlFunction · 0.85
shm_find_segmentFunction · 0.85
ipcpermFunction · 0.85
mac_sysvshm_check_shmctlFunction · 0.85
ipcperm_new2oldFunction · 0.85
copyoutFunction · 0.50

Tested by

no test coverage detected