/***
This file is part of systemd.
Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
Copyright 2009 Alan Jenkins <alan-jenkins@tuffmail.co.uk>
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.
systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "io-util.h"
#include "libudev-private.h"
/**
* SECTION:libudev-queue
* @short_description: access to currently active events
*
* This exports the current state of the udev processing queue.
*/
/**
* udev_queue:
*
* Opaque object representing the current event queue in the udev daemon.
*/
struct udev_queue {
int refcount;
int fd;
};
/**
* udev_queue_new:
* @udev: udev library context
*
* The initial refcount is 1, and needs to be decremented to
* release the resources of the udev queue context.
*
* Returns: the udev queue context, or #NULL on error.
**/
{
return NULL;
if (udev_queue == NULL)
return NULL;
return udev_queue;
}
/**
* udev_queue_ref:
* @udev_queue: udev queue context
*
* Take a reference of a udev queue context.
*
* Returns: the same udev queue context.
**/
{
if (udev_queue == NULL)
return NULL;
udev_queue->refcount++;
return udev_queue;
}
/**
* udev_queue_unref:
* @udev_queue: udev queue context
*
* Drop a reference of a udev queue context. If the refcount reaches zero,
* the resources of the queue context will be released.
*
* Returns: #NULL
**/
{
if (udev_queue == NULL)
return NULL;
udev_queue->refcount--;
if (udev_queue->refcount > 0)
return NULL;
return NULL;
}
/**
* udev_queue_get_udev:
* @udev_queue: udev queue context
*
* Retrieve the udev library context the queue context was created with.
*
* Returns: the udev library context.
**/
{
if (udev_queue == NULL)
return NULL;
return udev_queue->udev;
}
/**
* udev_queue_get_kernel_seqnum:
* @udev_queue: udev queue context
*
* This function is deprecated.
*
* Returns: 0.
**/
{
return 0;
}
/**
* udev_queue_get_udev_seqnum:
* @udev_queue: udev queue context
*
* This function is deprecated.
*
* Returns: 0.
**/
{
return 0;
}
/**
* udev_queue_get_udev_is_active:
* @udev_queue: udev queue context
*
* Check if udev is active on the system.
*
* Returns: a flag indicating if udev is active.
**/
{
}
/**
* udev_queue_get_queue_is_empty:
* @udev_queue: udev queue context
*
* Check if udev is currently processing any events.
*
* Returns: a flag indicating if udev is currently handling events.
**/
{
}
/**
* udev_queue_get_seqnum_sequence_is_finished:
* @udev_queue: udev queue context
* @start: first event sequence number
* @end: last event sequence number
*
* This function is deprecated, it just returns the result of
* udev_queue_get_queue_is_empty().
*
* Returns: a flag indicating if udev is currently handling events.
**/
{
return udev_queue_get_queue_is_empty(udev_queue);
}
/**
* udev_queue_get_seqnum_is_finished:
* @udev_queue: udev queue context
* @seqnum: sequence number
*
* This function is deprecated, it just returns the result of
* udev_queue_get_queue_is_empty().
*
* Returns: a flag indicating if udev is currently handling events.
**/
_public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum)
{
return udev_queue_get_queue_is_empty(udev_queue);
}
/**
* udev_queue_get_queued_list_entry:
* @udev_queue: udev queue context
*
* This function is deprecated.
*
* Returns: NULL.
**/
{
return NULL;
}
/**
* udev_queue_get_fd:
* @udev_queue: udev queue context
*
* Returns: a file descriptor to watch for a queue to become empty.
*/
int fd;
int r;
if (udev_queue->fd >= 0)
return udev_queue->fd;
if (fd < 0)
return -errno;
if (r < 0) {
r = -errno;
return r;
}
return fd;
}
/**
* udev_queue_flush:
* @udev_queue: udev queue context
*
* Returns: the result of clearing the watch for queue changes.
*/
if (udev_queue->fd < 0)
return -EINVAL;
}