2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: lock.c /main/5 1996/11/08 02:07:28 cde-fuj $ */
25 * (c) Copyright 1995 FUJITSU LIMITED
26 * This is source code modified by FUJITSU LIMITED under the Joint
27 * Development Agreement for the CDEnext PST.
28 * This is unpublished proprietary source code of FUJITSU LIMITED
34 #include <sys/types.h>
43 * lock a file by a writing mode
51 #if NeedFunctionPrototypes
55 int fd; /* a file descripter */
62 flpar.l_type = F_RDLCK;
67 if ( fcntl( fd, F_SETLK, &flpar ) == -1 ) {
68 USAGE("Write lock not success \n" );
79 * free a file by a writing mode
86 #if NeedFunctionPrototypes
90 int fd; /* a file descripter */
96 flpar.l_type = F_UNLCK;
101 if ( fcntl( fd, F_SETLK, &flpar ) == -1 ){
102 USAGE("File unlock not success \n" );
111 * search whether file is locked by a writing mode
113 * 1 : file is locked by a writing mode
114 * 0 : file isn't locked by a writing mode
118 #if NeedFunctionPrototypes
122 int fd; /* file descripter */
128 flpar.l_type = F_WRLCK;
133 if ( fcntl( fd, F_GETLK, &flpar ) == -1 ) {
134 USAGE("Inquiry of file lock not sucess \n" );
138 if ( flpar.l_type == F_UNLCK ){