4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/types.h>
38 shm_open(const char *path
, int oflag
, mode_t mode
)
44 if (__pos4obj_check(path
) == -1)
47 /* acquire semaphore lock to have atomic operation */
48 if (__pos4obj_lock(path
, SHM_LOCK_TYPE
) < 0)
51 fd
= __pos4obj_open(path
, SHM_DATA_TYPE
, oflag
, mode
, &crflag
);
54 (void) __pos4obj_unlock(path
, SHM_LOCK_TYPE
);
58 if ((flags
= fcntl(fd
, F_GETFD
)) < 0 ||
59 fcntl(fd
, F_SETFD
, flags
| FD_CLOEXEC
) < 0) {
60 (void) __pos4obj_unlock(path
, SHM_LOCK_TYPE
);
61 (void) __close_nc(fd
);
65 /* relase semaphore lock operation */
66 if (__pos4obj_unlock(path
, SHM_LOCK_TYPE
) < 0) {
67 (void) __close_nc(fd
);
75 shm_unlink(const char *path
)
80 if (__pos4obj_check(path
) < 0)
83 if (__pos4obj_lock(path
, SHM_LOCK_TYPE
) < 0)
86 err
= __pos4obj_unlink(path
, SHM_DATA_TYPE
);
90 (void) __pos4obj_unlock(path
, SHM_LOCK_TYPE
);