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

Function vm_mmap_vnode

freebsd/vm/vm_mmap.c:1277–1382  ·  view source on GitHub ↗

* vm_mmap_vnode() * * Helper function for vm_mmap. Perform sanity check specific for mmap * operations on vnodes. */

Source from the content-addressed store, hash-verified

1275 * operations on vnodes.
1276 */
1277int
1278vm_mmap_vnode(struct thread *td, vm_size_t objsize,
1279 vm_prot_t prot, vm_prot_t *maxprotp, int *flagsp,
1280 struct vnode *vp, vm_ooffset_t *foffp, vm_object_t *objp,
1281 boolean_t *writecounted)
1282{
1283 struct vattr va;
1284 vm_object_t obj;
1285 vm_ooffset_t foff;
1286 struct ucred *cred;
1287 int error, flags;
1288 bool writex;
1289
1290 cred = td->td_ucred;
1291 writex = (*maxprotp & VM_PROT_WRITE) != 0 &&
1292 (*flagsp & MAP_SHARED) != 0;
1293 if ((error = vget(vp, LK_SHARED)) != 0)
1294 return (error);
1295 AUDIT_ARG_VNODE1(vp);
1296 foff = *foffp;
1297 flags = *flagsp;
1298 obj = vp->v_object;
1299 if (vp->v_type == VREG) {
1300 /*
1301 * Get the proper underlying object
1302 */
1303 if (obj == NULL) {
1304 error = EINVAL;
1305 goto done;
1306 }
1307 if (obj->type == OBJT_VNODE && obj->handle != vp) {
1308 vput(vp);
1309 vp = (struct vnode *)obj->handle;
1310 /*
1311 * Bypass filesystems obey the mpsafety of the
1312 * underlying fs. Tmpfs never bypasses.
1313 */
1314 error = vget(vp, LK_SHARED);
1315 if (error != 0)
1316 return (error);
1317 }
1318 if (writex) {
1319 *writecounted = TRUE;
1320 vm_pager_update_writecount(obj, 0, objsize);
1321 }
1322 } else {
1323 error = EINVAL;
1324 goto done;
1325 }
1326 if ((error = VOP_GETATTR(vp, &va, cred)))
1327 goto done;
1328#ifdef MAC
1329 /* This relies on VM_PROT_* matching PROT_*. */
1330 error = mac_vnode_check_mmap(cred, vp, (int)prot, flags);
1331 if (error != 0)
1332 goto done;
1333#endif
1334 if ((flags & MAP_SHARED) != 0) {

Callers 2

vfs_vnops.cFile · 0.85
vm_mmapFunction · 0.85

Calls 8

vgetFunction · 0.85
vputFunction · 0.85
VOP_GETATTRFunction · 0.85
mac_vnode_check_mmapFunction · 0.85
vm_pager_allocateFunction · 0.85
vm_object_referenceFunction · 0.85
vm_object_colorFunction · 0.85

Tested by

no test coverage detected