X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flibudev%2Flibudev-queue.c;h=f67dba99584ab2dad1f74a7629924fcf14c144e5;hp=ca230023072065cb9c1c837fff01ce60c080eb35;hb=051dfe8708e394a64e8ef6c281228763481ad32c;hpb=6ada823a9a0979ea145fd70add1007c21caa45c0 diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c index ca2300230..f67dba995 100644 --- a/src/libudev/libudev-queue.c +++ b/src/libudev/libudev-queue.c @@ -1,14 +1,22 @@ -/* - * libudev - interface to udev device information - * - * Copyright (C) 2008 Kay Sievers - * Copyright (C) 2009 Alan Jenkins - * - * 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 file is part of systemd. + + Copyright 2008-2012 Kay Sievers + Copyright 2009 Alan Jenkins + + systemd 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. + + 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 . +***/ #include #include @@ -92,16 +100,19 @@ _public_ struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue) * * Drop a reference of a udev queue context. If the refcount reaches zero, * the resources of the queue context will be released. + * + * Returns: #NULL **/ -_public_ void udev_queue_unref(struct udev_queue *udev_queue) +_public_ struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue) { if (udev_queue == NULL) - return; + return NULL; udev_queue->refcount--; if (udev_queue->refcount > 0) - return; + return NULL; udev_list_cleanup(&udev_queue->queue_list); free(udev_queue); + return NULL; } /** @@ -142,7 +153,9 @@ unsigned long long int udev_get_kernel_seqnum(struct udev *udev) * udev_queue_get_kernel_seqnum: * @udev_queue: udev queue context * - * Returns: the current kernel event sequence number. + * Get the current kernel event sequence number. + * + * Returns: the sequence number. **/ _public_ unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue) { @@ -205,16 +218,14 @@ ssize_t udev_queue_read_devpath(FILE *queue_file, char *devpath, size_t size) static FILE *open_queue_file(struct udev_queue *udev_queue, unsigned long long int *seqnum_start) { - char filename[UTIL_PATH_SIZE]; FILE *queue_file; - util_strscpyl(filename, sizeof(filename), "/run/udev/queue.bin", NULL); - queue_file = fopen(filename, "re"); + queue_file = fopen("/run/udev/queue.bin", "re"); if (queue_file == NULL) return NULL; if (udev_queue_read_seqnum(queue_file, seqnum_start) < 0) { - err(udev_queue->udev, "corrupt queue file\n"); + udev_err(udev_queue->udev, "corrupt queue file\n"); fclose(queue_file); return NULL; } @@ -226,7 +237,9 @@ static FILE *open_queue_file(struct udev_queue *udev_queue, unsigned long long i * udev_queue_get_udev_seqnum: * @udev_queue: udev queue context * - * Returns: the last known udev event sequence number. + * Get the last known udev event sequence number. + * + * Returns: the sequence number. **/ _public_ unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue) { @@ -258,6 +271,8 @@ _public_ unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *ud * 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. **/ _public_ int udev_queue_get_udev_is_active(struct udev_queue *udev_queue) @@ -277,6 +292,8 @@ _public_ int udev_queue_get_udev_is_active(struct udev_queue *udev_queue) * 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. **/ _public_ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue) @@ -331,6 +348,8 @@ out: * @start: first event sequence number * @end: last event sequence number * + * Check if udev is currently processing any events in a given sequence number range. + * * Returns: a flag indicating if any of the sequence numbers in the given range is currently active. **/ _public_ int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue, @@ -393,6 +412,8 @@ _public_ int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_ * @udev_queue: udev queue context * @seqnum: sequence number * + * Check if udev is currently processing a given sequence number. + * * Returns: a flag indicating if the given sequence number is currently active. **/ _public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum) @@ -407,7 +428,9 @@ _public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, un * udev_queue_get_queued_list_entry: * @udev_queue: udev queue context * - * Returns: the first entry of the list of queued events. + * Get the first entry of the list of queued events. + * + * Returns: a udev_list_entry. **/ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue) { @@ -435,7 +458,7 @@ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_qu snprintf(seqnum_str, sizeof(seqnum_str), "%llu", seqnum); s = syspath; - l = util_strpcpy(&s, sizeof(syspath), "/sys"); + l = strpcpy(&s, sizeof(syspath), "/sys"); len = udev_queue_read_devpath(queue_file, s, l); if (len < 0) break; @@ -444,7 +467,7 @@ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_qu udev_list_entry_add(&udev_queue->queue_list, syspath, seqnum_str); } else { udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_queue->queue_list)) { - if (strcmp(seqnum_str, udev_list_entry_get_value(list_entry)) == 0) { + if (streq(seqnum_str, udev_list_entry_get_value(list_entry))) { udev_list_entry_delete(list_entry); break; } @@ -455,11 +478,3 @@ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_qu return udev_list_get_entry(&udev_queue->queue_list); } - -struct udev_list_entry *udev_queue_get_failed_list_entry(struct udev_queue *udev_queue); -_public_ struct udev_list_entry *udev_queue_get_failed_list_entry(struct udev_queue *udev_queue) -{ - err(udev_queue->udev, "udev_queue_get_failed_list_entry() does not return anything; failed events are not recorded\n"); - errno = ENOSYS; - return NULL; -}