Re: [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

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

 




On 25/08/2015 18:03, Stefan Hajnoczi wrote:
>> >  
>> > +static uint64_t get_file_size(int fd)
>> > +{
>> > +    struct stat stat_buf;
>> > +    uint64_t size;
>> > +
>> > +    if (fstat(fd, &stat_buf) < 0) {
>> > +        return 0;
>> > +    }
>> > +
>> > +    if (S_ISREG(stat_buf.st_mode)) {
>> > +        return stat_buf.st_size;
>> > +    }
>> > +
>> > +    if (S_ISBLK(stat_buf.st_mode) && !ioctl(fd, BLKGETSIZE64, &size)) {
>> > +        return size;
>> > +    }
> #ifdef __linux__ for ioctl(fd, BLKGETSIZE64, &size)?
> 
> There is nothing Linux-specific about emulating NVDIMMs so this code
> should compile on all platforms.

The code from block/raw-posix.c and block/raw-win32.c's raw_getlength
should probably be extracted to a new function in utils/, and reused here.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux