~psusi/ubuntu/precise/dmraid/fix-gpt

« back to all changes in this revision

Viewing changes to 1.0.0.rc14/tools/commands.h

  • Committer: Bazaar Package Importer
  • Author(s): Giuseppe Iuculano, 6af052c
  • Date: 2009-03-25 22:34:59 UTC
  • mfrom: (2.1.9 sid)
  • mto: (2.4.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20090325223459-y54f0rmxem7htn6r
Tags: 1.0.0.rc15-6
[6af052c] Remove 15_isw_incorrect_status_fix.patch, it causes a
segfault. (Closes: #521104)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2004,2005  Heinz Mauelshagen, Red Hat GmbH.
3
 
 *                          All rights reserved.
4
 
 *
5
 
 * See file LICENSE at the top of this source tree for license information.
6
 
 */
7
 
 
8
 
#ifndef _COMMANDS_H
9
 
#define _COMMANDS_H
10
 
 
11
 
#include <dmraid/lib_context.h>
12
 
 
13
 
#define ARRAY_SIZE(a)   (sizeof(a) / sizeof(*a))
14
 
#define ARRAY_END(a)    (a + ARRAY_SIZE(a))
15
 
 
16
 
/* Options actions dmraid performs. */
17
 
enum action {
18
 
        UNDEF           = 0x0,
19
 
        ACTIVATE        = 0x1,
20
 
        DEACTIVATE      = 0x2,
21
 
        FORMAT          = 0x4,
22
 
#ifndef DMRAID_MINI
23
 
        BLOCK_DEVICES   = 0x8,
24
 
        COLUMN          = 0x10,
25
 
        DBG             = 0x20,
26
 
        DUMP            = 0x40,
27
 
        ERASE           = 0x80,
28
 
        GROUP           = 0x100,
29
 
#endif
30
 
        HELP            = 0x200,
31
 
#ifndef DMRAID_MINI
32
 
        LIST_FORMATS    = 0x400,
33
 
#  ifdef        DMRAID_NATIVE_LOG
34
 
        NATIVE_LOG      = 0x800,
35
 
#  endif
36
 
#endif
37
 
        NOPARTITIONS    = 0x1000,
38
 
#ifndef DMRAID_MINI
39
 
        RAID_DEVICES    = 0x2000,
40
 
        RAID_SETS       = 0x4000,
41
 
        TEST            = 0x8000,
42
 
        VERBOSE         = 0x10000,
43
 
        ACTIVE          = 0x20000,
44
 
        INACTIVE        = 0x40000,
45
 
        SEPARATOR       = 0x80000,
46
 
#endif
47
 
        VERSION         = 0x100000,
48
 
        IGNORELOCKING   = 0x200000,
49
 
};
50
 
 
51
 
#define ALL_FLAGS       ((enum action) -1)
52
 
 
53
 
/* Arguments allowed ? */
54
 
enum args {
55
 
        NO_ARGS,
56
 
        ARGS,
57
 
};
58
 
 
59
 
/*
60
 
 * Action flag definitions for set_action().
61
 
 *
62
 
 * 'Early' options can be handled directly in set_action() by calling
63
 
 * the functions registered here (f_set member) handing in arg.
64
 
 */
65
 
struct actions {
66
 
        int option;             /* Option character/value. */
67
 
        enum action action;     /* Action flag for this option or UNDEF. */
68
 
        enum action needed;     /* Mandatory options or UNDEF if alone */
69
 
        enum action allowed;    /* Allowed flags (ie, other options allowed) */
70
 
 
71
 
        enum args args;         /* Arguments allowed ? */
72
 
 
73
 
        /* Function to call on hit or NULL */
74
 
        int (*f_set)(struct lib_context *lc, int arg);
75
 
        int arg;                /* Argument for above function call */
76
 
};
77
 
 
78
 
/* Define which metadata is needed before we can call post functions. */
79
 
enum metadata_need {
80
 
        M_NONE   = 0x00,
81
 
        M_DEVICE = 0x01,
82
 
        M_RAID   = 0x02,
83
 
        M_SET    = 0x04,
84
 
};
85
 
 
86
 
enum id {
87
 
        ROOT,
88
 
        ANY_ID,
89
 
};
90
 
 
91
 
enum lock {
92
 
        LOCK,
93
 
        NO_LOCK,
94
 
};
95
 
 
96
 
/* 
97
 
 * Pre and Post functions to perform for an option.
98
 
 */
99
 
struct prepost {
100
 
        enum action action;
101
 
        enum metadata_need metadata;
102
 
        enum id id;
103
 
        enum lock lock;
104
 
        int (*pre)(int arg);
105
 
        int arg;
106
 
        int (*post)(struct lib_context *lc, int arg);
107
 
};
108
 
 
109
 
int handle_args(struct lib_context *lc, int argc, char ***argv);
110
 
int perform(struct lib_context *lc, char **argv);
111
 
 
112
 
#endif