On Wed, May 16, 2012 at 7:27 AM, Christian Brunner <c...@muc.de> wrote:
> This patch allows importing images from stdin with the following command:
>
>   rbd import --size=<size in MB> - [dest-image]
>
> Signed-off-by: Christian Brunner <c...@muc.de>
> ---
>  src/rbd.cc |   37 +++++++++++++++++++++++++------------
>  1 files changed, 25 insertions(+), 12 deletions(-)
>
> -  r = fstat(fd, &stat_buf);
> -  if (r < 0) {
> -    r = -errno;
> -    cerr << "stat error " << path << std::endl;
> -    return r;
> +  if (fd > 0) {
> +    r = fstat(fd, &stat_buf);
> +    if (r < 0) {
> +      r = -errno;
> +      cerr << "stat error " << path << std::endl;
> +      return r;
> +    }
> +    size = (uint64_t)stat_buf.st_size;
>   }
> -  size = (uint64_t)stat_buf.st_size;
> +

There's no reason why you couldn't stat stdin too, it's just not
guaranteed to give you anything helpful. Think "rbd import - myimg
<file". Just do the stat and react to the results, don't avoid the
stat.
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to