GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
ZERO_REGION(9) FreeBSD Kernel Developer's Manual ZERO_REGION(9)

zero_regionRead-only region prefilled with zeroes

#include <sys/param.h>
#include <sys/systm.h>
#include <vm/vm_param.h>

extern const void *zero_region;

The global variable zero_region points to a read-only region prefilled with zeroes. The size of the region is specified by the ZERO_REGION_SIZE macro.

The region zero_region points to is mapped to the same page multiple times.

/*
 * This function writes zeroes to the vnode at offset 0
 * with ZERO_REGION_SIZE length.
 */
static int
write_example(struct vnode *vp)
{
	struct thread *td;
	struct iovec aiov;
	struct uio auio;
	int error;

	td = curthread;

	aiov.iov_base = __DECONST(void *, zero_region);
	aiov.iov_len = ZERO_REGION_SIZE;
	auio.uio_iov = &aiov;
	auio.uio_iovcnt = 1;
	auio.uio_offset = 0;
	auio.uio_resid = ZERO_REGION_SIZE;
	auio.uio_segflg = UIO_SYSSPACE;
	auio.uio_rw = UIO_WRITE;
	auio.uio_td = td;

	error = VOP_WRITE(vp, &auio, 0, td->td_ucred);
	return (error);
}

pmap(9), vm_map(9)

This manual page was written by Ka Ho Ng <khng@FreeBSDFoundation.org> under sponsorship from the FreeBSD Foundation.

March 2, 2021 FreeBSD 14.3-RELEASE

Search for    or go to Top of page |  Section 9 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.