Whamcloud - gitweb
fix some bugs of snapfs
[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         {"snap_list", snap_snap_list, 0, 
45           "snap_list [table_no] list all the snapshots on the device\n"},
46         
47         /* User interface commands */
48         {"======= control ========", jt_noop, 0, "control commands"},
49         {"help", Parser_help, 0, "help"},
50         {"exit", jt_quit, 0, "quit"},
51         {"quit", jt_quit, 0, "quit"},
52         { 0, 0, 0, NULL }
53 };
54
55 int main(int argc, char **argv)
56 {
57         int rc;
58         
59         setlinebuf(stdout);
60
61         Parser_init("snapconf > ", cmdlist);
62         init_snap_list();
63         
64         if (argc > 1) {
65                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
66         } else {
67                 rc = Parser_commands();
68         }
69
70         return rc;
71 }
72