Re: Using fsync instead of ioctl(fd, DIOCGFLUSH); (Re: anybody besides me trying to compile gpt-fdisk?)

2015-10-24 Thread Joel Rees
On Thu, Oct 22, 2015 at 11:15 PM, Christian Weisgerber
 wrote:
> On 2015-10-21, Joel Rees  wrote:
>
>> Is fsync an appropriate way to flush writes to the disk device? In the
>> FreeBSD code, it is
>>
>>   i = ioctl(fd, DIOCGFLUSH);
>
> Dunno, but I'd check what fdisk and disklabel do.

Near as I can tell, from MBR_write in mbr.c and GPT_write() in gpt.c,
the openbsd way would be to use DISK_writesector() and ordinary
write()s and optionally reload the table with

   ioctl( fd, DIOCRLDINFO, 0)

disklabel is a little more opaque to my first efforts to read it, but,
from mpsave in editor.c, it looks like ordinary fprintf()s followed by
closing the file.

So openbsd doesn't seem to need to actually explicitly sync or flush.

An fsync() would probably not hurt, but should probably include a
comment that it probably is redundant?

OH, and openbsd's fdisk got the -g option somewhere between mid August
and October 11th :-)

Cool. Maybe we don't care whether gptfdisk compiles or runs here. But
I'll try to invent some ways to test it over the next couple of weeks
anyway, just because I need the practice.

-- 
Joel Rees

Be careful when you look at conspiracy.
Arm yourself with knowledge of yourself, as well:
http://reiisi.blogspot.jp/2011/10/conspiracy-theories.html



Re: Using fsync instead of ioctl(fd, DIOCGFLUSH); (Re: anybody besides me trying to compile gpt-fdisk?)

2015-10-22 Thread Christian Weisgerber
On 2015-10-21, Joel Rees  wrote:

> Is fsync an appropriate way to flush writes to the disk device? In the
> FreeBSD code, it is
>
>   i = ioctl(fd, DIOCGFLUSH);

Dunno, but I'd check what fdisk and disklabel do.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de