Whamcloud - gitweb
add snapconf utils
[fs/lustre-release.git] / lustre / snapfs / utils / snapconf.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *      utils/snapconf.c
6  *
7  */
8
9
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <portals/api-support.h>
13 #include <portals/ptlctl.h>
14 #include <portals/list.h>
15 #include "parser.h"
16 #include "snapctl.h"
17
18 static int jt_quit(int argc, char **argv) {
19         Parser_quit(argc, argv);
20         return 0;
21 }
22
23 static int jt_noop(int argc, char **argv) {
24         return 0;
25 }
26
27 static int jt_opt_ignore_errors(int argc, char **argv) {
28         Parser_ignore_errors(1);
29         return 0;
30 }
31
32 command_t cmdlist[] = {
33         /* Metacommands */
34         {"--ignore_errors", jt_opt_ignore_errors, 0,
35          "ignore errors that occur during script processing\n"
36          "--ignore_errors"},
37         /* snapshot commands*/
38         {"add", snapshot_add, 0, 
39           "add [table_no] <snap_name> add snapshot to the device\n"},
40         {"list", snapshot_list, 0, "snap_list list snap available device\n"},
41         {"dev", snapshot_dev, 0, "open <device> open available snap device\n"},
42
43         /* User interface commands */
44         {"======= control ========", jt_noop, 0, "control commands"},
45         {"help", Parser_help, 0, "help"},
46         {"exit", jt_quit, 0, "quit"},
47         {"quit", jt_quit, 0, "quit"},
48         { 0, 0, 0, NULL }
49 };
50
51 int main(int argc, char **argv)
52 {
53         int rc;
54         
55         setlinebuf(stdout);
56
57         Parser_init("snapconf > ", cmdlist);
58         init_snap_list();
59         
60         if (argc > 1) {
61                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
62         } else {
63                 rc = Parser_commands();
64         }
65
66         return rc;
67 }
68