1*7c604eeaShaad /* $NetBSD: lvremove.c,v 1.1.1.3 2009/12/02 00:25:52 haad Exp $ */
256a34939Shaad
356a34939Shaad /*
456a34939Shaad * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
556a34939Shaad * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
656a34939Shaad *
756a34939Shaad * This file is part of LVM2.
856a34939Shaad *
956a34939Shaad * This copyrighted material is made available to anyone wishing to use,
1056a34939Shaad * modify, copy, or redistribute it subject to the terms and conditions
1156a34939Shaad * of the GNU Lesser General Public License v.2.1.
1256a34939Shaad *
1356a34939Shaad * You should have received a copy of the GNU Lesser General Public License
1456a34939Shaad * along with this program; if not, write to the Free Software Foundation,
1556a34939Shaad * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1656a34939Shaad */
1756a34939Shaad
1856a34939Shaad #include "tools.h"
1956a34939Shaad
lvremove_single(struct cmd_context * cmd,struct logical_volume * lv,void * handle __attribute ((unused)))2056a34939Shaad static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
2156a34939Shaad void *handle __attribute((unused)))
2256a34939Shaad {
23*7c604eeaShaad struct logical_volume *origin;
24*7c604eeaShaad
25*7c604eeaShaad /*
26*7c604eeaShaad * If this is a sparse device, remove its origin too.
27*7c604eeaShaad */
28*7c604eeaShaad if (lv_is_cow(lv) && lv_is_virtual_origin(origin = origin_from_cow(lv)))
29*7c604eeaShaad lv = origin;
30*7c604eeaShaad
31*7c604eeaShaad if (!lv_remove_with_dependencies(cmd, lv, arg_count(cmd, force_ARG))) {
32*7c604eeaShaad stack;
3356a34939Shaad return ECMD_FAILED;
34*7c604eeaShaad }
3556a34939Shaad
3656a34939Shaad return ECMD_PROCESSED;
3756a34939Shaad }
3856a34939Shaad
lvremove(struct cmd_context * cmd,int argc,char ** argv)3956a34939Shaad int lvremove(struct cmd_context *cmd, int argc, char **argv)
4056a34939Shaad {
4156a34939Shaad if (!argc) {
4256a34939Shaad log_error("Please enter one or more logical volume paths");
4356a34939Shaad return EINVALID_CMD_LINE;
4456a34939Shaad }
4556a34939Shaad
4656a34939Shaad cmd->handles_missing_pvs = 1;
4756a34939Shaad
48*7c604eeaShaad return process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, NULL,
4956a34939Shaad &lvremove_single);
5056a34939Shaad }
51