/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright 2016 Joyent, Inc.
*/
/*
* Acquire the specified kind of lock with the specified parameters. After
* acquiring the lock, a byte will be written to stdout. The program will
* then wait for a byte to be written to stdin before exiting.
*
* Usage: <posix|ofd|flock> <shared|exclusive> <path>
*/
#include "util.h"
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
static void acq_fcntl(int, int, int);
static void
{
int ret, i;
/*
* Acquire the lock, and then try reacquiring it several times. Once we
* have acquired the lock, trying to acquire it again should succeed,
* and shouldn't upgrade, downgrade or free the lock.
*/
for (i = 0; i < 3; i++) {
flock_log("Acquiring lock (fcntl)...\n");
if (ret == -1) {
}
}
/* Let the parent know we have the lock and wait */
flock_log("Waiting (fcntl)...\n");
flock_alert(1);
flock_block(0);
/* Now unlock */
flock_log("Releasing lock (fcntl)...\n");
if (ret == -1) {
}
}
static void
{
int ret, i;
/*
* Acquire the lock, and then try reacquiring it several times. Once we
* have acquired the lock, trying to acquire it again should succeed,
* and shouldn't upgrade, downgrade or free the lock.
*/
for (i = 0; i < 3; i++) {
flock_log("Acquiring lock (flock)...\n");
if (ret == -1) {
}
}
/* Wait to be okayed to unlock */
flock_log("Waiting (flock)...\n");
flock_alert(1);
flock_block(0);
/* Release lock */
flock_log("Releasing lock (flock)...\n");
if (ret == -1) {
}
}
static void
{
switch (style) {
case LSTYLE_POSIX:
break;
case LSTYLE_OFD:
break;
case LSTYLE_FLOCK:
break;
default:
abort();
}
}
int
{
int fd;
if (argc < 4) {
}
} else {
}
if (fd == -1) {
}
return (0);
}