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