filelock-darwin.cpp revision cae3b8810c39392e70dfb12b951431018a80fcba
/* $Id$ */
/** @file
* IPRT - File Locking, POSIX.
*/
/*
* Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP RTLOGGROUP_FILE
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
{
/* Check arguments. */
if (fLock & ~RTFILE_LOCK_MASK)
{
return VERR_INVALID_PARAMETER;
}
/*
* Validate offset.
*/
&& ( (offLock >> 32) != 0
|| (cbLock >> 32) != 0
{
return VERR_NOT_SUPPORTED;
}
/* Prepare flock structure. */
return VINF_SUCCESS;
{
/*
* This is really bad hack for getting VDIs to work somewhat
* safely on SMB mounts.
*/
/** @todo we need to keep track of these locks really. Anyone requiring to lock more
* than one part of a file will have to fix this. */
unsigned f = 0;
if (fLock & RTFILE_LOCK_WAIT)
f |= LOCK_NB;
if (fLock & RTFILE_LOCK_WRITE)
f |= LOCK_EX;
else
f |= LOCK_SH;
return VINF_SUCCESS;
if (iErr == EWOULDBLOCK)
return VERR_FILE_LOCK_VIOLATION;
}
return VERR_FILE_LOCK_VIOLATION;
return RTErrConvertFromErrno(iErr);
}
{
/** @todo We never returns VERR_FILE_NOT_LOCKED for now. */
}
{
/*
* Validate offset.
*/
&& ( (offLock >> 32) != 0
|| (cbLock >> 32) != 0
{
return VERR_NOT_SUPPORTED;
}
/* Prepare flock structure. */
return VINF_SUCCESS;
{
/* A SMB hack, see RTFileLock. */
return VINF_SUCCESS;
}
/** @todo check error codes for non existing lock. */
return VERR_FILE_LOCK_VIOLATION;
return RTErrConvertFromErrno(iErr);
}