Bug 74873

Summary: Insufficient feature-test for fdatasync
Product: shared-mime-info Reporter: Daniel Macks <dmacks>
Component: generalAssignee: Shared Mime Info group <shared_mime_info>
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Mac OS X (All)   
Whiteboard:
i915 platform: i915 features:

Description Daniel Macks 2014-02-12 05:46:38 UTC
On OS X 10.8...

checking for fdatasync... yes

update-mime-database.c:960:6: warning: implicit declaration of function 'fdatasync' is invalid in C99 [-Wimplicit-function-declaration]
        if (fdatasync(fd) == -1)

And then linking succeeds with no unresolved symbols. Our libSystem (analogous to linux glibc), that function exists, but it's not declared in any standard header and has no manpage. And the feature does not appear to be implemented: unistd.h defines _POSIX_SYNCHRONIZED_IO as -1, whereas 0 would mean supported. Google says that other OS X recent versions have the same situation (undeclared but present but unsupported) as well. My kernel sys/proto.h does have a declaration of fdatasync, but its prototype might indicate what libSystem does have isn't even what shared-mime-info wants (or at least would need an alternative parameter list):

int fdatasync(struct proc *, struct fdatasync_args *, int *);

3 arguments! Until someone figures out what this function is and how/if it should be used (if it even works), probably better to have autoconf do a more thorough test than just AC_CHECK_FUNCS. Look for it being declared? Look for _POSIX_SYNCHRONIZED_IO being 0 (if it's defined)?
Comment 1 Daniel Macks 2014-05-05 02:08:20 UTC
Still broken as of shared-mime-info-1.3
Comment 2 Bastien Nocera 2014-05-05 09:39:21 UTC
Generally waiting for a patch for this.
Comment 3 Daniel Macks 2014-05-05 22:45:18 UTC
I can fix the code, but don't know the larger picture. Easy enough to test for the implementation as well as the header/symbol being present. Googling around, some other programs fall back to fsync() if fdatasync() isn't supported rather than not syncing at all. See for example,

http://bugs.extatic.org/view.php?id=174

But it's a more expensive call IIRC...no idea how valuable doing some sort of sync is.
Comment 4 GitLab Migration User 2018-10-13 10:36:21 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/shared-mime-info/issues/7.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.