/home/abuild/rpmbuild/BUILD/lxc-1.1.2/src/lxc/lxclock.h File Reference
#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.
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 |
Function Documentation
Lock the containers disk data.
- Parameters:
-
- Returns:
0
on success, or an lxclock() error return values on error.
Lock the containers memory.
- Parameters:
-
- Returns:
- As for lxclock().
Unlock the containers memory.
- Parameters:
-
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 |
) |
|
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)
).
- 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:
-
- Returns:
0
on success, -2
if provided lock was not already held, otherwise -1
with errno
saved from flock(2)
or sem_post function.