tt/mini_isam: remove all ancient sccsid blocks
[oweals/cde.git] / cde / lib / tt / mini_isam / issync.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
24 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
25 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
26 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
27 /*%%  $XConsortium: issync.c /main/3 1995/10/23 11:45:20 rswiston $                                                      */
28 /*
29  * Copyright (c) 1988 by Sun Microsystems, Inc.
30  */
31
32 /*
33  * issync.c
34  *
35  * Description:
36  *      Sync all kernel buffers to the disk.
37  *
38  * Note: issync() flushes changed kernel buffers that are local to
39  *      the application that issued the call.
40  * 
41  * See sync(2) UNIX manual for what actually happens if sync() is called.
42  */
43
44 #include "isam_impl.h"
45 #include <sys/file.h>
46 #include <sys/time.h>
47
48 /*
49  * int  issync()
50  */
51
52 int 
53 issync(void)
54 {
55     return iscntl(ALLISFD, ISCNTL_FSYNC);
56 }
57
58 /*
59  * int  isfsync(fd)
60  */
61
62 int 
63 isfsync(int isfd)
64 {
65     return iscntl(isfd, ISCNTL_FSYNC);
66 }
67
68
69 int _issync(void)
70 {
71     int         i;
72
73     for (i = 0; i < MAXISFD; i++)
74         (void)_isfsync(i);
75
76     return (ISOK);
77 }
78
79 int _isfsync(int isfd)
80 {
81     Fab *fab;
82     Fcb                 *fcb;
83     int                 ret;
84
85     /*
86      * Get File Access Block.
87      */
88     if ((fab = _isfd_find(isfd)) == NULL) {
89         _setiserrno2(ENOTOPEN, '9', '0');
90         return (ISERROR);
91     }
92
93     /*
94      * Check that the open mode was ISINPUT, or ISINOUT.
95      */
96     if (fab->openmode != OM_INPUT && fab->openmode != OM_INOUT) {
97         _setiserrno2(ENOTOPEN, '9', '0');
98         return (ISERROR);
99     }
100
101     _isam_entryhook();
102
103     /*
104      * Get FCB corresponding to the isfhandle handle.
105      */
106     if ((fcb = _openfcb(&fab->isfhandle, &fab->errcode)) == NULL) {
107         _isam_exithook();
108         ret = ISERROR;
109     }
110     else {
111
112         if (fcb->datfd != -1)
113             (void)fsync(fcb->datfd);
114
115         if (fcb->indfd != -1)
116             (void)fsync(fcb->indfd);
117
118         if (fcb->varfd != -1)
119             (void)fsync(fcb->varfd);
120
121         _amseterrcode(&fab->errcode, ISOK);
122         _isam_exithook();
123         ret = ISOK;
124     }
125
126     _seterr_errcode(&fab->errcode);
127
128     return (ret);                            /* Successful write */
129 }