summaryrefslogtreecommitdiff
path: root/contrib/sendmail/src/bf_torek.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/sendmail/src/bf_torek.c')
-rw-r--r--contrib/sendmail/src/bf_torek.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/contrib/sendmail/src/bf_torek.c b/contrib/sendmail/src/bf_torek.c
index ab129d43b70be..d58abc9c50e21 100644
--- a/contrib/sendmail/src/bf_torek.c
+++ b/contrib/sendmail/src/bf_torek.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_torek.c,v 8.19.18.2 2000/09/17 17:04:26 gshapiro Exp $";
+static char id[] = "@(#)$Id: bf_torek.c,v 8.19.18.4 2001/02/14 04:07:27 gshapiro Exp $";
#endif /* ! lint */
#if SFIO
@@ -381,6 +381,51 @@ 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;
+
+ if (bftest(fp))
+ {
+ /* Get bf structure */
+ bfp = (struct bf *)fp->_cookie;
+
+ if (bfp->bf_ondisk && bfp->bf_committed)
+ fd = bfp->bf_disk_fd;
+ else
+ 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: