1 /* guestmount - mount guests using libguestfs and FUSE
2 * Copyright (C) 2009-2011 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * Derived from the example program 'fusexmp.c':
19 * Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
21 * This program can be distributed under the terms of the GNU GPL.
22 * See the file COPYING.
25 #define FUSE_USE_VERSION 26
43 #include <sys/types.h>
51 #include "guestmount.h"
55 /* See <attr/xattr.h> */
57 #define ENOATTR ENODATA
64 int keys_from_stdin = 0;
66 const char *libvirt_uri;
67 int dir_cache_timeout = 60;
68 static int trace_calls = 0;
70 #define TRACE_CALL(fs,...) \
72 fprintf (stderr, "%s: %s (" fs ")\n", \
73 program_name, __func__, __VA_ARGS__); \
79 return -guestfs_last_errno (g);
82 static struct guestfs_xattr_list *
83 copy_xattr_list (const struct guestfs_xattr *first, size_t num)
85 struct guestfs_xattr_list *xattrs;
87 xattrs = malloc (sizeof *xattrs);
94 xattrs->val = malloc (num * sizeof (struct guestfs_xattr));
95 if (xattrs->val == NULL) {
102 for (i = 0; i < num; ++i) {
103 xattrs->val[i].attrname = strdup (first[i].attrname);
104 xattrs->val[i].attrval_len = first[i].attrval_len;
105 xattrs->val[i].attrval = malloc (first[i].attrval_len);
106 memcpy (xattrs->val[i].attrval, first[i].attrval, first[i].attrval_len);
113 fg_readdir (const char *path, void *buf, fuse_fill_dir_t filler,
114 off_t offset, struct fuse_file_info *fi)
116 TRACE_CALL ("%s, %p, %ld", path, buf, (long) offset);
121 dir_cache_remove_all_expired (now);
123 struct guestfs_dirent_list *ents;
125 ents = guestfs_readdir (g, path);
130 for (i = 0; i < ents->len; ++i) {
132 memset (&stat, 0, sizeof stat);
134 stat.st_ino = ents->val[i].ino;
135 switch (ents->val[i].ftyp) {
136 case 'b': stat.st_mode = S_IFBLK; break;
137 case 'c': stat.st_mode = S_IFCHR; break;
138 case 'd': stat.st_mode = S_IFDIR; break;
139 case 'f': stat.st_mode = S_IFIFO; break;
140 case 'l': stat.st_mode = S_IFLNK; break;
141 case 'r': stat.st_mode = S_IFREG; break;
142 case 's': stat.st_mode = S_IFSOCK; break;
145 default: stat.st_mode = 0;
148 /* Copied from the example, which also ignores 'offset'. I'm
149 * not quite sure how this is ever supposed to work on large
152 if (filler (buf, ents->val[i].name, &stat, 0))
156 /* Now prepopulate the directory caches. This step is just an
157 * optimization, don't worry if it fails.
159 char **names = malloc ((ents->len + 1) * sizeof (char *));
161 for (i = 0; i < ents->len; ++i)
162 names[i] = ents->val[i].name;
165 struct guestfs_stat_list *ss = guestfs_lstatlist (g, path, names);
167 for (i = 0; i < ss->len; ++i) {
168 if (ss->val[i].ino >= 0) {
171 statbuf.st_dev = ss->val[i].dev;
172 statbuf.st_ino = ss->val[i].ino;
173 statbuf.st_mode = ss->val[i].mode;
174 statbuf.st_nlink = ss->val[i].nlink;
175 statbuf.st_uid = ss->val[i].uid;
176 statbuf.st_gid = ss->val[i].gid;
177 statbuf.st_rdev = ss->val[i].rdev;
178 statbuf.st_size = ss->val[i].size;
179 statbuf.st_blksize = ss->val[i].blksize;
180 statbuf.st_blocks = ss->val[i].blocks;
181 statbuf.st_atime = ss->val[i].atime;
182 statbuf.st_mtime = ss->val[i].mtime;
183 statbuf.st_ctime = ss->val[i].ctime;
185 lsc_insert (path, names[i], now, &statbuf);
188 guestfs_free_stat_list (ss);
191 struct guestfs_xattr_list *xattrs = guestfs_lxattrlist (g, path, names);
194 struct guestfs_xattr *first;
195 struct guestfs_xattr_list *copy;
196 for (i = 0, ni = 0; i < xattrs->len; ++i, ++ni) {
197 assert (strlen (xattrs->val[i].attrname) == 0);
198 if (xattrs->val[i].attrval_len > 0) {
200 first = &xattrs->val[i];
202 for (; i < xattrs->len && strlen (xattrs->val[i].attrname) > 0; ++i)
205 copy = copy_xattr_list (first, num);
207 xac_insert (path, names[ni], now, copy);
212 guestfs_free_xattr_list (xattrs);
215 char **links = guestfs_readlinklist (g, path, names);
217 for (i = 0; names[i] != NULL; ++i) {
219 /* Note that rlc_insert owns the string links[i] after this, */
220 rlc_insert (path, names[i], now, links[i]);
222 /* which is why we have to free links[i] here. */
225 free (links); /* free the array, not the strings */
231 guestfs_free_dirent_list (ents);
237 fg_getattr (const char *path, struct stat *statbuf)
239 TRACE_CALL ("%s, %p", path, statbuf);
241 const struct stat *buf;
243 buf = lsc_lookup (path);
245 memcpy (statbuf, buf, sizeof *statbuf);
249 struct guestfs_stat *r;
251 r = guestfs_lstat (g, path);
255 statbuf->st_dev = r->dev;
256 statbuf->st_ino = r->ino;
257 statbuf->st_mode = r->mode;
258 statbuf->st_nlink = r->nlink;
259 statbuf->st_uid = r->uid;
260 statbuf->st_gid = r->gid;
261 statbuf->st_rdev = r->rdev;
262 statbuf->st_size = r->size;
263 statbuf->st_blksize = r->blksize;
264 statbuf->st_blocks = r->blocks;
265 statbuf->st_atime = r->atime;
266 statbuf->st_mtime = r->mtime;
267 statbuf->st_ctime = r->ctime;
269 guestfs_free_stat (r);
274 /* Nautilus loves to use access(2) to test everything about a file,
275 * such as whether it's executable. Therefore treat this a lot like
279 fg_access (const char *path, int mask)
281 TRACE_CALL ("%s, %d", path, mask);
286 if (read_only && (mask & W_OK))
289 r = fg_getattr (path, &statbuf);
290 if (r < 0 || mask == F_OK)
293 struct fuse_context *fuse = fuse_get_context ();
298 ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IRUSR
299 : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IRGRP
300 : statbuf.st_mode & S_IROTH);
303 ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IWUSR
304 : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IWGRP
305 : statbuf.st_mode & S_IWOTH);
308 ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IXUSR
309 : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IXGRP
310 : statbuf.st_mode & S_IXOTH);
312 return ok ? 0 : -EACCES;
316 fg_readlink (const char *path, char *buf, size_t size)
318 TRACE_CALL ("%s, %p, %zu", path, buf, size);
323 r = rlc_lookup (path);
325 r = guestfs_readlink (g, path);
331 /* Note this is different from the real readlink(2) syscall. FUSE wants
332 * the string to be always nul-terminated, even if truncated.
334 size_t len = strlen (r);
338 memcpy (buf, r, len);
342 char *tmp = (char *) r;
350 fg_mknod (const char *path, mode_t mode, dev_t rdev)
352 TRACE_CALL ("%s, 0%o, 0x%lx", path, mode, (long) rdev);
356 if (read_only) return -EROFS;
358 dir_cache_invalidate (path);
360 r = guestfs_mknod (g, mode, major (rdev), minor (rdev), path);
368 fg_mkdir (const char *path, mode_t mode)
370 TRACE_CALL ("%s, 0%o", path, mode);
374 if (read_only) return -EROFS;
376 dir_cache_invalidate (path);
378 r = guestfs_mkdir_mode (g, path, mode);
386 fg_unlink (const char *path)
388 TRACE_CALL ("%s", path);
392 if (read_only) return -EROFS;
394 dir_cache_invalidate (path);
396 r = guestfs_rm (g, path);
404 fg_rmdir (const char *path)
406 TRACE_CALL ("%s", path);
410 if (read_only) return -EROFS;
412 dir_cache_invalidate (path);
414 r = guestfs_rmdir (g, path);
422 fg_symlink (const char *from, const char *to)
424 TRACE_CALL ("%s, %s", from, to);
428 if (read_only) return -EROFS;
430 dir_cache_invalidate (to);
432 r = guestfs_ln_s (g, from, to);
440 fg_rename (const char *from, const char *to)
442 TRACE_CALL ("%s, %s", from, to);
446 if (read_only) return -EROFS;
448 dir_cache_invalidate (from);
449 dir_cache_invalidate (to);
451 /* XXX It's not clear how close the 'mv' command is to the
452 * rename syscall. We might need to add the rename syscall
453 * to the guestfs(3) API.
455 r = guestfs_mv (g, from, to);
463 fg_link (const char *from, const char *to)
465 TRACE_CALL ("%s, %s", from, to);
469 if (read_only) return -EROFS;
471 dir_cache_invalidate (from);
472 dir_cache_invalidate (to);
474 r = guestfs_ln (g, from, to);
482 fg_chmod (const char *path, mode_t mode)
484 TRACE_CALL ("%s, 0%o", path, mode);
488 if (read_only) return -EROFS;
490 dir_cache_invalidate (path);
492 r = guestfs_chmod (g, mode, path);
500 fg_chown (const char *path, uid_t uid, gid_t gid)
502 TRACE_CALL ("%s, %ld, %ld", path, (long) uid, (long) gid);
506 if (read_only) return -EROFS;
508 dir_cache_invalidate (path);
510 r = guestfs_lchown (g, uid, gid, path);
518 fg_truncate (const char *path, off_t size)
520 TRACE_CALL ("%s, %ld", path, (long) size);
524 if (read_only) return -EROFS;
526 dir_cache_invalidate (path);
528 r = guestfs_truncate_size (g, path, size);
536 fg_utimens (const char *path, const struct timespec ts[2])
538 TRACE_CALL ("%s, [{ %ld, %ld }, { %ld, %ld }]",
539 path, ts[0].tv_sec, ts[0].tv_nsec, ts[1].tv_sec, ts[1].tv_nsec);
543 if (read_only) return -EROFS;
545 dir_cache_invalidate (path);
547 time_t atsecs = ts[0].tv_sec;
548 long atnsecs = ts[0].tv_nsec;
549 time_t mtsecs = ts[1].tv_sec;
550 long mtnsecs = ts[1].tv_nsec;
553 if (atnsecs == UTIME_NOW)
557 if (atnsecs == UTIME_OMIT)
561 if (mtnsecs == UTIME_NOW)
565 if (mtnsecs == UTIME_OMIT)
569 r = guestfs_utimens (g, path, atsecs, atnsecs, mtsecs, mtnsecs);
576 /* All this function needs to do is to check that the requested open
577 * flags are valid. See the notes in <fuse/fuse.h>.
580 fg_open (const char *path, struct fuse_file_info *fi)
582 TRACE_CALL ("%s, 0%o", path, fi->flags);
584 int flags = fi->flags & 3;
586 if (read_only && flags != O_RDONLY)
593 fg_read (const char *path, char *buf, size_t size, off_t offset,
594 struct fuse_file_info *fi)
596 TRACE_CALL ("%s, %p, %zu, %ld", path, buf, size, offset);
602 fprintf (stderr, "fg_read: %s: size %zu offset %ju\n",
605 /* The guestfs protocol limits size to somewhere over 2MB. We just
606 * reduce the requested size here accordingly and push the problem
607 * up to every user. http://www.jwz.org/doc/worse-is-better.html
609 const size_t limit = 2 * 1024 * 1024;
613 r = guestfs_pread (g, path, size, offset, &rsize);
617 /* This should never happen, but at least it stops us overflowing
618 * the output buffer if it does happen.
623 memcpy (buf, r, rsize);
630 fg_write (const char *path, const char *buf, size_t size,
631 off_t offset, struct fuse_file_info *fi)
633 TRACE_CALL ("%s, %p, %zu, %ld", path, buf, size, offset);
635 if (read_only) return -EROFS;
637 dir_cache_invalidate (path);
640 const size_t limit = 2 * 1024 * 1024;
645 r = guestfs_pwrite (g, path, buf, size, offset);
653 fg_statfs (const char *path, struct statvfs *stbuf)
655 TRACE_CALL ("%s, %p", path, stbuf);
657 struct guestfs_statvfs *r;
659 r = guestfs_statvfs (g, path);
663 stbuf->f_bsize = r->bsize;
664 stbuf->f_frsize = r->frsize;
665 stbuf->f_blocks = r->blocks;
666 stbuf->f_bfree = r->bfree;
667 stbuf->f_bavail = r->bavail;
668 stbuf->f_files = r->files;
669 stbuf->f_ffree = r->ffree;
670 stbuf->f_favail = r->favail;
671 stbuf->f_fsid = r->fsid;
672 stbuf->f_flag = r->flag;
673 stbuf->f_namemax = r->namemax;
675 guestfs_free_statvfs (r);
681 fg_release (const char *path, struct fuse_file_info *fi)
683 TRACE_CALL ("%s", path);
685 /* Just a stub. This method is optional and can safely be left
691 /* Emulate this by calling sync. */
692 static int fg_fsync(const char *path, int isdatasync,
693 struct fuse_file_info *fi)
695 TRACE_CALL ("%s, %d", path, isdatasync);
699 r = guestfs_sync (g);
707 fg_setxattr (const char *path, const char *name, const char *value,
708 size_t size, int flags)
710 TRACE_CALL ("%s, %s, %p, %zu", path, name, value, size);
714 if (read_only) return -EROFS;
716 dir_cache_invalidate (path);
718 /* XXX Underlying guestfs(3) API doesn't understand the flags. */
719 r = guestfs_lsetxattr (g, name, value, size, path);
726 /* The guestfs(3) API for getting xattrs is much easier to use
727 * than the real syscall. Unfortunately we now have to emulate
728 * the real syscall using that API :-(
731 fg_getxattr (const char *path, const char *name, char *value,
734 TRACE_CALL ("%s, %s, %p, %zu", path, name, value, size);
736 const struct guestfs_xattr_list *xattrs;
739 xattrs = xac_lookup (path);
740 if (xattrs == NULL) {
741 xattrs = guestfs_lgetxattrs (g, path);
747 /* Find the matching attribute (index in 'i'). */
750 for (i = 0; i < xattrs->len; ++i) {
751 if (STREQ (xattrs->val[i].attrname, name))
755 if (i == xattrs->len) { /* not found */
760 /* The getxattr man page is unclear, but if value == NULL then we
761 * return the space required (the caller then makes a second syscall
762 * after allocating the required amount of space). If value != NULL
763 * then it's not clear what we should do, but it appears we should
764 * copy as much as possible and return -ERANGE if there's not enough
765 * space in the buffer.
767 size_t sz = xattrs->val[i].attrval_len;
779 memcpy (value, xattrs->val[i].attrval, sz);
783 guestfs_free_xattr_list ((struct guestfs_xattr_list *) xattrs);
788 /* Ditto as above. */
790 fg_listxattr (const char *path, char *list, size_t size)
792 TRACE_CALL ("%s, %p, %zu", path, list, size);
794 const struct guestfs_xattr_list *xattrs;
797 xattrs = xac_lookup (path);
798 if (xattrs == NULL) {
799 xattrs = guestfs_lgetxattrs (g, path);
805 /* Calculate how much space is required to hold the result. */
809 for (i = 0; i < xattrs->len; ++i) {
810 len = strlen (xattrs->val[i].attrname) + 1;
814 /* The listxattr man page is unclear, but if list == NULL then we
815 * return the space required (the caller then makes a second syscall
816 * after allocating the required amount of space). If list != NULL
817 * then it's not clear what we should do, but it appears we should
818 * copy as much as possible and return -ERANGE if there's not enough
819 * space in the buffer.
828 for (i = 0; i < xattrs->len; ++i) {
829 len = strlen (xattrs->val[i].attrname) + 1;
831 memcpy (list, xattrs->val[i].attrname, len);
843 guestfs_free_xattr_list ((struct guestfs_xattr_list *) xattrs);
849 fg_removexattr(const char *path, const char *name)
851 TRACE_CALL ("%s, %s", path, name);
855 if (read_only) return -EROFS;
857 dir_cache_invalidate (path);
859 r = guestfs_lremovexattr (g, name, path);
866 static struct fuse_operations fg_operations = {
867 .getattr = fg_getattr,
869 .readlink = fg_readlink,
870 .readdir = fg_readdir,
873 .symlink = fg_symlink,
880 .truncate = fg_truncate,
881 .utimens = fg_utimens,
886 .release = fg_release,
888 .setxattr = fg_setxattr,
889 .getxattr = fg_getxattr,
890 .listxattr = fg_listxattr,
891 .removexattr = fg_removexattr,
894 static void __attribute__((noreturn))
897 const char *tmp_argv[] = { program_name, "--help", NULL };
898 fuse_main (2, (char **) tmp_argv, &fg_operations, NULL);
902 static void __attribute__((noreturn))
905 if (status != EXIT_SUCCESS)
906 fprintf (stderr, _("Try `%s --help' for more information.\n"),
910 _("%s: FUSE module for libguestfs\n"
911 "%s lets you mount a virtual machine filesystem\n"
912 "Copyright (C) 2009-2010 Red Hat Inc.\n"
914 " %s [--options] [-- [--FUSE-options]] mountpoint\n"
916 " -a|--add image Add image\n"
917 " -c|--connect uri Specify libvirt URI for -d option\n"
918 " --dir-cache-timeout Set readdir cache timeout (default 5 sec)\n"
919 " -d|--domain guest Add disks from libvirt guest\n"
920 " --echo-keys Don't turn off echo for passphrases\n"
921 " --format[=raw|..] Force disk format for -a option\n"
922 " --fuse-help Display extra FUSE options\n"
923 " -i|--inspector Automatically mount filesystems\n"
924 " --help Display help message and exit\n"
925 " --keys-from-stdin Read passphrases from stdin\n"
926 " -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n"
927 " -n|--no-sync Don't autosync\n"
928 " -o|--option opt Pass extra option to FUSE\n"
929 " -r|--ro Mount read-only\n"
930 " --selinux Enable SELinux support\n"
931 " -v|--verbose Verbose messages\n"
932 " -V|--version Display version and exit\n"
933 " -x|--trace Trace guestfs API calls\n"
935 program_name, program_name, program_name);
941 main (int argc, char *argv[])
943 setlocale (LC_ALL, "");
944 bindtextdomain (PACKAGE, LOCALEBASEDIR);
945 textdomain (PACKAGE);
947 enum { HELP_OPTION = CHAR_MAX + 1 };
949 /* The command line arguments are broadly compatible with (a subset
950 * of) guestfish. Thus we have to deal mainly with -a, -m and --ro.
952 static const char *options = "a:c:d:im:no:rv?Vwx";
953 static const struct option long_options[] = {
954 { "add", 1, 0, 'a' },
955 { "connect", 1, 0, 'c' },
956 { "dir-cache-timeout", 1, 0, 0 },
957 { "domain", 1, 0, 'd' },
958 { "echo-keys", 0, 0, 0 },
959 { "format", 2, 0, 0 },
960 { "fuse-help", 0, 0, 0 },
961 { "help", 0, 0, HELP_OPTION },
962 { "inspector", 0, 0, 'i' },
963 { "keys-from-stdin", 0, 0, 0 },
964 { "mount", 1, 0, 'm' },
965 { "no-sync", 0, 0, 'n' },
966 { "option", 1, 0, 'o' },
969 { "selinux", 0, 0, 0 },
970 { "trace", 0, 0, 'x' },
971 { "verbose", 0, 0, 'v' },
972 { "version", 0, 0, 'V' },
976 struct drv *drvs = NULL;
978 struct mp *mps = NULL;
981 const char *format = NULL;
987 const char **fuse_argv = NULL;
989 #define ADD_FUSE_ARG(str) \
992 fuse_argv = realloc (fuse_argv, (1+fuse_argc) * sizeof (char *)); \
994 perror ("realloc"); \
995 exit (EXIT_FAILURE); \
997 fuse_argv[fuse_argc-1] = (str); \
998 fuse_argv[fuse_argc] = NULL; \
1001 /* LC_ALL=C is required so we can parse error messages. */
1002 setenv ("LC_ALL", "C", 1);
1004 /* Set global program name that is not polluted with libtool artifacts. */
1005 set_program_name (argv[0]);
1007 memset (&sa, 0, sizeof sa);
1008 sa.sa_handler = SIG_IGN;
1009 sa.sa_flags = SA_RESTART;
1010 sigaction (SIGPIPE, &sa, NULL);
1012 /* Various initialization. */
1015 g = guestfs_create ();
1017 fprintf (stderr, _("guestfs_create: failed to create handle\n"));
1018 exit (EXIT_FAILURE);
1021 guestfs_set_recovery_proc (g, 0);
1023 ADD_FUSE_ARG (program_name);
1024 /* MUST be single-threaded. You cannot have two threads accessing the
1025 * same libguestfs handle, and opening more than one handle is likely
1026 * to be very expensive.
1028 ADD_FUSE_ARG ("-s");
1030 /* If developing, add ./appliance to the path. Note that libtools
1031 * interferes with this because uninstalled guestfish is a shell
1032 * script that runs the real program with an absolute path. Detect
1035 * BUT if LIBGUESTFS_PATH environment variable is already set by
1036 * the user, then don't override it.
1038 if (getenv ("LIBGUESTFS_PATH") == NULL &&
1040 (argv[0][0] != '/' || strstr (argv[0], "/.libs/lt-") != NULL))
1041 guestfs_set_path (g, "appliance:" GUESTFS_DEFAULT_PATH);
1044 c = getopt_long (argc, argv, options, long_options, &option_index);
1048 case 0: /* options which are long only */
1049 if (STREQ (long_options[option_index].name, "dir-cache-timeout"))
1050 dir_cache_timeout = atoi (optarg);
1051 else if (STREQ (long_options[option_index].name, "fuse-help"))
1053 else if (STREQ (long_options[option_index].name, "selinux"))
1054 guestfs_set_selinux (g, 1);
1055 else if (STREQ (long_options[option_index].name, "format")) {
1056 if (!optarg || STREQ (optarg, ""))
1060 } else if (STREQ (long_options[option_index].name, "keys-from-stdin")) {
1061 keys_from_stdin = 1;
1062 } else if (STREQ (long_options[option_index].name, "echo-keys")) {
1065 fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
1066 program_name, long_options[option_index].name, option_index);
1067 exit (EXIT_FAILURE);
1096 ADD_FUSE_ARG ("-o");
1097 ADD_FUSE_ARG (optarg);
1118 ADD_FUSE_ARG ("-f");
1119 guestfs_set_recovery_proc (g, 1);
1124 usage (EXIT_SUCCESS);
1127 usage (EXIT_FAILURE);
1131 /* Check we have the right options. */
1132 if (!drvs || !(mps || inspector)) {
1134 _("%s: must have at least one -a/-d and at least one -m/-i option\n"),
1136 exit (EXIT_FAILURE);
1139 /* We'd better have a mountpoint. */
1140 if (optind+1 != argc) {
1142 _("%s: you must specify a mountpoint in the host filesystem\n"),
1144 exit (EXIT_FAILURE);
1147 /* Do the guest drives and mountpoints. */
1148 add_drives (drvs, 'a');
1149 if (guestfs_launch (g) == -1)
1150 exit (EXIT_FAILURE);
1158 /* FUSE example does this, not clear if it's necessary, but ... */
1159 if (guestfs_umask (g, 0) == -1)
1160 exit (EXIT_FAILURE);
1162 /* At the last minute, remove the libguestfs error handler. In code
1163 * above this point, the default error handler has been used which
1164 * sends all errors to stderr. Now before entering FUSE itself we
1165 * want to silence errors so we can convert them (see error()
1168 guestfs_set_error_handler (g, NULL, NULL);
1170 /* Finish off FUSE args. */
1171 ADD_FUSE_ARG (argv[optind]);
1174 It says about the line containing the for-statement:
1175 error: assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow]
1178 fprintf (stderr, "guestmount: invoking FUSE with args [");
1179 for (i = 0; i < fuse_argc; ++i) {
1180 if (i > 0) fprintf (stderr, ", ");
1181 fprintf (stderr, "%s", fuse_argv[i]);
1183 fprintf (stderr, "]\n");
1187 r = fuse_main (fuse_argc, (char **) fuse_argv, &fg_operations, NULL);
1193 exit (r == -1 ? 1 : 0);