sbuild  1.6.5
Public Member Functions | Private Attributes | List of all members
sbuild::device_lock Class Reference

Device lock. More...

#include <sbuild-lock.h>

+ Inheritance diagram for sbuild::device_lock:
+ Collaboration diagram for sbuild::device_lock:

Public Member Functions

 device_lock (std::string const &device)
 The constructor. More...
 
virtual ~device_lock ()
 The destructor.
 
virtual void set_lock (lock::type lock_type, unsigned int timeout)
 Acquire a lock. More...
 
virtual void unset_lock ()
 Release a lock. More...
 

Private Attributes

std::string device
 The device to lock.
 
bool locked
 Is the file locked?
 

Additional Inherited Members

- Public Types inherited from sbuild::lock
enum  type { LOCK_SHARED = F_RDLCK, LOCK_EXCLUSIVE = F_WRLCK, LOCK_NONE = F_UNLCK }
 Lock type. More...
 
enum  error_code {
  TIMEOUT_HANDLER, TIMEOUT_SET, TIMEOUT_CANCEL, LOCK,
  UNLOCK, LOCK_TIMEOUT, UNLOCK_TIMEOUT, DEVICE_LOCK,
  DEVICE_LOCK_TIMEOUT, DEVICE_TEST, DEVICE_UNLOCK, DEVICE_UNLOCK_TIMEOUT
}
 Error codes. More...
 
typedef custom_error< error_codeerror
 Exception type.
 
- Protected Member Functions inherited from sbuild::lock
 lock ()
 The constructor.
 
virtual ~lock ()
 The destructor.
 
void set_alarm ()
 Set the SIGALARM handler. More...
 
void clear_alarm ()
 Restore the state of SIGALRM prior to starting lock acquisition.
 
void set_timer (struct itimerval const &timer)
 Set up an itimer for future expiry. More...
 
void unset_timer ()
 Remove any itimer currently set up. More...
 

Detailed Description

Device lock.

Set an advisory lock on a device. The lock is acquired using liblockdev lock_dev(). Note that a lock_type of LOCK_SHARED is equivalent to LOCK_EXCLUSIVE, because this lock type does not support shared locks.

Constructor & Destructor Documentation

device_lock::device_lock ( std::string const &  device)

The constructor.

Parameters
devicethe device to lock (full pathname).

Member Function Documentation

void device_lock::set_lock ( lock::type  lock_type,
unsigned int  timeout 
)
virtual
void device_lock::unset_lock ( )
virtual

Release a lock.

This is equivalent to set_lock with a lock_type of LOCK_NONE and a timeout of 0.

Implements sbuild::lock.

References sbuild::lock::LOCK_NONE, and set_lock().

Referenced by sbuild::chroot_block_device::setup_lock(), and sbuild::chroot_lvm_snapshot::setup_lock().

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: