186d7f5d3SJohn Marino /* $NetBSD: freeseg.c,v 1.1.1.1 2008/12/22 00:18:01 haad Exp $ */
286d7f5d3SJohn Marino
386d7f5d3SJohn Marino /*
486d7f5d3SJohn Marino * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
586d7f5d3SJohn Marino *
686d7f5d3SJohn Marino * This file is part of LVM2.
786d7f5d3SJohn Marino *
886d7f5d3SJohn Marino * This copyrighted material is made available to anyone wishing to use,
986d7f5d3SJohn Marino * modify, copy, or redistribute it subject to the terms and conditions
1086d7f5d3SJohn Marino * of the GNU Lesser General Public License v.2.1.
1186d7f5d3SJohn Marino *
1286d7f5d3SJohn Marino * You should have received a copy of the GNU Lesser General Public License
1386d7f5d3SJohn Marino * along with this program; if not, write to the Free Software Foundation,
1486d7f5d3SJohn Marino * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1586d7f5d3SJohn Marino */
1686d7f5d3SJohn Marino
1786d7f5d3SJohn Marino #include "lib.h"
1886d7f5d3SJohn Marino #include "toolcontext.h"
1986d7f5d3SJohn Marino #include "segtype.h"
2086d7f5d3SJohn Marino #include "display.h"
2186d7f5d3SJohn Marino #include "text_export.h"
2286d7f5d3SJohn Marino #include "text_import.h"
2386d7f5d3SJohn Marino #include "config.h"
2486d7f5d3SJohn Marino #include "str_list.h"
2586d7f5d3SJohn Marino #include "targets.h"
2686d7f5d3SJohn Marino #include "lvm-string.h"
2786d7f5d3SJohn Marino #include "activate.h"
2886d7f5d3SJohn Marino #include "str_list.h"
2986d7f5d3SJohn Marino #include "metadata.h"
3086d7f5d3SJohn Marino
_freeseg_name(const struct lv_segment * seg)3186d7f5d3SJohn Marino static const char *_freeseg_name(const struct lv_segment *seg)
3286d7f5d3SJohn Marino {
3386d7f5d3SJohn Marino return seg->segtype->name;
3486d7f5d3SJohn Marino }
3586d7f5d3SJohn Marino
_freeseg_destroy(const struct segment_type * segtype)3686d7f5d3SJohn Marino static void _freeseg_destroy(const struct segment_type *segtype)
3786d7f5d3SJohn Marino {
3886d7f5d3SJohn Marino dm_free((void *)segtype);
3986d7f5d3SJohn Marino }
4086d7f5d3SJohn Marino
4186d7f5d3SJohn Marino static struct segtype_handler _freeseg_ops = {
4286d7f5d3SJohn Marino .name = _freeseg_name,
4386d7f5d3SJohn Marino .destroy = _freeseg_destroy,
4486d7f5d3SJohn Marino };
4586d7f5d3SJohn Marino
init_free_segtype(struct cmd_context * cmd)4686d7f5d3SJohn Marino struct segment_type *init_free_segtype(struct cmd_context *cmd)
4786d7f5d3SJohn Marino {
4886d7f5d3SJohn Marino struct segment_type *segtype = dm_malloc(sizeof(*segtype));
4986d7f5d3SJohn Marino
5086d7f5d3SJohn Marino if (!segtype)
5186d7f5d3SJohn Marino return_NULL;
5286d7f5d3SJohn Marino
5386d7f5d3SJohn Marino segtype->cmd = cmd;
5486d7f5d3SJohn Marino segtype->ops = &_freeseg_ops;
5586d7f5d3SJohn Marino segtype->name = "free";
5686d7f5d3SJohn Marino segtype->private = NULL;
5786d7f5d3SJohn Marino segtype->flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
5886d7f5d3SJohn Marino
5986d7f5d3SJohn Marino log_very_verbose("Initialised segtype: %s", segtype->name);
6086d7f5d3SJohn Marino
6186d7f5d3SJohn Marino return segtype;
6286d7f5d3SJohn Marino }
63