Example #1
0
void
dir_cache_invalidate (const char *path)
{
  lsc_remove (lsc_ht, path, lsc_free);
  lsc_remove (xac_ht, path, xac_free);
  lsc_remove (rlc_ht, path, rlc_free);
}
Example #2
0
static const struct stat *
lsc_lookup (guestfs_h *g, const char *pathname)
{
  const struct lsc_entry key = { .pathname = (char *) pathname };
  struct lsc_entry *entry;
  time_t now;

  time (&now);

  entry = hash_lookup (g->lsc_ht, &key);
  if (entry && entry->timeout >= now)
    return &entry->statbuf;
  else
    return NULL;
}

static const struct guestfs_xattr_list *
xac_lookup (guestfs_h *g, const char *pathname)
{
  const struct xac_entry key = { .pathname = (char *) pathname };
  struct xac_entry *entry;
  time_t now;

  time (&now);

  entry = hash_lookup (g->xac_ht, &key);
  if (entry && entry->timeout >= now)
    return entry->xattrs;
  else
    return NULL;
}

static const char *
rlc_lookup (guestfs_h *g, const char *pathname)
{
  const struct rlc_entry key = { .pathname = (char *) pathname };
  struct rlc_entry *entry;
  time_t now;

  time (&now);

  entry = hash_lookup (g->rlc_ht, &key);
  if (entry && entry->timeout >= now)
    return entry->link;
  else
    return NULL;
}

static void
lsc_remove (Hash_table *ht, const char *pathname, Hash_data_freer freer)
{
  const struct lsc_entry key = { .pathname = (char *) pathname };
  struct lsc_entry *entry;

  entry = hash_delete (ht, &key);

  freer (entry);
}

static void
dir_cache_invalidate (guestfs_h *g, const char *path)
{
  lsc_remove (g->lsc_ht, path, lsc_free);
  lsc_remove (g->xac_ht, path, xac_free);
  lsc_remove (g->rlc_ht, path, rlc_free);
}

#else /* !HAVE_FUSE */

int
guestfs__mount_local (guestfs_h *g, const char *localmountpoint,
                      const struct guestfs_mount_local_argv *optargs)
{
  guestfs_error_errno (g, ENOTSUP, _("FUSE not supported"));
  return -1;
}

int
guestfs__mount_local_run (guestfs_h *g)
{
  guestfs_error_errno (g, ENOTSUP, _("FUSE not supported"));
  return -1;
}

int
guestfs__umount_local (guestfs_h *g,
                       const struct guestfs_umount_local_argv *optargs)
{
  guestfs_error_errno (g, ENOTSUP, _("FUSE not supported"));
  return -1;
}