On Thu, Aug 16, 2018 at 03:01:31PM -0500, Eric Blake wrote:
>> + }
>> + if (!has_size) {
>> + struct stat s;
>> + if (fstat(fd, &s)) {
>> + error_setg_errno(errp, errno, "could not fstat fd to get size");
>> + goto exit;
>> + }
>> + size = s.st_size;
>> + }
>
> This works for regular files, but not for block devices.
>
> Do we have a helper function for easily determining the size of an arbitrary
> fd (whether file or block device)? If not, should we? As there are
> multiple spots in the code that grab this sort of information.I found raw_getlength() in block/file-posix.c, but its static and it takes a BlockDriverState* as argument. For most systems it could be extracted without too much trouble, but some (e.g __sun__ and BSD) are quite entangled with BlockDriverState code. > Otherwise looks okay to me. Should I check for S_ISCHR() and S_ISBLK() and abort with an error? I don't think it's a common use case for pmemload anyway. Regards Simon -- + privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9
signature.asc
Description: PGP signature
