diff options
Diffstat (limited to 'contrib/sendmail/src/bf_portable.c')
-rw-r--r-- | contrib/sendmail/src/bf_portable.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/contrib/sendmail/src/bf_portable.c b/contrib/sendmail/src/bf_portable.c index 4de0af3..3c09cec 100644 --- a/contrib/sendmail/src/bf_portable.c +++ b/contrib/sendmail/src/bf_portable.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. + * Copyright (c) 1999-2001 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set @@ -11,7 +11,7 @@ */ #ifndef lint -static char id[] = "@(#)$Id: bf_portable.c,v 8.25.4.3 2000/06/29 21:21:58 gshapiro Exp $"; +static char id[] = "@(#)$Id: bf_portable.c,v 8.25.4.5 2001/02/14 04:07:27 gshapiro Exp $"; #endif /* ! lint */ #if SFIO @@ -283,6 +283,47 @@ bftruncate(fp) } /* +** BFFSYNC -- fsync the fd associated with the FILE * +** +** Parameters: +** fp -- FILE * to fsync +** +** Returns: +** 0 on success, -1 on error +** +** Sets errno: +** EINVAL if FILE * not bfcommitted yet. +** any value of errno specified by fsync() +*/ + +int +bffsync(fp) + FILE *fp; +{ + int fd; + struct bf *bfp; + + /* Get associated bf structure */ + bfp = bflookup(fp); + + /* If called on a normal FILE *, noop */ + if (bfp != NULL && !bfp->bf_committed) + fd = -1; + else + fd = fileno(fp); + + if (tTd(58, 10)) + dprintf("bffsync: fd = %d\n", fd); + + if (fd < 0) + { + errno = EINVAL; + return -1; + } + return fsync(fd); +} + +/* ** BFCLOSE -- close a buffered file ** ** Parameters: |