Require PCRE library.
[libguestfs.git] / src / inspect.c
1 /* libguestfs
2  * Copyright (C) 2010-2011 Red Hat Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 #include <config.h>
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <stdint.h>
24 #include <inttypes.h>
25 #include <unistd.h>
26 #include <fcntl.h>
27 #include <string.h>
28 #include <sys/stat.h>
29 #include <errno.h>
30 #include <endian.h>
31
32 #include <pcre.h>
33
34 #ifdef HAVE_HIVEX
35 #include <hivex.h>
36 #endif
37
38 #include "c-ctype.h"
39 #include "ignore-value.h"
40 #include "xstrtol.h"
41
42 #include "guestfs.h"
43 #include "guestfs-internal.h"
44 #include "guestfs-internal-actions.h"
45 #include "guestfs_protocol.h"
46
47 #if defined(HAVE_HIVEX)
48
49 /* The main inspection code. */
50 char **
51 guestfs__inspect_os (guestfs_h *g)
52 {
53   /* Remove any information previously stored in the handle. */
54   guestfs___free_inspect_info (g);
55
56   if (guestfs_umount_all (g) == -1)
57     return NULL;
58
59   /* Iterate over all possible devices.  Try to mount each
60    * (read-only).  Examine ones which contain filesystems and add that
61    * information to the handle.
62    */
63   /* Look to see if any devices directly contain filesystems (RHBZ#590167). */
64   char **devices;
65   devices = guestfs_list_devices (g);
66   if (devices == NULL)
67     return NULL;
68
69   size_t i;
70   for (i = 0; devices[i] != NULL; ++i) {
71     if (guestfs___check_for_filesystem_on (g, devices[i], 1, 0) == -1) {
72       guestfs___free_string_list (devices);
73       guestfs___free_inspect_info (g);
74       return NULL;
75     }
76   }
77   guestfs___free_string_list (devices);
78
79   /* Look at all partitions. */
80   char **partitions;
81   partitions = guestfs_list_partitions (g);
82   if (partitions == NULL) {
83     guestfs___free_inspect_info (g);
84     return NULL;
85   }
86
87   for (i = 0; partitions[i] != NULL; ++i) {
88     if (guestfs___check_for_filesystem_on (g, partitions[i], 0, i+1) == -1) {
89       guestfs___free_string_list (partitions);
90       guestfs___free_inspect_info (g);
91       return NULL;
92     }
93   }
94   guestfs___free_string_list (partitions);
95
96   /* Look at all LVs. */
97   if (guestfs___feature_available (g, "lvm2")) {
98     char **lvs;
99     lvs = guestfs_lvs (g);
100     if (lvs == NULL) {
101       guestfs___free_inspect_info (g);
102       return NULL;
103     }
104
105     for (i = 0; lvs[i] != NULL; ++i) {
106       if (guestfs___check_for_filesystem_on (g, lvs[i], 0, 0) == -1) {
107         guestfs___free_string_list (lvs);
108         guestfs___free_inspect_info (g);
109         return NULL;
110       }
111     }
112     guestfs___free_string_list (lvs);
113   }
114
115   /* At this point we have, in the handle, a list of all filesystems
116    * found and data about each one.  Now we assemble the list of
117    * filesystems which are root devices and return that to the user.
118    * Fall through to guestfs__inspect_get_roots to do that.
119    */
120   char **ret = guestfs__inspect_get_roots (g);
121   if (ret == NULL)
122     guestfs___free_inspect_info (g);
123   return ret;
124 }
125
126 char **
127 guestfs__inspect_get_roots (guestfs_h *g)
128 {
129   /* NB. Doesn't matter if g->nr_fses == 0.  We just return an empty
130    * list in this case.
131    */
132
133   size_t i;
134   size_t count = 0;
135   for (i = 0; i < g->nr_fses; ++i)
136     if (g->fses[i].is_root)
137       count++;
138
139   char **ret = calloc (count+1, sizeof (char *));
140   if (ret == NULL) {
141     perrorf (g, "calloc");
142     return NULL;
143   }
144
145   count = 0;
146   for (i = 0; i < g->nr_fses; ++i) {
147     if (g->fses[i].is_root) {
148       ret[count] = safe_strdup (g, g->fses[i].device);
149       count++;
150     }
151   }
152   ret[count] = NULL;
153
154   return ret;
155 }
156
157 char *
158 guestfs__inspect_get_type (guestfs_h *g, const char *root)
159 {
160   struct inspect_fs *fs = guestfs___search_for_root (g, root);
161   if (!fs)
162     return NULL;
163
164   char *ret;
165   switch (fs->type) {
166   case OS_TYPE_LINUX: ret = safe_strdup (g, "linux"); break;
167   case OS_TYPE_WINDOWS: ret = safe_strdup (g, "windows"); break;
168   case OS_TYPE_FREEBSD: ret = safe_strdup (g, "freebsd"); break;
169   case OS_TYPE_UNKNOWN: default: ret = safe_strdup (g, "unknown"); break;
170   }
171
172   return ret;
173 }
174
175 char *
176 guestfs__inspect_get_arch (guestfs_h *g, const char *root)
177 {
178   struct inspect_fs *fs = guestfs___search_for_root (g, root);
179   if (!fs)
180     return NULL;
181
182   return safe_strdup (g, fs->arch ? : "unknown");
183 }
184
185 char *
186 guestfs__inspect_get_distro (guestfs_h *g, const char *root)
187 {
188   struct inspect_fs *fs = guestfs___search_for_root (g, root);
189   if (!fs)
190     return NULL;
191
192   char *ret;
193   switch (fs->distro) {
194   case OS_DISTRO_ARCHLINUX: ret = safe_strdup (g, "archlinux"); break;
195   case OS_DISTRO_CENTOS: ret = safe_strdup (g, "centos"); break;
196   case OS_DISTRO_DEBIAN: ret = safe_strdup (g, "debian"); break;
197   case OS_DISTRO_FEDORA: ret = safe_strdup (g, "fedora"); break;
198   case OS_DISTRO_GENTOO: ret = safe_strdup (g, "gentoo"); break;
199   case OS_DISTRO_LINUX_MINT: ret = safe_strdup (g, "linuxmint"); break;
200   case OS_DISTRO_MANDRIVA: ret = safe_strdup (g, "mandriva"); break;
201   case OS_DISTRO_MEEGO: ret = safe_strdup (g, "meego"); break;
202   case OS_DISTRO_PARDUS: ret = safe_strdup (g, "pardus"); break;
203   case OS_DISTRO_REDHAT_BASED: ret = safe_strdup (g, "redhat-based"); break;
204   case OS_DISTRO_RHEL: ret = safe_strdup (g, "rhel"); break;
205   case OS_DISTRO_SCIENTIFIC_LINUX: ret = safe_strdup (g, "scientificlinux"); break;
206   case OS_DISTRO_SLACKWARE: ret = safe_strdup (g, "slackware"); break;
207   case OS_DISTRO_WINDOWS: ret = safe_strdup (g, "windows"); break;
208   case OS_DISTRO_UBUNTU: ret = safe_strdup (g, "ubuntu"); break;
209   case OS_DISTRO_UNKNOWN: default: ret = safe_strdup (g, "unknown"); break;
210   }
211
212   return ret;
213 }
214
215 int
216 guestfs__inspect_get_major_version (guestfs_h *g, const char *root)
217 {
218   struct inspect_fs *fs = guestfs___search_for_root (g, root);
219   if (!fs)
220     return -1;
221
222   return fs->major_version;
223 }
224
225 int
226 guestfs__inspect_get_minor_version (guestfs_h *g, const char *root)
227 {
228   struct inspect_fs *fs = guestfs___search_for_root (g, root);
229   if (!fs)
230     return -1;
231
232   return fs->minor_version;
233 }
234
235 char *
236 guestfs__inspect_get_product_name (guestfs_h *g, const char *root)
237 {
238   struct inspect_fs *fs = guestfs___search_for_root (g, root);
239   if (!fs)
240     return NULL;
241
242   return safe_strdup (g, fs->product_name ? : "unknown");
243 }
244
245 char *
246 guestfs__inspect_get_product_variant (guestfs_h *g, const char *root)
247 {
248   struct inspect_fs *fs = guestfs___search_for_root (g, root);
249   if (!fs)
250     return NULL;
251
252   return safe_strdup (g, fs->product_variant ? : "unknown");
253 }
254
255 char *
256 guestfs__inspect_get_windows_systemroot (guestfs_h *g, const char *root)
257 {
258   struct inspect_fs *fs = guestfs___search_for_root (g, root);
259   if (!fs)
260     return NULL;
261
262   if (!fs->windows_systemroot) {
263     error (g, _("not a Windows guest, or systemroot could not be determined"));
264     return NULL;
265   }
266
267   return safe_strdup (g, fs->windows_systemroot);
268 }
269
270 char *
271 guestfs__inspect_get_windows_current_control_set (guestfs_h *g,
272                                                   const char *root)
273 {
274   struct inspect_fs *fs = guestfs___search_for_root (g, root);
275   if (!fs)
276     return NULL;
277
278   if (!fs->windows_current_control_set) {
279     error (g, _("not a Windows guest, or CurrentControlSet could not be determined"));
280     return NULL;
281   }
282
283   return safe_strdup (g, fs->windows_current_control_set);
284 }
285
286 char *
287 guestfs__inspect_get_format (guestfs_h *g, const char *root)
288 {
289   struct inspect_fs *fs = guestfs___search_for_root (g, root);
290   if (!fs)
291     return NULL;
292
293   char *ret;
294   switch (fs->format) {
295   case OS_FORMAT_INSTALLED: ret = safe_strdup (g, "installed"); break;
296   case OS_FORMAT_INSTALLER: ret = safe_strdup (g, "installer"); break;
297   case OS_FORMAT_UNKNOWN: default: ret = safe_strdup (g, "unknown"); break;
298   }
299
300   return ret;
301 }
302
303 int
304 guestfs__inspect_is_live (guestfs_h *g, const char *root)
305 {
306   struct inspect_fs *fs = guestfs___search_for_root (g, root);
307   if (!fs)
308     return -1;
309
310   return fs->is_live_disk;
311 }
312
313 int
314 guestfs__inspect_is_netinst (guestfs_h *g, const char *root)
315 {
316   struct inspect_fs *fs = guestfs___search_for_root (g, root);
317   if (!fs)
318     return -1;
319
320   return fs->is_netinst_disk;
321 }
322
323 int
324 guestfs__inspect_is_multipart (guestfs_h *g, const char *root)
325 {
326   struct inspect_fs *fs = guestfs___search_for_root (g, root);
327   if (!fs)
328     return -1;
329
330   return fs->is_multipart_disk;
331 }
332
333 char **
334 guestfs__inspect_get_mountpoints (guestfs_h *g, const char *root)
335 {
336   struct inspect_fs *fs = guestfs___search_for_root (g, root);
337   if (!fs)
338     return NULL;
339
340   char **ret;
341
342   /* If no fstab information (Windows) return just the root. */
343   if (fs->nr_fstab == 0) {
344     ret = calloc (3, sizeof (char *));
345     ret[0] = safe_strdup (g, "/");
346     ret[1] = safe_strdup (g, root);
347     ret[2] = NULL;
348     return ret;
349   }
350
351 #define CRITERION fs->fstab[i].mountpoint[0] == '/'
352   size_t i, count = 0;
353   for (i = 0; i < fs->nr_fstab; ++i)
354     if (CRITERION)
355       count++;
356
357   /* Hashtables have 2N+1 entries. */
358   ret = calloc (2*count+1, sizeof (char *));
359   if (ret == NULL) {
360     perrorf (g, "calloc");
361     return NULL;
362   }
363
364   count = 0;
365   for (i = 0; i < fs->nr_fstab; ++i)
366     if (CRITERION) {
367       ret[2*count] = safe_strdup (g, fs->fstab[i].mountpoint);
368       ret[2*count+1] = safe_strdup (g, fs->fstab[i].device);
369       count++;
370     }
371 #undef CRITERION
372
373   return ret;
374 }
375
376 char **
377 guestfs__inspect_get_filesystems (guestfs_h *g, const char *root)
378 {
379   struct inspect_fs *fs = guestfs___search_for_root (g, root);
380   if (!fs)
381     return NULL;
382
383   char **ret;
384
385   /* If no fstab information (Windows) return just the root. */
386   if (fs->nr_fstab == 0) {
387     ret = calloc (2, sizeof (char *));
388     ret[0] = safe_strdup (g, root);
389     ret[1] = NULL;
390     return ret;
391   }
392
393   ret = calloc (fs->nr_fstab + 1, sizeof (char *));
394   if (ret == NULL) {
395     perrorf (g, "calloc");
396     return NULL;
397   }
398
399   size_t i;
400   for (i = 0; i < fs->nr_fstab; ++i)
401     ret[i] = safe_strdup (g, fs->fstab[i].device);
402
403   return ret;
404 }
405
406 char **
407 guestfs__inspect_get_drive_mappings (guestfs_h *g, const char *root)
408 {
409   char **ret;
410   size_t i, count;
411   struct inspect_fs *fs;
412
413   fs = guestfs___search_for_root (g, root);
414   if (!fs)
415     return NULL;
416
417   /* If no drive mappings, return an empty hashtable. */
418   if (!fs->drive_mappings)
419     count = 0;
420   else {
421     for (count = 0; fs->drive_mappings[count] != NULL; count++)
422       ;
423   }
424
425   ret = calloc (count+1, sizeof (char *));
426   if (ret == NULL) {
427     perrorf (g, "calloc");
428     return NULL;
429   }
430
431   /* We need to make a deep copy of the hashtable since the caller
432    * will free it.
433    */
434   for (i = 0; i < count; ++i)
435     ret[i] = safe_strdup (g, fs->drive_mappings[i]);
436
437   ret[count] = NULL;
438
439   return ret;
440 }
441
442 char *
443 guestfs__inspect_get_package_format (guestfs_h *g, const char *root)
444 {
445   struct inspect_fs *fs = guestfs___search_for_root (g, root);
446   if (!fs)
447     return NULL;
448
449   char *ret;
450   switch (fs->package_format) {
451   case OS_PACKAGE_FORMAT_RPM: ret = safe_strdup (g, "rpm"); break;
452   case OS_PACKAGE_FORMAT_DEB: ret = safe_strdup (g, "deb"); break;
453   case OS_PACKAGE_FORMAT_PACMAN: ret = safe_strdup (g, "pacman"); break;
454   case OS_PACKAGE_FORMAT_EBUILD: ret = safe_strdup (g, "ebuild"); break;
455   case OS_PACKAGE_FORMAT_PISI: ret = safe_strdup (g, "pisi"); break;
456   case OS_PACKAGE_FORMAT_UNKNOWN:
457   default:
458     ret = safe_strdup (g, "unknown");
459     break;
460   }
461
462   return ret;
463 }
464
465 char *
466 guestfs__inspect_get_package_management (guestfs_h *g, const char *root)
467 {
468   struct inspect_fs *fs = guestfs___search_for_root (g, root);
469   if (!fs)
470     return NULL;
471
472   char *ret;
473   switch (fs->package_management) {
474   case OS_PACKAGE_MANAGEMENT_YUM: ret = safe_strdup (g, "yum"); break;
475   case OS_PACKAGE_MANAGEMENT_UP2DATE: ret = safe_strdup (g, "up2date"); break;
476   case OS_PACKAGE_MANAGEMENT_APT: ret = safe_strdup (g, "apt"); break;
477   case OS_PACKAGE_MANAGEMENT_PACMAN: ret = safe_strdup (g, "pacman"); break;
478   case OS_PACKAGE_MANAGEMENT_PORTAGE: ret = safe_strdup (g, "portage"); break;
479   case OS_PACKAGE_MANAGEMENT_PISI: ret = safe_strdup (g, "pisi"); break;
480   case OS_PACKAGE_MANAGEMENT_URPMI: ret = safe_strdup (g, "urpmi"); break;
481   case OS_PACKAGE_MANAGEMENT_UNKNOWN:
482   default:
483     ret = safe_strdup (g, "unknown");
484     break;
485   }
486
487   return ret;
488 }
489
490 char *
491 guestfs__inspect_get_hostname (guestfs_h *g, const char *root)
492 {
493   struct inspect_fs *fs = guestfs___search_for_root (g, root);
494   if (!fs)
495     return NULL;
496
497   return safe_strdup (g, fs->hostname ? : "unknown");
498 }
499
500 /* Download a guest file to a local temporary file.  The file is
501  * cached in the temporary directory, and is not downloaded again.
502  *
503  * The name of the temporary (downloaded) file is returned.  The
504  * caller must free the pointer, but does *not* need to delete the
505  * temporary file.  It will be deleted when the handle is closed.
506  *
507  * Refuse to download the guest file if it is larger than max_size.
508  * On this and other errors, NULL is returned.
509  *
510  * There is actually one cache per 'struct inspect_fs *' in order
511  * to handle the case of multiple roots.
512  */
513 char *
514 guestfs___download_to_tmp (guestfs_h *g, struct inspect_fs *fs,
515                            const char *filename,
516                            const char *basename, int64_t max_size)
517 {
518   char *r;
519   int fd;
520   char devfd[32];
521   int64_t size;
522
523   /* Make the basename unique by prefixing it with the fs number. */
524   if (asprintf (&r, "%s/%ld-%s", g->tmpdir, fs - g->fses, basename) == -1) {
525     perrorf (g, "asprintf");
526     return NULL;
527   }
528
529   /* If the file has already been downloaded, return. */
530   if (access (r, R_OK) == 0)
531     return r;
532
533   /* Check size of remote file. */
534   size = guestfs_filesize (g, filename);
535   if (size == -1)
536     /* guestfs_filesize failed and has already set error in handle */
537     goto error;
538   if (size > max_size) {
539     error (g, _("size of %s is unreasonably large (%" PRIi64 " bytes)"),
540            filename, size);
541     goto error;
542   }
543
544   fd = open (r, O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY, 0600);
545   if (fd == -1) {
546     perrorf (g, "open: %s", r);
547     goto error;
548   }
549
550   snprintf (devfd, sizeof devfd, "/dev/fd/%d", fd);
551
552   if (guestfs_download (g, filename, devfd) == -1) {
553     unlink (r);
554     close (fd);
555     goto error;
556   }
557
558   if (close (fd) == -1) {
559     perrorf (g, "close: %s", r);
560     unlink (r);
561     goto error;
562   }
563
564   return r;
565
566  error:
567   free (r);
568   return NULL;
569 }
570
571 struct inspect_fs *
572 guestfs___search_for_root (guestfs_h *g, const char *root)
573 {
574   if (g->nr_fses == 0) {
575     error (g, _("no inspection data: call guestfs_inspect_os first"));
576     return NULL;
577   }
578
579   size_t i;
580   struct inspect_fs *fs;
581   for (i = 0; i < g->nr_fses; ++i) {
582     fs = &g->fses[i];
583     if (fs->is_root && STREQ (root, fs->device))
584       return fs;
585   }
586
587   error (g, _("%s: root device not found: only call this function with a root device previously returned by guestfs_inspect_os"),
588          root);
589   return NULL;
590 }
591
592 #else /* no hivex at compile time */
593
594 /* XXX These functions should be in an optgroup. */
595
596 #define NOT_IMPL(r)                                                     \
597   error (g, _("inspection API not available since this version of libguestfs was compiled without the hivex library")); \
598   return r
599
600 char **
601 guestfs__inspect_os (guestfs_h *g)
602 {
603   NOT_IMPL(NULL);
604 }
605
606 char **
607 guestfs__inspect_get_roots (guestfs_h *g)
608 {
609   NOT_IMPL(NULL);
610 }
611
612 char *
613 guestfs__inspect_get_type (guestfs_h *g, const char *root)
614 {
615   NOT_IMPL(NULL);
616 }
617
618 char *
619 guestfs__inspect_get_arch (guestfs_h *g, const char *root)
620 {
621   NOT_IMPL(NULL);
622 }
623
624 char *
625 guestfs__inspect_get_distro (guestfs_h *g, const char *root)
626 {
627   NOT_IMPL(NULL);
628 }
629
630 int
631 guestfs__inspect_get_major_version (guestfs_h *g, const char *root)
632 {
633   NOT_IMPL(-1);
634 }
635
636 int
637 guestfs__inspect_get_minor_version (guestfs_h *g, const char *root)
638 {
639   NOT_IMPL(-1);
640 }
641
642 char *
643 guestfs__inspect_get_product_name (guestfs_h *g, const char *root)
644 {
645   NOT_IMPL(NULL);
646 }
647
648 char *
649 guestfs__inspect_get_product_variant (guestfs_h *g, const char *root)
650 {
651   NOT_IMPL(NULL);
652 }
653
654 char *
655 guestfs__inspect_get_windows_systemroot (guestfs_h *g, const char *root)
656 {
657   NOT_IMPL(NULL);
658 }
659
660 char *
661 guestfs__inspect_get_windows_current_control_set (guestfs_h *g,
662                                                   const char *root)
663 {
664   NOT_IMPL(NULL);
665 }
666
667 char **
668 guestfs__inspect_get_mountpoints (guestfs_h *g, const char *root)
669 {
670   NOT_IMPL(NULL);
671 }
672
673 char **
674 guestfs__inspect_get_filesystems (guestfs_h *g, const char *root)
675 {
676   NOT_IMPL(NULL);
677 }
678
679 char **
680 guestfs__inspect_get_drive_mappings (guestfs_h *g, const char *root)
681 {
682   NOT_IMPL(NULL);
683 }
684
685 char *
686 guestfs__inspect_get_package_format (guestfs_h *g, const char *root)
687 {
688   NOT_IMPL(NULL);
689 }
690
691 char *
692 guestfs__inspect_get_package_management (guestfs_h *g, const char *root)
693 {
694   NOT_IMPL(NULL);
695 }
696
697 char *
698 guestfs__inspect_get_hostname (guestfs_h *g, const char *root)
699 {
700   NOT_IMPL(NULL);
701 }
702
703 char *
704 guestfs__inspect_get_format (guestfs_h *g, const char *root)
705 {
706   NOT_IMPL(NULL);
707 }
708
709 int
710 guestfs__inspect_is_live (guestfs_h *g, const char *root)
711 {
712   NOT_IMPL(-1);
713 }
714
715 int
716 guestfs__inspect_is_netinst (guestfs_h *g, const char *root)
717 {
718   NOT_IMPL(-1);
719 }
720
721 int
722 guestfs__inspect_is_multipart (guestfs_h *g, const char *root)
723 {
724   NOT_IMPL(-1);
725 }
726
727 #endif /* no hivex at compile time */
728
729 void
730 guestfs___free_inspect_info (guestfs_h *g)
731 {
732   size_t i;
733   for (i = 0; i < g->nr_fses; ++i) {
734     free (g->fses[i].device);
735     free (g->fses[i].product_name);
736     free (g->fses[i].product_variant);
737     free (g->fses[i].arch);
738     free (g->fses[i].hostname);
739     free (g->fses[i].windows_systemroot);
740     free (g->fses[i].windows_current_control_set);
741     size_t j;
742     for (j = 0; j < g->fses[i].nr_fstab; ++j) {
743       free (g->fses[i].fstab[j].device);
744       free (g->fses[i].fstab[j].mountpoint);
745     }
746     free (g->fses[i].fstab);
747     if (g->fses[i].drive_mappings)
748       guestfs___free_string_list (g->fses[i].drive_mappings);
749   }
750   free (g->fses);
751   g->nr_fses = 0;
752   g->fses = NULL;
753 }
754
755 /* In the Perl code this is a public function. */
756 int
757 guestfs___feature_available (guestfs_h *g, const char *feature)
758 {
759   /* If there's an error we should ignore it, so to do that we have to
760    * temporarily replace the error handler with a null one.
761    */
762   guestfs_error_handler_cb old_error_cb = g->error_cb;
763   g->error_cb = NULL;
764
765   const char *groups[] = { feature, NULL };
766   int r = guestfs_available (g, (char * const *) groups);
767
768   g->error_cb = old_error_cb;
769
770   return r == 0 ? 1 : 0;
771 }