4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
35 #include <sys/syscall.h>
38 * convert lockf() into fcntl() for SystemV compatibility
47 lockf(int fildes
, int function
, long size
)
52 cmd
= SV_SETLK
; /* assume non-blocking operation */
53 ld
.l_type
= F_WRLCK
; /* lockf() only deals with exclusive locks */
54 ld
.l_whence
= 1; /* lock always starts at current position */
65 if (_syscall(SYS_fcntl
, fildes
, SV_GETLK
, &ld
) != -1) {
66 if (ld
.l_type
== F_UNLCK
) {
68 /* l_pid is the last field in the
69 SVr3 flock structure */
72 errno
= EACCES
; /* EAGAIN ?? */
80 /* the rest fall thru to the fcntl() at the end */
86 cmd
= SV_SETLKW
; /* block, if not available */
92 if (_syscall(SYS_fcntl
, fildes
, cmd
, &ld
) == -1) {
94 /* this hack is purported to be for /usr/group compatibility */
100 ld
.l_pid
= ld
.l_xxx
; /* l_pid is the last field in the
101 SVr3 flock structure */