Ejemplo n.º 1
0
struct guestfs_stat *
guestfs_impl_lstat (guestfs_h *g, const char *path)
{
  CLEANUP_FREE_STATNS struct guestfs_statns *r;
  struct guestfs_stat *ret;

  r = guestfs_lstatns (g, path);
  if (r == NULL)
    return NULL;

  ret = safe_malloc (g, sizeof *ret);
  statns_to_old_stat (r, ret);
  return ret;                   /* caller frees */
}
Ejemplo n.º 2
0
static int
mount_local_getattr (const char *path, struct stat *statbuf)
{
  const struct stat *buf;
  CLEANUP_FREE_STAT struct guestfs_statns *r = NULL;
  DECL_G ();
  DEBUG_CALL ("%s, %p", path, statbuf);

  buf = lsc_lookup (g, path);
  if (buf) {
    memcpy (statbuf, buf, sizeof *statbuf);
    return 0;
  }

  r = guestfs_lstatns (g, path);
  if (r == NULL)
    RETURN_ERRNO;

  memset (statbuf, 0, sizeof *statbuf);
  statbuf->st_dev = r->st_dev;
  statbuf->st_ino = r->st_ino;
  statbuf->st_mode = r->st_mode;
  statbuf->st_nlink = r->st_nlink;
  statbuf->st_uid = r->st_uid;
  statbuf->st_gid = r->st_gid;
  statbuf->st_rdev = r->st_rdev;
  statbuf->st_size = r->st_size;
  statbuf->st_blksize = r->st_blksize;
  statbuf->st_blocks = r->st_blocks;
  statbuf->st_atime = r->st_atime_sec;
#ifdef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
  statbuf->st_atim.tv_nsec = r->st_atime_nsec;
#endif
  statbuf->st_mtime = r->st_mtime_sec;
#ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
  statbuf->st_mtim.tv_nsec = r->st_mtime_nsec;
#endif
  statbuf->st_ctime = r->st_ctime_sec;
#ifdef HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC
  statbuf->st_ctim.tv_nsec = r->st_ctime_nsec;
#endif

  return 0;
}