]>
git.saurik.com Git - apple/libc.git/blob - gen/sync_volume_np.c
2 * Copyright (c) 2011 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 #include <System/sys/fsctl.h>
29 * Sync a mounted filesystem, without syncing others.
30 * There are currently two flags that can be used:
32 * SYNC_VOLUME_FULLSYNC causes it to try to push the
33 * data to the platter (otherwise, it just pushes it
34 * to the disk drive, where it may remain in cache
37 * SYNC_VOLUME_WAIT causes it to wait until the writes
38 * have completed. Otherwise, it'll return as soon
39 * as the requests have been made.
41 * The functions are a simple wrapper for fsctl, and
42 * return what it does.
46 sync_volume_np(const char *path
, int flags
) {
51 if (flags
& SYNC_VOLUME_FULLSYNC
)
52 full_sync
|= FSCTL_SYNC_FULLSYNC
;
54 if (flags
& SYNC_VOLUME_WAIT
)
55 full_sync
|= FSCTL_SYNC_WAIT
;
58 rv
= (fsctl(path
, FSIOC_SYNC_VOLUME
, &full_sync
, 0) == -1) ? errno
: 0;
64 fsync_volume_np(int fd
, int flags
) {
69 if (flags
& SYNC_VOLUME_FULLSYNC
)
70 full_sync
|= FSCTL_SYNC_FULLSYNC
;
72 if (flags
& SYNC_VOLUME_WAIT
)
73 full_sync
|= FSCTL_SYNC_WAIT
;
76 rv
= (ffsctl(fd
, FSCTL_SYNC_VOLUME
, &full_sync
, 0) == -1) ? errno
: 0;