[BACK]Return to remove.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sbin / gpt

Annotation of src/sbin/gpt/remove.c, Revision 1.21.16.1

1.1       christos    1: /*-
                      2:  * Copyright (c) 2004 Marcel Moolenaar
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  *
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  * 2. Redistributions in binary form must reproduce the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer in the
                     13:  *    documentation and/or other materials provided with the distribution.
                     14:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     16:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     17:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     18:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     19:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     20:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     21:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     22:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     23:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     24:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     25:  */
                     26:
1.14      christos   27: #if HAVE_NBTOOL_CONFIG_H
                     28: #include "nbtool_config.h"
                     29: #endif
                     30:
1.1       christos   31: #include <sys/cdefs.h>
1.2       christos   32: #ifdef __FBSDID
1.1       christos   33: __FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
1.2       christos   34: #endif
                     35: #ifdef __RCSID
1.21.16.1! christos   36: __RCSID("$NetBSD: remove.c,v 1.22 2018/07/03 03:41:24 jnemeth Exp $");
1.2       christos   37: #endif
1.1       christos   38:
                     39: #include <sys/types.h>
                     40:
                     41: #include <err.h>
                     42: #include <stddef.h>
                     43: #include <stdio.h>
                     44: #include <stdlib.h>
                     45: #include <string.h>
                     46: #include <unistd.h>
                     47:
                     48: #include "map.h"
                     49: #include "gpt.h"
1.18      christos   50: #include "gpt_private.h"
1.1       christos   51:
1.19      christos   52: static int cmd_remove(gpt_t, int, char *[]);
1.4       riz        53:
1.19      christos   54: static const char *removehelp[] = {
1.21      christos   55:        "-a",
                     56:        "[-b blocknr] [-i index] [-L label] [-s sectors] [-t type]",
1.19      christos   57: };
                     58:
                     59: struct gpt_cmd c_remove = {
                     60:        "remove",
                     61:        cmd_remove,
                     62:        removehelp, __arraycount(removehelp),
1.21.16.1! christos   63:        GPT_SYNC,
1.19      christos   64: };
1.1       christos   65:
1.19      christos   66: #define usage() gpt_usage(NULL, &c_remove)
1.1       christos   67:
1.20      christos   68: static void
                     69: change(struct gpt_ent *ent, void *v)
1.1       christos   70: {
1.20      christos   71:        /* Remove the primary entry by clearing the partition type. */
                     72:        gpt_uuid_copy(ent->ent_type, gpt_uuid_nil);
1.1       christos   73: }
                     74:
1.19      christos   75: static int
1.18      christos   76: cmd_remove(gpt_t gpt, int argc, char *argv[])
1.1       christos   77: {
1.18      christos   78:        int ch;
1.20      christos   79:        struct gpt_find find;
                     80:
                     81:        memset(&find, 0, sizeof(find));
                     82:        find.msg = "removed";
1.1       christos   83:
                     84:        /* Get the remove options */
1.20      christos   85:        while ((ch = getopt(argc, argv, GPT_FIND)) != -1)
                     86:                if (gpt_add_find(gpt, &find, ch) == -1)
1.19      christos   87:                        return usage();
1.1       christos   88:
1.18      christos   89:        if (argc != optind)
1.19      christos   90:                return usage();
1.1       christos   91:
1.20      christos   92:        return gpt_change_ent(gpt, &find, change, NULL);
1.1       christos   93: }

CVSweb <webmaster@jp.NetBSD.org>