/*
* 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 (c) 2012 by Delphix. All rights reserved.
*/
/*
* Make a directory busy. If the argument is an existing file or directory,
* simply open it directly and pause. If not, verify that the parent directory
* exists, and create a new file in that directory.
*/
#include <stdio.h>
#include <fcntl.h>
#include <dirent.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
static void
{
exit(1);
}
static void
{
}
static void
daemonize(void)
{
} else if (pid != 0) {
exit(0);
}
(void) setsid();
(void) close(0);
(void) close(1);
(void) close(2);
}
int
{
int ret, c;
switch (c) {
/* Open the file or directory read only */
case 'r':
break;
/* Run in the foreground */
case 'f':
break;
default:
}
}
if (argc != 1)
char *slash;
/*
* The argument supplied doesn't exist. Copy the path, and
* remove the trailing slash if presnt.
*/
/*
* Get the directory and file names, using the current directory
* if the provided path doesn't specify a directory at all.
*/
} else {
*slash = '\0';
}
/* The directory portion of the path must exist */
S_IFDIR))
} else {
}
} else {
}
daemonize();
(void) pause();
/* NOTREACHED */
return (0);
}