Re: [PATCH 1/2] rbd: allow importing from stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 16, 2012 at 7:27 AM, Christian Brunner <chb@xxxxxx> 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 <chb@xxxxxx>
> ---
>  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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux