git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update TODO file.
[libguestfs.git]
/
fuse
/
guestmount.c
diff --git
a/fuse/guestmount.c
b/fuse/guestmount.c
index
ec3cc77
..
9f0a39e
100644
(file)
--- a/
fuse/guestmount.c
+++ b/
fuse/guestmount.c
@@
-46,6
+46,7
@@
#include "progname.h"
#include "progname.h"
+#include "guestmount.h"
#include "dircache.h"
/* See <attr/xattr.h> */
#include "dircache.h"
/* See <attr/xattr.h> */
@@
-53,21
+54,6
@@
#define ENOATTR ENODATA
#endif
#define ENOATTR ENODATA
#endif
-#ifdef HAVE_GETTEXT
-#include "gettext.h"
-#define _(str) dgettext(PACKAGE, (str))
-//#define N_(str) dgettext(PACKAGE, (str))
-#else
-#define _(str) str
-//#define N_(str) str
-#endif
-
-static inline char *
-bad_cast (char const *s)
-{
- return (char *) s;
-}
-
static guestfs_h *g = NULL;
static int read_only = 0;
int verbose = 0;
static guestfs_h *g = NULL;
static int read_only = 0;
int verbose = 0;
@@
-360,8
+346,10
@@
fg_readlink (const char *path, char *buf, size_t size)
memcpy (buf, r, len);
buf[len] = '\0';
memcpy (buf, r, len);
buf[len] = '\0';
- if (free_it)
- free ((char *) r);
+ if (free_it) {
+ char *tmp = (char *) r;
+ free (tmp);
+ }
return 0;
}
return 0;
}
@@
-439,7
+427,7
@@
fg_symlink (const char *from, const char *to)
dir_cache_invalidate (to);
dir_cache_invalidate (to);
- r = guestfs_ln_s (g,
to, from
);
+ r = guestfs_ln_s (g,
from, to
);
if (r == -1)
return error ();
if (r == -1)
return error ();
@@
-453,6
+441,7
@@
fg_rename (const char *from, const char *to)
if (read_only) return -EROFS;
if (read_only) return -EROFS;
+ dir_cache_invalidate (from);
dir_cache_invalidate (to);
/* XXX It's not clear how close the 'mv' command is to the
dir_cache_invalidate (to);
/* XXX It's not clear how close the 'mv' command is to the
@@
-473,9
+462,10
@@
fg_link (const char *from, const char *to)
if (read_only) return -EROFS;
if (read_only) return -EROFS;
+ dir_cache_invalidate (from);
dir_cache_invalidate (to);
dir_cache_invalidate (to);
- r = guestfs_ln (g,
to, from
);
+ r = guestfs_ln (g,
from, to
);
if (r == -1)
return error ();
if (r == -1)
return error ();
@@
-544,14
+534,22
@@
fg_utimens (const char *path, const struct timespec ts[2])
time_t mtsecs = ts[1].tv_sec;
long mtnsecs = ts[1].tv_nsec;
time_t mtsecs = ts[1].tv_sec;
long mtnsecs = ts[1].tv_nsec;
+#ifdef UTIME_NOW
if (atnsecs == UTIME_NOW)
atnsecs = -1;
if (atnsecs == UTIME_NOW)
atnsecs = -1;
+#endif
+#ifdef UTIME_OMIT
if (atnsecs == UTIME_OMIT)
atnsecs = -2;
if (atnsecs == UTIME_OMIT)
atnsecs = -2;
+#endif
+#ifdef UTIME_NOW
if (mtnsecs == UTIME_NOW)
mtnsecs = -1;
if (mtnsecs == UTIME_NOW)
mtnsecs = -1;
+#endif
+#ifdef UTIME_OMIT
if (mtnsecs == UTIME_OMIT)
mtnsecs = -2;
if (mtnsecs == UTIME_OMIT)
mtnsecs = -2;
+#endif
r = guestfs_utimens (g, path, atsecs, atnsecs, mtsecs, mtnsecs);
if (r == -1)
r = guestfs_utimens (g, path, atsecs, atnsecs, mtsecs, mtnsecs);
if (r == -1)
@@
-619,7
+617,7
@@
fg_read (const char *path, char *buf, size_t size, off_t offset,
size_t rsize;
if (verbose)
size_t rsize;
if (verbose)
- fprintf (stderr, "fg_read: %s: size %zu offset %
z
u\n",
+ fprintf (stderr, "fg_read: %s: size %zu offset %
j
u\n",
path, size, offset);
/* The guestfs protocol limits size to somewhere over 2MB. We just
path, size, offset);
/* The guestfs protocol limits size to somewhere over 2MB. We just
@@
-694,7
+692,7
@@
fg_release (const char *path, struct fuse_file_info *fi)
/* Emulate this by calling sync. */
static int fg_fsync(const char *path, int isdatasync,
/* Emulate this by calling sync. */
static int fg_fsync(const char *path, int isdatasync,
- struct fuse_file_info *fi)
+
struct fuse_file_info *fi)
{
int r;
{
int r;
@@
-745,7
+743,7
@@
fg_getxattr (const char *path, const char *name, char *value,
size_t i;
int r = -ENOATTR;
for (i = 0; i < xattrs->len; ++i) {
size_t i;
int r = -ENOATTR;
for (i = 0; i < xattrs->len; ++i) {
- if (
strcmp (xattrs->val[i].attrname, name) == 0
) {
+ if (
STREQ (xattrs->val[i].attrname, name)
) {
size_t sz = xattrs->val[i].attrval_len;
if (sz > size)
sz = size;
size_t sz = xattrs->val[i].attrval_len;
if (sz > size)
sz = size;
@@
-860,7
+858,7
@@
fuse_help (void)
{
const char *tmp_argv[] = { program_name, "--help", NULL };
fuse_main (2, (char **) tmp_argv, &fg_operations, NULL);
{
const char *tmp_argv[] = { program_name, "--help", NULL };
fuse_main (2, (char **) tmp_argv, &fg_operations, NULL);
- exit (
0
);
+ exit (
EXIT_SUCCESS
);
}
static void __attribute__((noreturn))
}
static void __attribute__((noreturn))
@@
-938,7
+936,7
@@
main (int argc, char *argv[])
fuse_argv = realloc (fuse_argv, (1+fuse_argc) * sizeof (char *)); \
if (!fuse_argv) { \
perror ("realloc"); \
fuse_argv = realloc (fuse_argv, (1+fuse_argc) * sizeof (char *)); \
if (!fuse_argv) { \
perror ("realloc"); \
- exit (
1
); \
+ exit (
EXIT_FAILURE
); \
} \
fuse_argv[fuse_argc-1] = (str); \
fuse_argv[fuse_argc] = NULL; \
} \
fuse_argv[fuse_argc-1] = (str); \
fuse_argv[fuse_argc] = NULL; \
@@
-961,7
+959,7
@@
main (int argc, char *argv[])
g = guestfs_create ();
if (g == NULL) {
fprintf (stderr, _("guestfs_create: failed to create handle\n"));
g = guestfs_create ();
if (g == NULL) {
fprintf (stderr, _("guestfs_create: failed to create handle\n"));
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
guestfs_set_autosync (g, 1);
}
guestfs_set_autosync (g, 1);
@@
-993,13
+991,13
@@
main (int argc, char *argv[])
switch (c) {
case 0: /* options which are long only */
switch (c) {
case 0: /* options which are long only */
- if (
strcmp (long_options[option_index].name, "dir-cache-timeout") == 0
)
+ if (
STREQ (long_options[option_index].name, "dir-cache-timeout")
)
dir_cache_timeout = atoi (optarg);
dir_cache_timeout = atoi (optarg);
- else if (
strcmp (long_options[option_index].name, "fuse-help") == 0
)
+ else if (
STREQ (long_options[option_index].name, "fuse-help")
)
fuse_help ();
fuse_help ();
- else if (
strcmp (long_options[option_index].name, "selinux") == 0
)
+ else if (
STREQ (long_options[option_index].name, "selinux")
)
guestfs_set_selinux (g, 1);
guestfs_set_selinux (g, 1);
- else if (
strcmp (long_options[option_index].name, "trace") == 0
) {
+ else if (
STREQ (long_options[option_index].name, "trace")
) {
ADD_FUSE_ARG ("-f");
guestfs_set_trace (g, 1);
guestfs_set_recovery_proc (g, 1);
ADD_FUSE_ARG ("-f");
guestfs_set_trace (g, 1);
guestfs_set_recovery_proc (g, 1);
@@
-1007,19
+1005,19
@@
main (int argc, char *argv[])
else {
fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
program_name, long_options[option_index].name, option_index);
else {
fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
program_name, long_options[option_index].name, option_index);
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
break;
case 'a':
if (access (optarg, R_OK) != 0) {
perror (optarg);
}
break;
case 'a':
if (access (optarg, R_OK) != 0) {
perror (optarg);
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
drv = malloc (sizeof (struct drv));
if (!drv) {
perror ("malloc");
}
drv = malloc (sizeof (struct drv));
if (!drv) {
perror ("malloc");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
drv->filename = optarg;
drv->next = drvs;
}
drv->filename = optarg;
drv->next = drvs;
@@
-1030,7
+1028,7
@@
main (int argc, char *argv[])
mp = malloc (sizeof (struct mp));
if (!mp) {
perror ("malloc");
mp = malloc (sizeof (struct mp));
if (!mp) {
perror ("malloc");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
p = strchr (optarg, ':');
if (p) {
}
p = strchr (optarg, ':');
if (p) {
@@
-1063,13
+1061,13
@@
main (int argc, char *argv[])
case 'V':
printf ("%s %s\n", program_name, PACKAGE_VERSION);
case 'V':
printf ("%s %s\n", program_name, PACKAGE_VERSION);
- exit (
0
);
+ exit (
EXIT_SUCCESS
);
case HELP_OPTION:
case HELP_OPTION:
- usage (
0
);
+ usage (
EXIT_SUCCESS
);
default:
default:
- usage (
1
);
+ usage (
EXIT_FAILURE
);
}
}
}
}
@@
-1078,7
+1076,7
@@
main (int argc, char *argv[])
fprintf (stderr,
_("%s: must have at least one -a and at least one -m option\n"),
program_name);
fprintf (stderr,
_("%s: must have at least one -a and at least one -m option\n"),
program_name);
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
/* We'd better have a mountpoint. */
}
/* We'd better have a mountpoint. */
@@
-1086,18
+1084,18
@@
main (int argc, char *argv[])
fprintf (stderr,
_("%s: you must specify a mountpoint in the host filesystem\n"),
program_name);
fprintf (stderr,
_("%s: you must specify a mountpoint in the host filesystem\n"),
program_name);
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
/* Do the guest drives and mountpoints. */
add_drives (drvs);
if (guestfs_launch (g) == -1)
}
/* Do the guest drives and mountpoints. */
add_drives (drvs);
if (guestfs_launch (g) == -1)
- exit (
1
);
+ exit (
EXIT_FAILURE
);
mount_mps (mps);
/* FUSE example does this, not clear if it's necessary, but ... */
if (guestfs_umask (g, 0) == -1)
mount_mps (mps);
/* FUSE example does this, not clear if it's necessary, but ... */
if (guestfs_umask (g, 0) == -1)
- exit (
1
);
+ exit (
EXIT_FAILURE
);
/* At the last minute, remove the libguestfs error handler. In code
* above this point, the default error handler has been used which
/* At the last minute, remove the libguestfs error handler. In code
* above this point, the default error handler has been used which
@@
-1110,6
+1108,10
@@
main (int argc, char *argv[])
/* Finish off FUSE args. */
ADD_FUSE_ARG (argv[optind]);
/* Finish off FUSE args. */
ADD_FUSE_ARG (argv[optind]);
+ /*
+ It says about the line containing the for-statement:
+ error: assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow]
+
if (verbose) {
fprintf (stderr, "guestmount: invoking FUSE with args [");
for (i = 0; i < fuse_argc; ++i) {
if (verbose) {
fprintf (stderr, "guestmount: invoking FUSE with args [");
for (i = 0; i < fuse_argc; ++i) {
@@
-1118,6
+1120,7
@@
main (int argc, char *argv[])
}
fprintf (stderr, "]\n");
}
}
fprintf (stderr, "]\n");
}
+ */
r = fuse_main (fuse_argc, (char **) fuse_argv, &fg_operations, NULL);
r = fuse_main (fuse_argc, (char **) fuse_argv, &fg_operations, NULL);
@@
-1141,7
+1144,7
@@
add_drives (struct drv *drv)
else
r = guestfs_add_drive_ro (g, drv->filename);
if (r == -1)
else
r = guestfs_add_drive_ro (g, drv->filename);
if (r == -1)
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
}
}
}
@@
-1158,6
+1161,6
@@
mount_mps (struct mp *mp)
else
r = guestfs_mount_ro (g, mp->device, mp->mountpoint);
if (r == -1)
else
r = guestfs_mount_ro (g, mp->device, mp->mountpoint);
if (r == -1)
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
}
}
}