Re: [PATCH 15/19] mkfs: don't treat files as though they are block devices

Eric Sandeen
2016-04-08T00:32:42Z

On 4/7/16 7:25 PM, Eric Sandeen wrote:
>> @@ -1299,15 +1370,23 @@ zero_old_xfs_structures(
>> > }
>> > memset(buf, 0, new_sb->sb_sectsize);
>> >
>> > - tmp = pread(xi->dfd, buf, new_sb->sb_sectsize, 0);
>> > - if (tmp < 0) {
>> > + off = pread(xi->dfd, buf, new_sb->sb_sectsize, 0);
>> > + if (off < 0) {
>> > fprintf(stderr, _("existing superblock read failed: %s\n"),
>> > strerror(errno));
>> > goto done;
>> > }
>> > - if (tmp != new_sb->sb_sectsize) {
>> > - fprintf(stderr,
>> > - _("warning: could not read existing superblock, skip zeroing\n"));
>> > + /*
>> > + * If we are creating an image file, it might be of zero length at this
>> > + * point in time. Hence reading the existing superblock is going to
>> > + * return zero bytes. It's not a failure we need to warn about in this
>> > + * case.
>> > + */
> except you already did "if (off < 0) fail" above this.

(oh, right, < 0 is different than == 0, sorry; so that part is ok)

Possibly better as:

if (off < 0 || (tmp != new_sb->sb_sectsize && !xi->disfile))
fprintf("error reading existing superblock ...")

I still think this patch might need a reset though :)

Thanks,
-Eric

> Ok, at this point I think it might be best to revert to Dave's original version.
>
> If there were specific problems you were trying to address, can you point them out?
>
> Thanks,
> -Eric