Makes a series of non-trivial calls.
[libguestfs.git] / src / guestfs-actions.c
1 /* libguestfs generated file
2  * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3  * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
4  *
5  * Copyright (C) 2009 Red Hat Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 struct mount_rv {
23   int err_code;      /* 0 OK or -1 error */
24   int serial;        /* serial number of reply */
25   char err_str[GUESTFS_ERROR_LEN]; /* error from daemon */
26 };
27
28 static void mount_cb (guestfs_h *g, void *data, XDR *xdr)
29 {
30   struct mount_rv *rv = (struct mount_rv *) data;
31
32   /* XXX */ rv->err_code = 0;
33   /* XXX rv->serial = ?; */
34   main_loop.main_loop_quit (g);
35 }
36
37 int guestfs_mount (guestfs_h *g,
38                 const char *device,
39                 const char *mountpoint)
40 {
41   struct guestfs_mount_args args;
42   struct mount_rv rv;
43   int serial;
44
45   if (g->state != READY) {
46     error (g, "guestfs_mount called from the wrong state, %d != READY",
47       g->state);
48     return -1;
49   }
50
51   args.device = (char *) device;
52   args.mountpoint = (char *) mountpoint;
53   serial = dispatch (g, GUESTFS_PROC_MOUNT,
54                      (xdrproc_t) xdr_guestfs_mount_args, (char *) &args);
55   if (serial == -1)
56     return -1;
57
58   rv.err_code = 42;
59   g->reply_cb_internal = mount_cb;
60   g->reply_cb_internal_data = &rv;
61   main_loop.main_loop_run (g);
62   g->reply_cb_internal = NULL;
63   g->reply_cb_internal_data = NULL;
64   if (rv.err_code == 42) { /* callback wasn't called */
65     error (g, "guestfs_mount failed, see earlier error messages");
66     return -1;
67   }
68   else if (rv.err_code == -1) { /* error from remote end */
69     error (g, "%s", rv.err_str);
70     return -1;
71   }
72
73   /* XXX check serial number agrees */
74
75   return 0;
76 }
77
78 struct sync_rv {
79   int err_code;      /* 0 OK or -1 error */
80   int serial;        /* serial number of reply */
81   char err_str[GUESTFS_ERROR_LEN]; /* error from daemon */
82 };
83
84 static void sync_cb (guestfs_h *g, void *data, XDR *xdr)
85 {
86   struct sync_rv *rv = (struct sync_rv *) data;
87
88   /* XXX */ rv->err_code = 0;
89   /* XXX rv->serial = ?; */
90   main_loop.main_loop_quit (g);
91 }
92
93 int guestfs_sync (guestfs_h *g)
94 {
95   struct sync_rv rv;
96   int serial;
97
98   if (g->state != READY) {
99     error (g, "guestfs_sync called from the wrong state, %d != READY",
100       g->state);
101     return -1;
102   }
103   serial = dispatch (g, GUESTFS_PROC_SYNC, NULL, NULL);
104   if (serial == -1)
105     return -1;
106
107   rv.err_code = 42;
108   g->reply_cb_internal = sync_cb;
109   g->reply_cb_internal_data = &rv;
110   main_loop.main_loop_run (g);
111   g->reply_cb_internal = NULL;
112   g->reply_cb_internal_data = NULL;
113   if (rv.err_code == 42) { /* callback wasn't called */
114     error (g, "guestfs_sync failed, see earlier error messages");
115     return -1;
116   }
117   else if (rv.err_code == -1) { /* error from remote end */
118     error (g, "%s", rv.err_str);
119     return -1;
120   }
121
122   /* XXX check serial number agrees */
123
124   return 0;
125 }
126
127 struct touch_rv {
128   int err_code;      /* 0 OK or -1 error */
129   int serial;        /* serial number of reply */
130   char err_str[GUESTFS_ERROR_LEN]; /* error from daemon */
131 };
132
133 static void touch_cb (guestfs_h *g, void *data, XDR *xdr)
134 {
135   struct touch_rv *rv = (struct touch_rv *) data;
136
137   /* XXX */ rv->err_code = 0;
138   /* XXX rv->serial = ?; */
139   main_loop.main_loop_quit (g);
140 }
141
142 int guestfs_touch (guestfs_h *g,
143                 const char *path)
144 {
145   struct guestfs_touch_args args;
146   struct touch_rv rv;
147   int serial;
148
149   if (g->state != READY) {
150     error (g, "guestfs_touch called from the wrong state, %d != READY",
151       g->state);
152     return -1;
153   }
154
155   args.path = (char *) path;
156   serial = dispatch (g, GUESTFS_PROC_TOUCH,
157                      (xdrproc_t) xdr_guestfs_touch_args, (char *) &args);
158   if (serial == -1)
159     return -1;
160
161   rv.err_code = 42;
162   g->reply_cb_internal = touch_cb;
163   g->reply_cb_internal_data = &rv;
164   main_loop.main_loop_run (g);
165   g->reply_cb_internal = NULL;
166   g->reply_cb_internal_data = NULL;
167   if (rv.err_code == 42) { /* callback wasn't called */
168     error (g, "guestfs_touch failed, see earlier error messages");
169     return -1;
170   }
171   else if (rv.err_code == -1) { /* error from remote end */
172     error (g, "%s", rv.err_str);
173     return -1;
174   }
175
176   /* XXX check serial number agrees */
177
178   return 0;
179 }
180