Lines Matching refs:mfd

98 	struct memfd *mfd;
105 mfd = kmem_zalloc(sizeof(*mfd), KM_SLEEP);
106 mfd->mfd_size = 0;
107 mfd->mfd_uobj = uao_create(INT64_MAX - PAGE_SIZE, 0); /* same as tmpfs */
110 strcpy(mfd->mfd_name, memfd_prefix);
112 &mfd->mfd_name[sizeof(memfd_prefix) - 1],
113 sizeof(mfd->mfd_name) - sizeof(memfd_prefix), NULL);
117 getnanotime(&mfd->mfd_btime);
120 mfd->mfd_seals |= F_SEAL_SEAL;
129 fp->f_memfd = mfd;
137 uao_detach(mfd->mfd_uobj);
138 kmem_free(mfd, sizeof(*mfd));
148 struct memfd *mfd = fp->f_memfd;
158 if (*offp >= mfd->mfd_size) {
164 todo = MIN(uio->uio_resid, mfd->mfd_size - *offp);
165 error = ubc_uiomove(mfd->mfd_uobj, uio, todo, UVM_ADV_SEQUENTIAL,
171 getnanotime(&mfd->mfd_atime);
185 struct memfd *mfd = fp->f_memfd;
189 if (mfd->mfd_seals & F_SEAL_ANY_WRITE) {
202 if (mfd->mfd_seals & F_SEAL_GROW) {
203 if (*offp >= mfd->mfd_size) {
209 if (*offp + uio->uio_resid >= mfd->mfd_size)
210 todo = mfd->mfd_size - *offp;
211 } else if (*offp + uio->uio_resid >= mfd->mfd_size) {
218 error = ubc_uiomove(mfd->mfd_uobj, uio, todo, UVM_ADV_SEQUENTIAL,
223 getnanotime(&mfd->mfd_mtime);
241 struct memfd *mfd = fp->f_memfd;
246 strncpy(data, mfd->mfd_name, MAXPATHLEN);
252 if (mfd->mfd_seals & F_SEAL_SEAL) {
269 if ((mfd->mfd_seals & F_SEAL_WRITE) == 0 &&
271 mfd->mfd_uobj->uo_refs > 1)
277 mfd->mfd_seals |= *(int *)data;
285 *(int *)data = mfd->mfd_seals;
297 struct memfd *mfd = fp->f_memfd;
304 st->st_size = mfd->mfd_size;
307 if ((mfd->mfd_seals & F_SEAL_ANY_WRITE) == 0)
310 st->st_birthtimespec = mfd->mfd_btime;
311 st->st_ctimespec = mfd->mfd_mtime;
312 st->st_atimespec = mfd->mfd_atime;
313 st->st_mtimespec = mfd->mfd_mtime;
323 struct memfd *mfd = fp->f_memfd;
325 uao_detach(mfd->mfd_uobj);
327 kmem_free(mfd, sizeof(*mfd));
337 struct memfd *mfd = fp->f_memfd;
351 if (*offp + size > mfd->mfd_size) {
356 if ((mfd->mfd_seals & F_SEAL_ANY_WRITE) &&
415 struct memfd *mfd = fp->f_memfd;
423 if (length == mfd->mfd_size)
426 if ((mfd->mfd_seals & F_SEAL_SHRINK) && length < mfd->mfd_size)
428 if ((mfd->mfd_seals & F_SEAL_GROW) && length > mfd->mfd_size)
431 if (length > mfd->mfd_size)
432 ubc_zerorange(mfd->mfd_uobj, mfd->mfd_size,
433 length - mfd->mfd_size, 0);
435 /* length < mfd->mfd_size, so try to get rid of excess pages */
437 end = round_page(mfd->mfd_size);
440 rw_enter(mfd->mfd_uobj->vmobjlock, RW_WRITER);
441 error = (*mfd->mfd_uobj->pgops->pgo_put)(mfd->mfd_uobj,
447 getnanotime(&mfd->mfd_mtime);
448 mfd->mfd_size = length;