1*4763305eSRobert Mustacchi.\" 2*4763305eSRobert Mustacchi.\" This file and its contents are supplied under the terms of the 3*4763305eSRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0. 4*4763305eSRobert Mustacchi.\" You may only use this file in accordance with the terms of version 5*4763305eSRobert Mustacchi.\" 1.0 of the CDDL. 6*4763305eSRobert Mustacchi.\" 7*4763305eSRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this 8*4763305eSRobert Mustacchi.\" source. A copy of the CDDL is also available via the Internet at 9*4763305eSRobert Mustacchi.\" http://www.illumos.org/license/CDDL. 10*4763305eSRobert Mustacchi.\" 11*4763305eSRobert Mustacchi.\" 12*4763305eSRobert Mustacchi.\" Copyright 2024 Oxide Computer Company 13*4763305eSRobert Mustacchi.\" 14*4763305eSRobert Mustacchi.Dd July 13, 2024 15*4763305eSRobert Mustacchi.Dt SYNCFS 3C 16*4763305eSRobert Mustacchi.Os 17*4763305eSRobert Mustacchi.Sh NAME 18*4763305eSRobert Mustacchi.Nm syncfs 19*4763305eSRobert Mustacchi.Nd synchronize file system to disk 20*4763305eSRobert Mustacchi.Sh LIBRARY 21*4763305eSRobert Mustacchi.Lb libc 22*4763305eSRobert Mustacchi.Sh SYNOPSIS 23*4763305eSRobert Mustacchi.In unistd.h 24*4763305eSRobert Mustacchi.Ft int 25*4763305eSRobert Mustacchi.Fo syncfs 26*4763305eSRobert Mustacchi.Fa "int fd" 27*4763305eSRobert Mustacchi.Fc 28*4763305eSRobert Mustacchi.Sh DESCRIPTION 29*4763305eSRobert MustacchiThe 30*4763305eSRobert Mustacchi.Fn syncfs 31*4763305eSRobert Mustacchifunction instructs the file system associated with the file descriptor, 32*4763305eSRobert Mustacchi.Fa fd , 33*4763305eSRobert Mustacchito ensure that all pending data and metadata updates that are still 34*4763305eSRobert Mustacchiin-memory are synchronized back to the file system's underlying storage 35*4763305eSRobert Mustacchidevices. 36*4763305eSRobert MustacchiThis function will block until all such writes are completed. 37*4763305eSRobert Mustacchi.Pp 38*4763305eSRobert MustacchiNot all file systems support this request. 39*4763305eSRobert MustacchiThis may happen either because the file system has not been enhanced yet 40*4763305eSRobert Mustacchito support this request or because the file system does not support the 41*4763305eSRobert Mustacchiidea of synchronizing data to a backing store such as the underlying 42*4763305eSRobert Mustacchisocket file system or the read-only 43*4763305eSRobert Mustacchi.Xr bootfs 4FS 44*4763305eSRobert Mustacchifile system. 45*4763305eSRobert Mustacchi.Pp 46*4763305eSRobert MustacchiIf an application only cares about the state of a single file and its 47*4763305eSRobert Mustacchimetadata, then it should use the 48*4763305eSRobert Mustacchi.Xr fsync 3C 49*4763305eSRobert Mustacchifunction instead. 50*4763305eSRobert MustacchiThe traditional 51*4763305eSRobert Mustacchi.Xr sync 2 52*4763305eSRobert Mustacchifunction has two primary differences from the 53*4763305eSRobert Mustacchi.Fn syncfs function: 54*4763305eSRobert Mustacchi.Xr sync 2 55*4763305eSRobert Mustacchiinstructs the system to schedule all I/O across all file 56*4763305eSRobert Mustacchisystems to be synchronized and it does not guarantee that all that 57*4763305eSRobert MustacchiI/O is completed prior to returning. 58*4763305eSRobert MustacchiThere is no non-blocking way to force I/O to be synchronized to a 59*4763305eSRobert Mustacchispecific file system. 60*4763305eSRobert Mustacchi.Sh RETURN VALUES 61*4763305eSRobert MustacchiUpon successful completion, the 62*4763305eSRobert Mustacchi.Fn syncfs 63*4763305eSRobert Mustacchifunction returns 64*4763305eSRobert Mustacchi.Sy 0 65*4763305eSRobert Mustacchiand ensures that the file system data and metadata synchronization has 66*4763305eSRobert Mustacchialready completed. 67*4763305eSRobert MustacchiOtherwise 68*4763305eSRobert Mustacchi.Sy -1 69*4763305eSRobert Mustacchiis returned 70*4763305eSRobert Mustacchiand 71*4763305eSRobert Mustacchi.Va errno 72*4763305eSRobert Mustacchiis set to indicate the error and outstanding file system data and 73*4763305eSRobert Mustacchimetadata is not guaranteed to have been synchronized. 74*4763305eSRobert Mustacchi.Sh ERRORS 75*4763305eSRobert MustacchiThe 76*4763305eSRobert Mustacchi.Fn syncfs 77*4763305eSRobert Mustacchifunctions will fail if: 78*4763305eSRobert Mustacchi.Bl -tag -width Er 79*4763305eSRobert Mustacchi.It Er EBADF 80*4763305eSRobert MustacchiThe 81*4763305eSRobert Mustacchi.Fa fd 82*4763305eSRobert Mustacchiargument is not a valid open file descriptor in the calling process. 83*4763305eSRobert Mustacchi.It Er EDQUOT, ENOSPC 84*4763305eSRobert MustacchiThere was no free space remaining on the file system's backing store or 85*4763305eSRobert Mustacchia quota was hit. 86*4763305eSRobert Mustacchi.It Er EIO 87*4763305eSRobert MustacchiAn I/O error occurred while reading or writing. 88*4763305eSRobert Mustacchi.It Er ENOSYS 89*4763305eSRobert MustacchiThe file system backing the file descriptor, 90*4763305eSRobert Mustacchi.Fa fd , 91*4763305eSRobert Mustacchidoes not support file system-wide synchronization. 92*4763305eSRobert Mustacchi.El 93*4763305eSRobert Mustacchi.Pp 94*4763305eSRobert MustacchiIt is possible that a remote file system 95*4763305eSRobert Mustacchi.Pq e.g. NFS 96*4763305eSRobert Mustacchimay fail with additional errors that are unique to the network based 97*4763305eSRobert Mustacchinature of the file system. 98*4763305eSRobert Mustacchi.Sh INTERFACE STABILITY 99*4763305eSRobert Mustacchi.Sy Committed 100*4763305eSRobert Mustacchi.Sh MT-LEVEL 101*4763305eSRobert Mustacchi.Sy Safe 102*4763305eSRobert Mustacchi.Sh SEE ALSO 103*4763305eSRobert Mustacchi.Xr sync 2 , 104*4763305eSRobert Mustacchi.Xr fsync 3C 105