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

Function vop_stdallocate

freebsd/kern/vfs_default.c:947–1078  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

945}
946
947int
948vop_stdallocate(struct vop_allocate_args *ap)
949{
950#ifdef __notyet__
951 struct statfs *sfs;
952 off_t maxfilesize = 0;
953#endif
954 struct iovec aiov;
955 struct vattr vattr, *vap;
956 struct uio auio;
957 off_t fsize, len, cur, offset;
958 uint8_t *buf;
959 struct thread *td;
960 struct vnode *vp;
961 size_t iosize;
962 int error;
963
964 buf = NULL;
965 error = 0;
966 td = curthread;
967 vap = &vattr;
968 vp = ap->a_vp;
969 len = *ap->a_len;
970 offset = *ap->a_offset;
971
972 error = VOP_GETATTR(vp, vap, td->td_ucred);
973 if (error != 0)
974 goto out;
975 fsize = vap->va_size;
976 iosize = vap->va_blocksize;
977 if (iosize == 0)
978 iosize = BLKDEV_IOSIZE;
979 if (iosize > maxphys)
980 iosize = maxphys;
981 buf = malloc(iosize, M_TEMP, M_WAITOK);
982
983#ifdef __notyet__
984 /*
985 * Check if the filesystem sets f_maxfilesize; if not use
986 * VOP_SETATTR to perform the check.
987 */
988 sfs = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
989 error = VFS_STATFS(vp->v_mount, sfs, td);
990 if (error == 0)
991 maxfilesize = sfs->f_maxfilesize;
992 free(sfs, M_STATFS);
993 if (error != 0)
994 goto out;
995 if (maxfilesize) {
996 if (offset > maxfilesize || len > maxfilesize ||
997 offset + len > maxfilesize) {
998 error = EFBIG;
999 goto out;
1000 }
1001 } else
1002#endif
1003 if (offset + len > vap->va_size) {
1004 /*

Callers

nothing calls this directly

Calls 5

VOP_GETATTRFunction · 0.85
mallocFunction · 0.85
bzeroFunction · 0.85
should_yieldFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected