#include <fcntl.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <semaphore.h>
#include <string.h>
#include <time.h>
Go to the source code of this file.
Data Structures | |
struct | lxc_lock |
Macros | |
#define | LXC_LOCK_ANON_SEM 1 |
#define | LXC_LOCK_FLOCK 2 |
Functions | |
struct lxc_lock * | lxc_newlock (const char *lxcpath, const char *name) |
Create a new (unlocked) lock. More... | |
int | lxclock (struct lxc_lock *lock, int timeout) |
Take an existing lock. More... | |
int | lxcunlock (struct lxc_lock *lock) |
Unlock specified lock previously locked using lxclock(). More... | |
void | lxc_putlock (struct lxc_lock *lock) |
Free a lock created by lxc_newlock(). More... | |
void | process_lock (void) |
Lock the current process. | |
void | process_unlock (void) |
Unlock the current process. | |
int | container_mem_lock (struct lxc_container *c) |
Lock the containers memory. More... | |
void | container_mem_unlock (struct lxc_container *c) |
Unlock the containers memory. More... | |
int | container_disk_lock (struct lxc_container *c) |
Lock the containers disk data. More... | |
void | container_disk_unlock (struct lxc_container *c) |
Unlock the containers disk data. More... | |
liblxcapi
Copyright © 2012 Serge Hallyn serge. Copyright © 2012 Canonical Ltd. .hal lyn@u bunt u.com
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#define LXC_LOCK_ANON_SEM 1 |
Anonymous semaphore lock
#define LXC_LOCK_FLOCK 2 |
flock(2) lock
int container_disk_lock | ( | struct lxc_container * | c | ) |
Lock the containers disk data.
c | Container. |
0
on success, or an lxclock() error return values on error. void container_disk_unlock | ( | struct lxc_container * | c | ) |
Unlock the containers disk data.
c | Container. |
int container_mem_lock | ( | struct lxc_container * | c | ) |
void container_mem_unlock | ( | struct lxc_container * | c | ) |
Unlock the containers memory.
c | Container. |
struct lxc_lock* lxc_newlock | ( | const char * | lxcpath, |
const char * | name | ||
) |
Create a new (unlocked) lock.
lxcpath | lxcpath lock should relate to. |
name | Name for lock. |
NULL
on failure.name
is not given, create an unnamed semaphore (used to protect against racing threads).void lxc_putlock | ( | struct lxc_lock * | lock | ) |
Free a lock created by lxc_newlock().
lock | Lock. |
int lxclock | ( | struct lxc_lock * | lock, |
int | timeout | ||
) |
Take an existing lock.
lock | Lock to operate on. |
timeout | Seconds to wait to take lock (0 signifies an indefinite wait). |
0
if lock obtained, -2
on failure to set timeout, or -1
on any other error (errno
will be set by sem_wait(3)
or fcntl(2)
).timeout
is (currently?) only supported for privlock, not for slock. Since currently there is not a single use of the timeout (except in the test case) I may remove the support for it in sem as well.