kernels/linux-2.4.0/drivers/md/lvm.c
/*
 * character device support function VG rename
 */
character device support function VG rename
character device support function VG rename
static int lvm_do_vg_rename(vg_t *vg_ptr, void *arg)
{
	int l = 0, p = 0, len = 0;
	char vg_name[NAME_LEN] = { 0,};
	char lv_name[NAME_LEN] = { 0,};
	char *ptr = NULL;
	lv_t *lv_ptr = NULL;
	pv_t *pv_ptr = NULL;
	if (copy_from_user(vg_name, arg, sizeof(vg_name)) != 0)
		return -EFAULT;
#if defined CONFIG_LVM_PROC_FS && defined CONFIG_PROC_FS
	lvm_do_remove_proc_entry_of_vg ( vg_ptr);
#endif
	strncpy ( vg_ptr->vg_name, vg_name, sizeof ( vg_name)-1);
	for ( l = 0; l < vg_ptr->lv_max; l++)
	{
		if ((lv_ptr = vg_ptr->lv[l]) == NULL) continue;
		strncpy(lv_ptr->vg_name, vg_name, sizeof ( vg_name));
		ptr = strrchr(lv_ptr->lv_name, '/');
		if (ptr == NULL) ptr = lv_ptr->lv_name;
		strncpy(lv_name, ptr, sizeof ( lv_name));
		len = sizeof(LVM_DIR_PREFIX);
		strcpy(lv_ptr->lv_name, LVM_DIR_PREFIX);
		strncat(lv_ptr->lv_name, vg_name, NAME_LEN - len);
		len += strlen ( vg_name);
		strncat(lv_ptr->lv_name, lv_name, NAME_LEN - len);
	}
	for ( p = 0; p < vg_ptr->pv_max; p++)
	{
		if ( (pv_ptr = vg_ptr->pv[p]) == NULL) continue;
		strncpy(pv_ptr->vg_name, vg_name, NAME_LEN);
	}
#if defined CONFIG_LVM_PROC_FS && defined CONFIG_PROC_FS
	lvm_do_create_proc_entry_of_vg ( vg_ptr);
#endif
	return 0;
}
static int lvm_do_vg_rename ( vg_t * vg_ptr , void * arg ) { int l = 0 , p = 0 , len = 0 ; char vg_name [ NAME_LEN ] = { 0 , } ; char lv_name [ NAME_LEN ] = { 0 , } ; char * ptr = NULL ; lv_t * lv_ptr = NULL ; pv_t * pv_ptr = NULL ; if ( copy_from_user ( vg_name , arg , sizeof ( vg_name ) ) != 0 ) return - EFAULT ; #if defined CONFIG_LVM_PROC_FS && defined CONFIG_PROC_FS lvm_do_remove_proc_entry_of_vg ( vg_ptr ) ; #endif strncpy ( vg_ptr -> vg_name , vg_name , sizeof ( vg_name ) - 1 ) ; for ( l = 0 ; l < vg_ptr -> lv_max ; l ++ ) { if ( ( lv_ptr = vg_ptr -> lv [ l ] ) == NULL ) continue ; strncpy ( lv_ptr -> vg_name , vg_name , sizeof ( vg_name ) ) ; ptr = strrchr ( lv_ptr -> lv_name , ' ' ) ; if ( ptr == NULL ) ptr = lv_ptr -> lv_name ; strncpy ( lv_name , ptr , sizeof ( lv_name ) ) ; len = sizeof ( LVM_DIR_PREFIX ) ; strcpy ( lv_ptr -> lv_name , LVM_DIR_PREFIX ) ; strncat ( lv_ptr -> lv_name , vg_name , NAME_LEN - len ) ; len += strlen ( vg_name ) ; strncat ( lv_ptr -> lv_name , lv_name , NAME_LEN - len ) ; } for ( p = 0 ; p < vg_ptr -> pv_max ; p ++ ) { if ( ( pv_ptr = vg_ptr -> pv [ p ] ) == NULL ) continue ; strncpy ( pv_ptr -> vg_name , vg_name , NAME_LEN ) ; } #if defined CONFIG_LVM_PROC_FS && defined CONFIG_PROC_FS lvm_do_create_proc_entry_of_vg ( vg_ptr ) ; #endif return 0 ; }
character device support function VG rename
character device support function VG rename