示例#1
0
static int
rlc_insert (guestfs_h *g,
            const char *path, const char *name, time_t now,
            char *link)
{
  struct rlc_entry *entry;
  size_t len;

  entry = malloc (sizeof *entry);
  if (entry == NULL) {
    perrorf (g, "malloc");
    return -1;
  }

  len = strlen (path) + strlen (name) + 2;
  entry->c.pathname = malloc (len);
  if (entry->c.pathname == NULL) {
    perrorf (g, "malloc");
    free (entry);
    return -1;
  }
  if (STREQ (path, "/"))
    snprintf (entry->c.pathname, len, "/%s", name);
  else
    snprintf (entry->c.pathname, len, "%s/%s", path, name);

  entry->link = link;

  entry->c.timeout = now + g->ml_dir_cache_timeout;

  return gen_replace (g, g->rlc_ht, (struct entry_common *) entry, rlc_free);
}
示例#2
0
文件: fuse.c 项目: msmhrt/libguestfs
static int
xac_insert (guestfs_h *g,
            const char *path, const char *name, time_t now,
            struct guestfs_xattr_list *xattrs)
{
  struct xac_entry *entry;

  entry = malloc (sizeof *entry);
  if (entry == NULL) {
    perror ("malloc");
    return -1;
  }

  size_t len = strlen (path) + strlen (name) + 2;
  entry->pathname = malloc (len);
  if (entry->pathname == NULL) {
    perror ("malloc");
    free (entry);
    return -1;
  }
  if (STREQ (path, "/"))
    snprintf (entry->pathname, len, "/%s", name);
  else
    snprintf (entry->pathname, len, "%s/%s", path, name);

  entry->xattrs = xattrs;

  entry->timeout = now + g->ml_dir_cache_timeout;

  return gen_replace (g->xac_ht, (struct lsc_entry *) entry, xac_free);
}
示例#3
0
文件: fuse.c 项目: msmhrt/libguestfs
static int
lsc_insert (guestfs_h *g,
            const char *path, const char *name, time_t now,
            struct stat const *statbuf)
{
  struct lsc_entry *entry;

  entry = malloc (sizeof *entry);
  if (entry == NULL) {
    perror ("malloc");
    return -1;
  }

  size_t len = strlen (path) + strlen (name) + 2;
  entry->pathname = malloc (len);
  if (entry->pathname == NULL) {
    perror ("malloc");
    free (entry);
    return -1;
  }
  if (STREQ (path, "/"))
    snprintf (entry->pathname, len, "/%s", name);
  else
    snprintf (entry->pathname, len, "%s/%s", path, name);

  memcpy (&entry->statbuf, statbuf, sizeof entry->statbuf);

  entry->timeout = now + g->ml_dir_cache_timeout;

  return gen_replace (g->lsc_ht, entry, lsc_free);
}
示例#4
0
int
rlc_insert (const char *path, const char *name, time_t now,
            char *link)
{
  struct rlc_entry *entry;

  entry = malloc (sizeof *entry);
  if (entry == NULL) {
    perror ("malloc");
    return -1;
  }

  size_t len = strlen (path) + strlen (name) + 2;
  entry->pathname = malloc (len);
  if (entry->pathname == NULL) {
    perror ("malloc");
    free (entry);
    return -1;
  }
  if (STREQ (path, "/"))
    snprintf (entry->pathname, len, "/%s", name);
  else
    snprintf (entry->pathname, len, "%s/%s", path, name);

  entry->link = link;

  entry->timeout = now + dir_cache_timeout;

  if (verbose)
    fprintf (stderr, "dir cache: inserting readlink entry %p (%s)\n",
             entry, entry->pathname);

  return gen_replace (rlc_ht, (struct lsc_entry *) entry, rlc_free);
}
示例#5
0
int
xac_insert (const char *path, const char *name, time_t now,
            struct guestfs_xattr_list *xattrs)
{
  struct xac_entry *entry;

  entry = malloc (sizeof *entry);
  if (entry == NULL) {
    perror ("malloc");
    return -1;
  }

  size_t len = strlen (path) + strlen (name) + 2;
  entry->pathname = malloc (len);
  if (entry->pathname == NULL) {
    perror ("malloc");
    free (entry);
    return -1;
  }
  if (STREQ (path, "/"))
    snprintf (entry->pathname, len, "/%s", name);
  else
    snprintf (entry->pathname, len, "%s/%s", path, name);

  entry->xattrs = xattrs;

  entry->timeout = now + dir_cache_timeout;

  if (verbose)
    fprintf (stderr, "dir cache: inserting xattr entry %p (%s)\n",
             entry, entry->pathname);

  return gen_replace (xac_ht, (struct lsc_entry *) entry, xac_free);
}
示例#6
0
int
lsc_insert (const char *path, const char *name, time_t now,
            struct stat const *statbuf)
{
  struct lsc_entry *entry;

  entry = malloc (sizeof *entry);
  if (entry == NULL) {
    perror ("malloc");
    return -1;
  }

  size_t len = strlen (path) + strlen (name) + 2;
  entry->pathname = malloc (len);
  if (entry->pathname == NULL) {
    perror ("malloc");
    free (entry);
    return -1;
  }
  if (STREQ (path, "/"))
    snprintf (entry->pathname, len, "/%s", name);
  else
    snprintf (entry->pathname, len, "%s/%s", path, name);

  memcpy (&entry->statbuf, statbuf, sizeof entry->statbuf);

  entry->timeout = now + dir_cache_timeout;

  if (verbose)
    fprintf (stderr, "dir cache: inserting lstat entry %p (%s)\n",
             entry, entry->pathname);

  return gen_replace (lsc_ht, entry, lsc_free);
}