Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-05

Calling DO_SYSCALL on Mac OS X

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Roland Turcan

Hello FPC-Pascal users discussions!

I need to flush buffers from TFileStream which I should use function "fpfsync (Handle)", but as far as I found, there is no implementation of DO_SYSCALL for mac. DO_SYSCALL is implemented only for BSD.

When my application crashes all files modified over TFileStream are broken.

How to force flushing file stream?

Thanks.

Jonas Maebe
to Roland Turcan
Roland Turcan wrote
I need to flush buffers from TFileStream which I should use function "fpfsync (Handle)", but as far as I found, there is no implementation of DO_SYSCALL for mac. DO_SYSCALL is implemented only for BSD.

Why do you think that you need DO_SYSCALL?

When my application crashes all files modified over TFileStream are broken. How to force flushing file stream?

uses

   unix;

...
fpfsync(handle).

Jonas

Roland Turcan
to Jonas Maebe

<<< 20.5.2009 15:54 - Jonas Maebe "" >>>

Roland Turcan wrote
> I need to flush buffers from TFileStream which I should use function > "fpfsync (Handle)", but as far as I found, there is no implementation > of DO_SYSCALL for mac. DO_SYSCALL is implemented only for BSD.

JM> Why do you think that you need DO_SYSCALL?

I just didn't find relation of fpfsync function to mac os x implementation.

> When my application crashes all files modified over TFileStream are > broken. > > How to force flushing file stream?

JM> uses
JM> unix;
JM> ...
JM> fpfsync(handle).

I have the same actually, but it doesn't work as I expect.

When I write into FileStream any data I call FlushBuffer function which contains fpfsync(handle), but because if still buggy version of ported application I have some expections which crashes application and then nearly all changed files are broken.

Are you sure, that fpfsync works fine on Mac OS?

JM> Jonas

Jonas Maebe
to Roland Turcan
Roland Turcan wrote
I just didn't find relation of fpfsync function to mac os x implementation.

rtl/unix/unxdeclh.inc:

Function fpfsync (fd : cint) : cint; cdecl; external clib name 'fsync';
Show quoted text 11 lines
JM> uses JM> unix; JM> ... JM> fpfsync(handle). I have the same actually, but it doesn't work as I expect. When I write into FileStream any data I call FlushBuffer function which contains fpfsync(handle), but because if still buggy version of ported application I have some expections which crashes application and then nearly all changed files are broken.

Are you checking the return value of fpfsync for errors? And are you certain that nothing is buffered in the stream itself, or elsewhere in the application?

Are you sure, that fpfsync works fine on Mac OS?

No. I don't think anyone ever added a test for that function to the test suite (nor for most other Unix-unit functions). Also see the man page of fsync for caveats (although those only apply in case of a power failure or an OS crash).

Jonas