kernels/linux-2.4.0/drivers/md/lvm.c
/*
 * character device support function logical volume status by name
 */
character device support function logical volume status by name
character device support function logical volume status by name
static int lvm_do_lv_status_byname(vg_t *vg_ptr, void *arg)
{
	uint l;
	ulong size;
	lv_t lv;
	lv_t *lv_ptr;
	lv_status_byname_req_t lv_status_byname_req;
	if (vg_ptr == NULL) return -ENXIO;
	if (copy_from_user(&lv_status_byname_req, arg,
			   sizeof(lv_status_byname_req_t)) != 0)
		return -EFAULT;
	if (lv_status_byname_req.lv == NULL) return -EINVAL;
	if (copy_from_user(&lv, lv_status_byname_req.lv,
			   sizeof(lv_t)) != 0)
		return -EFAULT;
	for (l = 0; l < vg_ptr->lv_max; l++) {
		lv_ptr = vg_ptr->lv[l];
		if (lv_ptr != NULL &&
		    strcmp(lv_ptr->lv_name,
			    lv_status_byname_req.lv_name) == 0) {
			if (copy_to_user(lv_status_byname_req.lv,
					 lv_ptr,
					 sizeof(lv_t)) != 0)
				return -EFAULT;
			if (lv.lv_current_pe != NULL) {
				size = lv_ptr->lv_allocated_le *
				       sizeof(pe_t);
				if (copy_to_user(lv.lv_current_pe,
						 lv_ptr->lv_current_pe,
						 size) != 0)
					return -EFAULT;
			}
			return 0;
		}
	}
	return -ENXIO;
}
static int lvm_do_lv_status_byname ( vg_t * vg_ptr , void * arg ) { uint l ; ulong size ; lv_t lv ; lv_t * lv_ptr ; lv_status_byname_req_t lv_status_byname_req ; if ( vg_ptr == NULL ) return - ENXIO ; if ( copy_from_user ( & lv_status_byname_req , arg , sizeof ( lv_status_byname_req_t ) ) != 0 ) return - EFAULT ; if ( lv_status_byname_req . lv == NULL ) return - EINVAL ; if ( copy_from_user ( & lv , lv_status_byname_req . lv , sizeof ( lv_t ) ) != 0 ) return - EFAULT ; for ( l = 0 ; l < vg_ptr -> lv_max ; l ++ ) { lv_ptr = vg_ptr -> lv [ l ] ; if ( lv_ptr != NULL && strcmp ( lv_ptr -> lv_name , lv_status_byname_req . lv_name ) == 0 ) { if ( copy_to_user ( lv_status_byname_req . lv , lv_ptr , sizeof ( lv_t ) ) != 0 ) return - EFAULT ; if ( lv . lv_current_pe != NULL ) { size = lv_ptr -> lv_allocated_le * sizeof ( pe_t ) ; if ( copy_to_user ( lv . lv_current_pe , lv_ptr -> lv_current_pe , size ) != 0 ) return - EFAULT ; } return 0 ; } } return - ENXIO ; }
character device support function logical volume status by name
character device support function logical volume status by name