1 /*	$NetBSD: freeseg.c,v 1.1.1.1 2008/12/22 00:18:01 haad Exp $	*/
2 
3 /*
4  * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
5  *
6  * This file is part of LVM2.
7  *
8  * This copyrighted material is made available to anyone wishing to use,
9  * modify, copy, or redistribute it subject to the terms and conditions
10  * of the GNU Lesser General Public License v.2.1.
11  *
12  * You should have received a copy of the GNU Lesser General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16 
17 #include "lib.h"
18 #include "toolcontext.h"
19 #include "segtype.h"
20 #include "display.h"
21 #include "text_export.h"
22 #include "text_import.h"
23 #include "config.h"
24 #include "str_list.h"
25 #include "targets.h"
26 #include "lvm-string.h"
27 #include "activate.h"
28 #include "str_list.h"
29 #include "metadata.h"
30 
31 static const char *_freeseg_name(const struct lv_segment *seg)
32 {
33 	return seg->segtype->name;
34 }
35 
36 static void _freeseg_destroy(const struct segment_type *segtype)
37 {
38 	dm_free((void *)segtype);
39 }
40 
41 static struct segtype_handler _freeseg_ops = {
42 	.name = _freeseg_name,
43 	.destroy = _freeseg_destroy,
44 };
45 
46 struct segment_type *init_free_segtype(struct cmd_context *cmd)
47 {
48 	struct segment_type *segtype = dm_malloc(sizeof(*segtype));
49 
50 	if (!segtype)
51 		return_NULL;
52 
53 	segtype->cmd = cmd;
54 	segtype->ops = &_freeseg_ops;
55 	segtype->name = "free";
56 	segtype->private = NULL;
57 	segtype->flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
58 
59 	log_very_verbose("Initialised segtype: %s", segtype->name);
60 
61 	return segtype;
62 }
63