#include "progname.h"
+#include "guestmount.h"
#include "dircache.h"
/* See <attr/xattr.h> */
#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;
memcpy (buf, r, len);
buf[len] = '\0';
- if (free_it)
- free ((char *) r);
+ if (free_it) {
+ char *tmp = (char *) r;
+ free (tmp);
+ }
return 0;
}
dir_cache_invalidate (to);
- r = guestfs_ln_s (g, to, from);
+ r = guestfs_ln_s (g, from, to);
if (r == -1)
return error ();
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
if (read_only) return -EROFS;
+ dir_cache_invalidate (from);
dir_cache_invalidate (to);
- r = guestfs_ln (g, to, from);
+ r = guestfs_ln (g, from, to);
if (r == -1)
return error ();
time_t mtsecs = ts[1].tv_sec;
long mtnsecs = ts[1].tv_nsec;
+#ifdef UTIME_NOW
if (atnsecs == UTIME_NOW)
atnsecs = -1;
+#endif
+#ifdef UTIME_OMIT
if (atnsecs == UTIME_OMIT)
atnsecs = -2;
+#endif
+#ifdef UTIME_NOW
if (mtnsecs == UTIME_NOW)
mtnsecs = -1;
+#endif
+#ifdef UTIME_OMIT
if (mtnsecs == UTIME_OMIT)
mtnsecs = -2;
+#endif
r = guestfs_utimens (g, path, atsecs, atnsecs, mtsecs, mtnsecs);
if (r == -1)
/* 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;
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;
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);
- else if (strcmp (long_options[option_index].name, "fuse-help") == 0)
+ else if (STREQ (long_options[option_index].name, "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);
- 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);