Whamcloud - gitweb
minor: verbose on sec register.
[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         {"device_list", snap_dev_list, 0, 
39           "device_list list snap available device\n"},
40         {"device", snap_dev_open, 0, 
41           "dev <device> open available snap device\n"},
42         {"add", snap_snap_add, 0, 
43           "add [table_no] <snap_name> add snapshot to the device\n"},
44         {"del", snap_snap_del, 0,
45           "del [table_no] <snap_name> del snapshot to the device\n"},
46         {"snap_list", snap_snap_list, 0, 
47           "snap_list [table_no] list all the snapshots on the device\n"},
48         
49         /* User interface commands */
50         {"======= control ========", jt_noop, 0, "control commands"},
51         {"help", Parser_help, 0, "help"},
52         {"exit", jt_quit, 0, "quit"},
53         {"quit", jt_quit, 0, "quit"},
54         { 0, 0, 0, NULL }
55 };
56
57 int main(int argc, char **argv)
58 {
59         int rc;
60         
61         setlinebuf(stdout);
62
63         Parser_init("snapconf > ", cmdlist);
64         init_snap_list();
65         
66         if (argc > 1) {
67                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
68         } else {
69                 rc = Parser_commands();
70         }
71
72         return rc;
73 }
74