cc [ flag ... ] file ... –lvolmgt [ library ... ] #include <sys/types.h> #include <volmgt.h> int volmgt_acquire(char *dev, char *id, int ovr, char **err, pid_t * pidp);
This function is obsolete. The management of removable media by the Volume Management feature, including vold, has been replaced by software that supports the Hardware Abstraction Layer (HAL). Programmatic support for HAL is through the HAL APIs, which are documented on the HAL web site. See hal(5). The return value of this function is undefined.
The volmgt_acquire() routine reserves the removable media device specified as dev. volmgt_acquire() operates in two different modes, depending on whether or not volume management is running.
If volume management is running, volmgt_acquire() attempts to reserve the removable media device specified as dev. Specify dev as either a symbolic device name or a physical device pathname.
If volume management is not running, volmgt_acquire() requires callers to specify a physical device pathname for dev. Specifying dev as a symbolic device name is not acceptable. In this mode, volmgt_acquire() relies entirely on the major and minor numbers of the device to determine whether or not the device is reserved.
If dev is free, volmgt_acquire() updates the internal device reservation database with the caller's process id (pid) and the specified id string.
If dev is reserved by another process, the reservation attempt fails and volmgt_acquire():
sets errno to EBUSY
fills the caller's id value in the array pointed to by err
fills in the pid to which the pointer pidp points with the pid of the process which holds the reservation, if the supplied pidp is non-zero.
If the override ovr is non-zero, the call overrides the device reservation.
The return from this function is undefined.
The volmgt_acquire() routine fails if one or more of the following are true:
One of the specified arguments is invalid or missing.
dev is already reserved by another process (and ovr was not set to a non-zero value)
See attributes(5) for descriptions of the following attributes:
The ovr argument is intended to allow callers to override the current device reservation. It is assumed that the calling application has determined that the current reservation can safely be cleared.