lxclock.h File Reference

#include <fcntl.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <semaphore.h>
#include <string.h>
#include <time.h>
Include dependency graph for lxclock.h:

Go to the source code of this file.

Data Structures

struct  lxc_lock

Defines

#define LXC_LOCK_ANON_SEM   1
#define LXC_LOCK_FLOCK   2

Functions

struct lxc_locklxc_newlock (const char *lxcpath, const char *name)
 Create a new (unlocked) lock.
int lxclock (struct lxc_lock *lock, int timeout)
 Take an existing lock.
int lxcunlock (struct lxc_lock *lock)
 Unlock specified lock previously locked using lxclock().
void lxc_putlock (struct lxc_lock *lock)
 Free a lock created by lxc_newlock().
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.
void container_mem_unlock (struct lxc_container *c)
 Unlock the containers memory.
int container_disk_lock (struct lxc_container *c)
 Lock the containers disk data.
void container_disk_unlock (struct lxc_container *c)
 Unlock the containers disk data.

Detailed Description

liblxcapi

Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>. Copyright © 2012 Canonical Ltd.

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 Documentation

#define LXC_LOCK_ANON_SEM   1

Anonymous semaphore lock

#define LXC_LOCK_FLOCK   2

flock(2) lock


Function Documentation

int container_disk_lock ( struct lxc_container c  ) 

Lock the containers disk data.

Parameters:
c Container.
Returns:
0 on success, or an lxclock() error return values on error.
void container_disk_unlock ( struct lxc_container c  ) 

Unlock the containers disk data.

Parameters:
c Container.
int container_mem_lock ( struct lxc_container c  ) 

Lock the containers memory.

Parameters:
c Container.
Returns:
As for lxclock().
void container_mem_unlock ( struct lxc_container c  ) 

Unlock the containers memory.

Parameters:
c Container.
struct lxc_lock* lxc_newlock ( const char *  lxcpath,
const char *  name 
) [read]

Create a new (unlocked) lock.

Parameters:
lxcpath lxcpath lock should relate to.
name Name for lock.
Returns:
Newly-allocated lxclock on success, NULL on failure.
Note:
If name is not given, create an unnamed semaphore (used to protect against racing threads).
Note that an unnamed sem was malloced by us and needs to be freed.
void lxc_putlock ( struct lxc_lock lock  ) 

Free a lock created by lxc_newlock().

Parameters:
lock Lock.
int lxclock ( struct lxc_lock lock,
int  timeout 
)

Take an existing lock.

Parameters:
lock Lock to operate on.
timeout Seconds to wait to take lock (0 signifies an indefinite wait).
Returns:
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)).
Note:
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.
int lxcunlock ( struct lxc_lock lock  ) 

Unlock specified lock previously locked using lxclock().

Parameters:
lock lxc_lock.
Returns:
0 on success, -2 if provided lock was not already held, otherwise -1 with errno saved from fcntl(2) or sem_post function.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Oct 2017 for LXC by  doxygen 1.6.1