FreeBSD/sys/geom/vinum/geom_vinum.c
/* Handle userland request of attaching object. */
Handle userland request of attaching object.
Handle userland request of attaching object .
static void
gv_attach(struct gv_softc *sc, struct gctl_req *req)
{
	struct gv_volume *v;
	struct gv_plex *p;
	struct gv_sd *s;
	off_t *offset;
	int *rename, type_child, type_parent;
	char *child, *parent;
	child = gctl_get_param(req, "child", NULL);
	if (child == NULL) {
		gctl_error(req, "no child given");
		return;
	}
	parent = gctl_get_param(req, "parent", NULL);
	if (parent == NULL) {
		gctl_error(req, "no parent given");
		return;
	}
	offset = gctl_get_paraml(req, "offset", sizeof(*offset));
	if (offset == NULL) {
		gctl_error(req, "no offset given");
		return;
	}
	rename = gctl_get_paraml(req, "rename", sizeof(*rename));
	if (rename == NULL) {
		gctl_error(req, "no rename flag given");
		return;
	}
	type_child = gv_object_type(sc, child);
	type_parent = gv_object_type(sc, parent);
	switch (type_child) {
	case GV_TYPE_PLEX:
		if (type_parent != GV_TYPE_VOL) {
			gctl_error(req, "no such volume to attach to");
			return;
		}
		v = gv_find_vol(sc, parent);
		p = gv_find_plex(sc, child);
		gv_post_event(sc, GV_EVENT_ATTACH_PLEX, p, v, *offset, *rename);
		break;
	case GV_TYPE_SD:
		if (type_parent != GV_TYPE_PLEX) {
			gctl_error(req, "no such plex to attach to");
			return;
		}
		p = gv_find_plex(sc, parent);
		s = gv_find_sd(sc, child);
		gv_post_event(sc, GV_EVENT_ATTACH_SD, s, p, *offset, *rename);
		break;
	default:
		gctl_error(req, "invalid child type");
		break;
	}
}
static void gv_attach ( struct gv_softc * sc , struct gctl_req * req ) { struct gv_volume * v ; struct gv_plex * p ; struct gv_sd * s ; off_t * offset ; int * rename , type_child , type_parent ; char * child , * parent ; child = gctl_get_param ( req , " " , NULL ) ; if ( child == NULL ) { gctl_error ( req , " " ) ; return ; } parent = gctl_get_param ( req , " " , NULL ) ; if ( parent == NULL ) { gctl_error ( req , " " ) ; return ; } offset = gctl_get_paraml ( req , " " , sizeof ( * offset ) ) ; if ( offset == NULL ) { gctl_error ( req , " " ) ; return ; } rename = gctl_get_paraml ( req , " " , sizeof ( * rename ) ) ; if ( rename == NULL ) { gctl_error ( req , " " ) ; return ; } type_child = gv_object_type ( sc , child ) ; type_parent = gv_object_type ( sc , parent ) ; switch ( type_child ) { case GV_TYPE_PLEX : if ( type_parent != GV_TYPE_VOL ) { gctl_error ( req , " " ) ; return ; } v = gv_find_vol ( sc , parent ) ; p = gv_find_plex ( sc , child ) ; gv_post_event ( sc , GV_EVENT_ATTACH_PLEX , p , v , * offset , * rename ) ; break ; case GV_TYPE_SD : if ( type_parent != GV_TYPE_PLEX ) { gctl_error ( req , " " ) ; return ; } p = gv_find_plex ( sc , parent ) ; s = gv_find_sd ( sc , child ) ; gv_post_event ( sc , GV_EVENT_ATTACH_SD , s , p , * offset , * rename ) ; break ; default : gctl_error ( req , " " ) ; break ; } }
Handle userland request of attaching object.
Handle userland request of attaching object .