Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sendfile.c
Show First 20 Lines • Show All 565 Lines • ▼ Show 20 Lines | sendfile_getobj(struct thread *td, struct file *fp, vm_object_t *obj_res, | ||||
int *bsize) | int *bsize) | ||||
{ | { | ||||
struct vattr va; | struct vattr va; | ||||
vm_object_t obj; | vm_object_t obj; | ||||
struct vnode *vp; | struct vnode *vp; | ||||
struct shmfd *shmfd; | struct shmfd *shmfd; | ||||
int error; | int error; | ||||
error = 0; | |||||
vp = *vp_res = NULL; | vp = *vp_res = NULL; | ||||
obj = NULL; | obj = NULL; | ||||
shmfd = *shmfd_res = NULL; | shmfd = *shmfd_res = NULL; | ||||
*bsize = 0; | *bsize = 0; | ||||
/* | /* | ||||
* The file descriptor must be a regular file and have a | * The file descriptor must be a regular file and have a | ||||
* backing VM object. | * backing VM object. | ||||
Show All 23 Lines | if (fp->f_type == DTYPE_VNODE) { | ||||
} else { | } else { | ||||
error = VOP_GETATTR(vp, &va, td->td_ucred); | error = VOP_GETATTR(vp, &va, td->td_ucred); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
*obj_size = va.va_size; | *obj_size = va.va_size; | ||||
VM_OBJECT_RLOCK(obj); | VM_OBJECT_RLOCK(obj); | ||||
} | } | ||||
} else if (fp->f_type == DTYPE_SHM) { | } else if (fp->f_type == DTYPE_SHM) { | ||||
error = 0; | |||||
shmfd = fp->f_data; | shmfd = fp->f_data; | ||||
obj = shmfd->shm_object; | obj = shmfd->shm_object; | ||||
VM_OBJECT_RLOCK(obj); | VM_OBJECT_RLOCK(obj); | ||||
*obj_size = shmfd->shm_size; | *obj_size = shmfd->shm_size; | ||||
} else { | } else { | ||||
error = EINVAL; | error = EINVAL; | ||||
goto out; | goto out; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 746 Lines • Show Last 20 Lines |