Discussion:
[PATCH 0/2] Polish document
Chengwei Yang
2013-04-24 08:19:53 UTC
Permalink
There are two patches for kmod documentation, the first fix several minor bugs
and the second one is a relative large change. It add more document for
exported enums.

Chengwei Yang (2):
Several minor fixes for documentation
Add document about exported enum definitions

libkmod/docs/libkmod-sections.txt | 6 +++
libkmod/libkmod-module.c | 89 ++++++++++++++++++++++++++++++-------
libkmod/libkmod.c | 23 +++++++---
libkmod/libkmod.h | 32 ++++++-------
4 files changed, 113 insertions(+), 37 deletions(-)
--
1.7.9.5
Chengwei Yang
2013-04-24 08:19:55 UTC
Permalink
There are several exported enum by libkmod without document, so this
patch mainly added documentation for below enums:
* kmod_resources_status
* kmod_module_insert_flags
* kmod_module_remove_flags
* kmod_module_probe_flags
* kmod_filter
* kmod_module_initstate

Signed-off-by: Chengwei Yang <chengwei.yang-***@public.gmane.org>
---
libkmod/docs/libkmod-sections.txt | 6 +++
libkmod/libkmod-module.c | 79 ++++++++++++++++++++++++++++++++-----
libkmod/libkmod.c | 17 +++++---
libkmod/libkmod.h | 32 ++++++++-------
4 files changed, 105 insertions(+), 29 deletions(-)

diff --git a/libkmod/docs/libkmod-sections.txt b/libkmod/docs/libkmod-sections.txt
index e59ab7a..d826daf 100644
--- a/libkmod/docs/libkmod-sections.txt
+++ b/libkmod/docs/libkmod-sections.txt
@@ -5,6 +5,7 @@ kmod_new
kmod_ref
kmod_unref

+kmod_resources_status
kmod_load_resources
kmod_unload_resources
kmod_validate_resources
@@ -53,13 +54,17 @@ kmod_module_ref
kmod_module_unref
kmod_module_unref_list

+kmod_module_insert_flags
kmod_module_insert_module
+kmod_module_probe_flags
kmod_module_probe_insert_module
+kmod_module_remove_flags
kmod_module_remove_module

kmod_module_get_module
kmod_module_get_dependencies
kmod_module_get_softdeps
+kmod_filter
kmod_module_apply_filter
kmod_module_get_filtered_blacklist
kmod_module_get_install_commands
@@ -98,6 +103,7 @@ kmod_module_info_get_value
<SECTION>
<FILE>libkmod-loaded</FILE>
kmod_module_new_from_loaded
+kmod_module_initstate
kmod_module_get_initstate
kmod_module_initstate_str
kmod_module_get_size
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 4754eeb..6086379 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -581,6 +581,15 @@ KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
}

/**
+ * kmod_filter:
+ * @KMOD_FILTER_BLACKLIST: filter modules in blacklist out
+ * @KMOD_FILTER_BUILTIN: filter builtin modules out
+ *
+ * kmod module filter flags, used to filter modules, used by
+ * kmod_module_apply_filter().
+ */
+
+/**
* kmod_module_get_filtered_blacklist:
* @ctx: kmod library context
* @input: list of kmod_module to be filtered with blacklist
@@ -736,9 +745,18 @@ KMOD_EXPORT const char *kmod_module_get_path(const struct kmod_module *mod)
extern long delete_module(const char *name, unsigned int flags);

/**
+ * kmod_module_remove_flags:
+ * @KMOD_REMOVE_FORCE: force remove module regardless its reference count
+ * @KMOD_REMOVE_NOWAIT: return immediately
+ *
+ * kmod module flags used by kmod_module_remove_module().
+ */
+
+/**
* kmod_module_remove_module:
* @mod: kmod module
- * @flags: flags to pass to Linux kernel when removing the module
+ * @flags: flags to pass to Linux kernel when removing the module,
+ * see #kmod_module_remove_flags.
*
* Remove a module from Linux kernel.
*
@@ -767,10 +785,19 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod,
extern long init_module(const void *mem, unsigned long len, const char *args);

/**
+ * kmod_module_insert_flags:
+ * @KMOD_INSERT_FORCE_VERMAGIC: remove version magic to force insert module
+ * @KMOD_INSERT_FORCE_MODVERSION: remove interface version to force insert module
+ * insert module
+ *
+ * kmod module flags used by kmod_module_insert_module().
+ */
+
+/**
* kmod_module_insert_module:
* @mod: kmod module
* @flags: flags are not passed to Linux Kernel, but instead they dictate the
- * behavior of this function.
+ * behavior of this function. See #kmod_module_insert_flags.
* @options: module's options to pass to Linux Kernel.
*
* Insert a module in Linux kernel. It opens the file pointed by @mod,
@@ -879,7 +906,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
/**
* kmod_module_apply_filter
* @ctx: kmod library context
- * @filter_type: bitmask to filter modules on
+ * @filter_type: bitmask to filter modules out, see #kmod_filter.
* @input: list of kmod_module to be filtered
* @output: where to save the new list
*
@@ -890,7 +917,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
* list.
*/
KMOD_EXPORT int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
+ kmod_filter filter_type,
const struct kmod_list *input,
struct kmod_list **output)
{
@@ -1147,10 +1174,31 @@ static int kmod_module_get_probe_list(struct kmod_module *mod,
}

/**
+ * kmod_module_probe_flags:
+ * @KMOD_PROBE_FORCE_VERMAGIC: remove version magic to force insert module
+ * @KMOD_PROBE_FORCE_MODVERSION: remove interface version to force insert module
+ * @KMOD_PROBE_IGNORE_COMMAND: whether the module's command and softdep should
+ * be ignored
+ * @KMOD_PROBE_IGNORE_LOADED: do not check whether the module is already live in
+ * kernel or not
+ * @KMOD_PROBE_DRY_RUN: dry run, do not insert module
+ * @KMOD_PROBE_FAIL_ON_LOADED: if KMOD_PROBE_IGNORE_LOADED not specified and
+ * the module is already live in kernel, the function will fail if this flag
+ * specified
+ * @KMOD_PROBE_APPLY_BLACKLIST_ALL: probe will fail if the module is in
+ * blacklist
+ * @KMOD_PROBE_APPLY_BLACKLIST: probe will fail if the module is in blacklist
+ * @KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY: probe will fail if the module is an
+ * alias and in blacklist
+ *
+ * kmod module probe flags used by kmod_module_probe_insert_module().
+ */
+
+/**
* kmod_module_probe_insert_module:
* @mod: kmod module
* @flags: flags are not passed to Linux Kernel, but instead they dictate the
- * behavior of this function.
+ * behavior of this function. See #kmod_module_probe_flags.
* @extra_options: module's options to pass to Linux Kernel. It applies only
* to @mod, not to its dependencies.
* @run_install: function to run when @mod is backed by an install command.
@@ -1619,15 +1667,28 @@ KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx,
}

/**
+ * kmod_module_initstate:
+ * @KMOD_MODULE_BUILTIN: module is builtin
+ * @KMOD_MODULE_LIVE: module is live in kernel
+ * @KMOD_MODULE_COMING: module is being loaded
+ * @KMOD_MODULE_GOING: module is being unloaded
+ * @_KMOD_MODULE_PAD: do not use it
+ *
+ * kmod module init state, used by kmod_module_get_initstate()
+ * and kmod_module_initstate_str().
+ */
+
+/**
* kmod_module_initstate_str:
- * @state: the state as returned by kmod_module_get_initstate()
+ * @state: the state as returned by kmod_module_get_initstate(), see
+ * #kmod_module_initstate.
*
* Translate a initstate to a string.
*
* Returns: the string associated to the @state. This string is statically
* allocated, do not free it.
*/
-KMOD_EXPORT const char *kmod_module_initstate_str(enum kmod_module_initstate state)
+KMOD_EXPORT const char *kmod_module_initstate_str(kmod_module_initstate state)
{
switch (state) {
case KMOD_MODULE_BUILTIN:
@@ -1650,7 +1711,7 @@ KMOD_EXPORT const char *kmod_module_initstate_str(enum kmod_module_initstate sta
* Get the initstate of this @mod, as returned by Linux Kernel, by reading
* /sys filesystem.
*
- * Returns: < 0 on error or enum kmod_initstate if module is found in kernel.
+ * Returns: < 0 on error or #kmod_module_initstate if module is found in kernel.
*/
KMOD_EXPORT int kmod_module_get_initstate(const struct kmod_module *mod)
{
@@ -2378,7 +2439,7 @@ list_error:
}

/**
- * kmod_module_versions_get_symbol:
+ * kmod_module_version_get_symbol:
* @entry: a list entry representing a kmod module versions
*
* Get the symbol of a kmod module versions.
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 1113614..98cf15e 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -48,6 +48,16 @@
* and is passed to all library operations.
*/

+/**
+ * kmod_resources_status:
+ * @KMOD_RESOURCES_OK: kmod resources are still valid
+ * @KMOD_RESOURCES_MUST_RELOAD: kmod resources are sufficient to call
+ * kmod_load_resources() and kmod_unload_resources()
+ * @KMOD_RESOURCES_MUST_RECREATE: kmod resources #kmod_ctx must be re-created.
+ *
+ * kmod resources status, see kmod_load_resources(), kmod_unload_resources()
+ * and kmod_validate_resources().
+ */
static struct _index_files {
const char *fn;
const char *prefix;
@@ -740,12 +750,9 @@ static bool is_cache_invalid(const char *path, unsigned long long stamp)
* Check if indexes and configuration files changed on disk and the current
* context is not valid anymore.
*
- * Returns: KMOD_RESOURCES_OK if resources are still valid,
- * KMOD_RESOURCES_MUST_RELOAD if it's sufficient to call
- * kmod_unload_resources() and kmod_load_resources() or
- * KMOD_RESOURCES_MUST_RECREATE if @ctx must be re-created.
+ * Returns: kmod resources status, see #kmod_resources_status
*/
-KMOD_EXPORT int kmod_validate_resources(struct kmod_ctx *ctx)
+KMOD_EXPORT kmod_resources_status kmod_validate_resources(struct kmod_ctx *ctx)
{
struct kmod_list *l;
size_t i;
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 3397f87..c1bec07 100644
--- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h
@@ -59,13 +59,15 @@ void kmod_set_userdata(struct kmod_ctx *ctx, const void *userdata);
int kmod_load_resources(struct kmod_ctx *ctx);
void kmod_unload_resources(struct kmod_ctx *ctx);

-enum kmod_resources {
+/* kmod resources status */
+typedef enum {
KMOD_RESOURCES_OK = 0,
KMOD_RESOURCES_MUST_RELOAD = 1,
KMOD_RESOURCES_MUST_RECREATE = 2,
-};
-int kmod_validate_resources(struct kmod_ctx *ctx);
+} kmod_resources_status;
+kmod_resources_status kmod_validate_resources(struct kmod_ctx *ctx);

+/* kmod module type */
enum kmod_index {
KMOD_INDEX_MODULES_DEP = 0,
KMOD_INDEX_MODULES_ALIAS,
@@ -138,19 +140,19 @@ struct kmod_module *kmod_module_get_module(const struct kmod_list *entry);


/* Removal flags */
-enum kmod_remove {
+typedef enum {
KMOD_REMOVE_FORCE = O_TRUNC,
KMOD_REMOVE_NOWAIT = O_NONBLOCK,
-};
+} kmod_module_remove_flags;

/* Insertion flags */
-enum kmod_insert {
+typedef enum {
KMOD_INSERT_FORCE_VERMAGIC = 0x1,
KMOD_INSERT_FORCE_MODVERSION = 0x2,
-};
+} kmod_module_insert_flags;

/* Flags to kmod_module_probe_insert_module() */
-enum kmod_probe {
+typedef enum {
KMOD_PROBE_FORCE_VERMAGIC = 0x00001,
KMOD_PROBE_FORCE_MODVERSION = 0x00002,
KMOD_PROBE_IGNORE_COMMAND = 0x00004,
@@ -162,13 +164,13 @@ enum kmod_probe {
KMOD_PROBE_APPLY_BLACKLIST_ALL = 0x10000,
KMOD_PROBE_APPLY_BLACKLIST = 0x20000,
KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY = 0x40000,
-};
+} kmod_module_probe_flags;

/* Flags to kmod_module_apply_filter() */
-enum kmod_filter {
+typedef enum {
KMOD_FILTER_BLACKLIST = 0x00001,
KMOD_FILTER_BUILTIN = 0x00002,
-};
+} kmod_filter;

int kmod_module_remove_module(struct kmod_module *mod, unsigned int flags);
int kmod_module_insert_module(struct kmod_module *mod, unsigned int flags,
@@ -194,7 +196,7 @@ int kmod_module_get_filtered_blacklist(const struct kmod_ctx *ctx,
const struct kmod_list *input,
struct kmod_list **output) __attribute__ ((deprecated));
int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
+ kmod_filter filter_type,
const struct kmod_list *input,
struct kmod_list **output);

@@ -205,15 +207,15 @@ int kmod_module_apply_filter(const struct kmod_ctx *ctx,
* by kernel
*/

-enum kmod_module_initstate {
+typedef enum {
KMOD_MODULE_BUILTIN = 0,
KMOD_MODULE_LIVE,
KMOD_MODULE_COMING,
KMOD_MODULE_GOING,
/* Padding to make sure enum is not mapped to char */
_KMOD_MODULE_PAD = (1 << 31),
-};
-const char *kmod_module_initstate_str(enum kmod_module_initstate state);
+} kmod_module_initstate;
+const char *kmod_module_initstate_str(kmod_module_initstate state);
int kmod_module_get_initstate(const struct kmod_module *mod);
int kmod_module_get_refcnt(const struct kmod_module *mod);
struct kmod_list *kmod_module_get_holders(const struct kmod_module *mod);
--
1.7.9.5
Lucas De Marchi
2013-04-25 04:19:16 UTC
Permalink
Post by Chengwei Yang
There are several exported enum by libkmod without document, so this
* kmod_resources_status
* kmod_module_insert_flags
* kmod_module_remove_flags
* kmod_module_probe_flags
* kmod_filter
* kmod_module_initstate
---
libkmod/docs/libkmod-sections.txt | 6 +++
libkmod/libkmod-module.c | 79 ++++++++++++++++++++++++++++++++-----
libkmod/libkmod.c | 17 +++++---
libkmod/libkmod.h | 32 ++++++++-------
4 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/libkmod/docs/libkmod-sections.txt b/libkmod/docs/libkmod-sections.txt
index e59ab7a..d826daf 100644
--- a/libkmod/docs/libkmod-sections.txt
+++ b/libkmod/docs/libkmod-sections.txt
@@ -5,6 +5,7 @@ kmod_new
kmod_ref
kmod_unref
+kmod_resources_status
kmod_load_resources
kmod_unload_resources
kmod_validate_resources
@@ -53,13 +54,17 @@ kmod_module_ref
kmod_module_unref
kmod_module_unref_list
+kmod_module_insert_flags
kmod_module_insert_module
+kmod_module_probe_flags
kmod_module_probe_insert_module
+kmod_module_remove_flags
kmod_module_remove_module
kmod_module_get_module
kmod_module_get_dependencies
kmod_module_get_softdeps
+kmod_filter
kmod_module_apply_filter
kmod_module_get_filtered_blacklist
kmod_module_get_install_commands
@@ -98,6 +103,7 @@ kmod_module_info_get_value
<SECTION>
<FILE>libkmod-loaded</FILE>
kmod_module_new_from_loaded
+kmod_module_initstate
kmod_module_get_initstate
kmod_module_initstate_str
kmod_module_get_size
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 4754eeb..6086379 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -581,6 +581,15 @@ KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
}
/**
+ *
+ * kmod module filter flags, used to filter modules, used by
+ * kmod_module_apply_filter().
+ */
+
+/**
@@ -736,9 +745,18 @@ KMOD_EXPORT const char *kmod_module_get_path(const struct kmod_module *mod)
extern long delete_module(const char *name, unsigned int flags);
/**
Humn... this is ambiguous since user might think this is related to
the kmod_module reference count, which it isn't. Please make it
explicit like: "force module removal regardless if it's still in use
by a kernel subsystem or other process"
Actually we'd like to deprecate *not* using this flag so it might
become the default in a future version. See rmmod, it's already
warning the user that the "-w" flag is deprecated. Could you be a bit
more verbose here?
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_remove_module().
+ */
+
+/**
+ * see #kmod_module_remove_flags.
*
* Remove a module from Linux kernel.
*
@@ -767,10 +785,19 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod,
extern long init_module(const void *mem, unsigned long len, const char *args);
/**
+ * insert module
I think it's weird to call this "interface". Maybe do like is done in
init_module man page:

"Ignore symbol version hashes"
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_insert_module().
+ */
+
+/**
- * behavior of this function.
+ * behavior of this function. See #kmod_module_insert_flags.
*
@@ -879,7 +906,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
/**
* kmod_module_apply_filter
*
@@ -890,7 +917,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
* list.
*/
KMOD_EXPORT int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
Is this a limitation in gtk-doc that it can't generate the doc if it's
not typedef'ed? I don't think so...

We don't use typedefs in kmod and actually mixing this change in a
commit that says to be about adding doc is pretty bad.
Post by Chengwei Yang
+ kmod_filter filter_type,
const struct kmod_list *input,
struct kmod_list **output)
{
@@ -1147,10 +1174,31 @@ static int kmod_module_get_probe_list(struct kmod_module *mod,
}
/**
ditto.
Post by Chengwei Yang
+ * be ignored
whether the probe should ignore install commands and softdeps
configured in the system
Post by Chengwei Yang
+ * kernel or not
@KMOD_PROBE_DRY_RUN: dry run, do not insert module, just call the
associated callback function
Post by Chengwei Yang
+ * the module is already live in kernel, the function will fail if this flag
+ * specified
some verbs missing:

@KMOD_PROBE_FAIL_ON_LOADED: if KMOD_PROBE_IGNORE_LOADED is not
specified and the module is already live in kernel, the function will
fail if this flag is specified.
Post by Chengwei Yang
+ * blacklist
probe will apply KMOD_FILTER_BLACKLIST filter to this module and its
dependencies. This will most likely fail the probe, unless a
blacklisted module is already loaded.
ok
Post by Chengwei Yang
+ * alias and in blacklist
and is blacklisted
Post by Chengwei Yang
+ *
+ * kmod module probe flags used by kmod_module_probe_insert_module().
+ */
+
+/**
- * behavior of this function.
+ * behavior of this function. See #kmod_module_probe_flags.
@@ -1619,15 +1667,28 @@ KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx,
}
/**
+ *
+ * kmod module init state, used by kmod_module_get_initstate()
+ * and kmod_module_initstate_str().
+ */
+
+/**
+ * #kmod_module_initstate.
*
* Translate a initstate to a string.
*
* allocated, do not free it.
*/
-KMOD_EXPORT const char *kmod_module_initstate_str(enum kmod_module_initstate state)
+KMOD_EXPORT const char *kmod_module_initstate_str(kmod_module_initstate state)
{
switch (state) {
@@ -1650,7 +1711,7 @@ KMOD_EXPORT const char *kmod_module_initstate_str(enum kmod_module_initstate sta
* /sys filesystem.
*
- * Returns: < 0 on error or enum kmod_initstate if module is found in kernel.
+ * Returns: < 0 on error or #kmod_module_initstate if module is found in kernel.
*/
KMOD_EXPORT int kmod_module_get_initstate(const struct kmod_module *mod)
{
}
/**
*
* Get the symbol of a kmod module versions.
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 1113614..98cf15e 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -48,6 +48,16 @@
* and is passed to all library operations.
*/
+/**
+ * kmod_load_resources() and kmod_unload_resources()
+ *
+ * kmod resources status, see kmod_load_resources(), kmod_unload_resources()
+ * and kmod_validate_resources().
+ */
static struct _index_files {
const char *fn;
const char *prefix;
@@ -740,12 +750,9 @@ static bool is_cache_invalid(const char *path, unsigned long long stamp)
* Check if indexes and configuration files changed on disk and the current
* context is not valid anymore.
*
- * Returns: KMOD_RESOURCES_OK if resources are still valid,
- * KMOD_RESOURCES_MUST_RELOAD if it's sufficient to call
- * kmod_unload_resources() and kmod_load_resources() or
+ * Returns: kmod resources status, see #kmod_resources_status
*/
-KMOD_EXPORT int kmod_validate_resources(struct kmod_ctx *ctx)
+KMOD_EXPORT kmod_resources_status kmod_validate_resources(struct kmod_ctx *ctx)
we can't change the API right now, so keep it as int, but you can
document it like you did.
Post by Chengwei Yang
{
struct kmod_list *l;
size_t i;
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 3397f87..c1bec07 100644
--- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h
@@ -59,13 +59,15 @@ void kmod_set_userdata(struct kmod_ctx *ctx, const void *userdata);
int kmod_load_resources(struct kmod_ctx *ctx);
void kmod_unload_resources(struct kmod_ctx *ctx);
-enum kmod_resources {
+/* kmod resources status */
+typedef enum {
KMOD_RESOURCES_OK = 0,
KMOD_RESOURCES_MUST_RELOAD = 1,
KMOD_RESOURCES_MUST_RECREATE = 2,
-};
-int kmod_validate_resources(struct kmod_ctx *ctx);
+} kmod_resources_status;
+kmod_resources_status kmod_validate_resources(struct kmod_ctx *ctx);
+/* kmod module type */
enum kmod_index {
KMOD_INDEX_MODULES_DEP = 0,
KMOD_INDEX_MODULES_ALIAS,
@@ -138,19 +140,19 @@ struct kmod_module *kmod_module_get_module(const struct kmod_list *entry);
/* Removal flags */
-enum kmod_remove {
+typedef enum {
KMOD_REMOVE_FORCE = O_TRUNC,
KMOD_REMOVE_NOWAIT = O_NONBLOCK,
-};
+} kmod_module_remove_flags;
/* Insertion flags */
-enum kmod_insert {
+typedef enum {
KMOD_INSERT_FORCE_VERMAGIC = 0x1,
KMOD_INSERT_FORCE_MODVERSION = 0x2,
-};
+} kmod_module_insert_flags;
/* Flags to kmod_module_probe_insert_module() */
-enum kmod_probe {
+typedef enum {
KMOD_PROBE_FORCE_VERMAGIC = 0x00001,
KMOD_PROBE_FORCE_MODVERSION = 0x00002,
KMOD_PROBE_IGNORE_COMMAND = 0x00004,
@@ -162,13 +164,13 @@ enum kmod_probe {
KMOD_PROBE_APPLY_BLACKLIST_ALL = 0x10000,
KMOD_PROBE_APPLY_BLACKLIST = 0x20000,
KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY = 0x40000,
-};
+} kmod_module_probe_flags;
/* Flags to kmod_module_apply_filter() */
-enum kmod_filter {
+typedef enum {
KMOD_FILTER_BLACKLIST = 0x00001,
KMOD_FILTER_BUILTIN = 0x00002,
-};
+} kmod_filter;
int kmod_module_remove_module(struct kmod_module *mod, unsigned int flags);
int kmod_module_insert_module(struct kmod_module *mod, unsigned int flags,
@@ -194,7 +196,7 @@ int kmod_module_get_filtered_blacklist(const struct kmod_ctx *ctx,
const struct kmod_list *input,
struct kmod_list **output) __attribute__ ((deprecated));
int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
+ kmod_filter filter_type,
const struct kmod_list *input,
struct kmod_list **output);
@@ -205,15 +207,15 @@ int kmod_module_apply_filter(const struct kmod_ctx *ctx,
* by kernel
*/
-enum kmod_module_initstate {
+typedef enum {
KMOD_MODULE_BUILTIN = 0,
KMOD_MODULE_LIVE,
KMOD_MODULE_COMING,
KMOD_MODULE_GOING,
/* Padding to make sure enum is not mapped to char */
_KMOD_MODULE_PAD = (1 << 31),
-};
-const char *kmod_module_initstate_str(enum kmod_module_initstate state);
+} kmod_module_initstate;
+const char *kmod_module_initstate_str(kmod_module_initstate state);
int kmod_module_get_initstate(const struct kmod_module *mod);
int kmod_module_get_refcnt(const struct kmod_module *mod);
struct kmod_list *kmod_module_get_holders(const struct kmod_module *mod);
--
Lucas De Marchi
Yang Chengwei
2013-04-25 05:18:37 UTC
Permalink
Post by Lucas De Marchi
Post by Chengwei Yang
There are several exported enum by libkmod without document, so this
* kmod_resources_status
* kmod_module_insert_flags
* kmod_module_remove_flags
* kmod_module_probe_flags
* kmod_filter
* kmod_module_initstate
---
libkmod/docs/libkmod-sections.txt | 6 +++
libkmod/libkmod-module.c | 79 ++++++++++++++++++++++++++++++++-----
libkmod/libkmod.c | 17 +++++---
libkmod/libkmod.h | 32 ++++++++-------
4 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/libkmod/docs/libkmod-sections.txt b/libkmod/docs/libkmod-sections.txt
index e59ab7a..d826daf 100644
--- a/libkmod/docs/libkmod-sections.txt
+++ b/libkmod/docs/libkmod-sections.txt
@@ -5,6 +5,7 @@ kmod_new
kmod_ref
kmod_unref
+kmod_resources_status
kmod_load_resources
kmod_unload_resources
kmod_validate_resources
@@ -53,13 +54,17 @@ kmod_module_ref
kmod_module_unref
kmod_module_unref_list
+kmod_module_insert_flags
kmod_module_insert_module
+kmod_module_probe_flags
kmod_module_probe_insert_module
+kmod_module_remove_flags
kmod_module_remove_module
kmod_module_get_module
kmod_module_get_dependencies
kmod_module_get_softdeps
+kmod_filter
kmod_module_apply_filter
kmod_module_get_filtered_blacklist
kmod_module_get_install_commands
@@ -98,6 +103,7 @@ kmod_module_info_get_value
<SECTION>
<FILE>libkmod-loaded</FILE>
kmod_module_new_from_loaded
+kmod_module_initstate
kmod_module_get_initstate
kmod_module_initstate_str
kmod_module_get_size
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 4754eeb..6086379 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -581,6 +581,15 @@ KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
}
/**
+ *
+ * kmod module filter flags, used to filter modules, used by
+ * kmod_module_apply_filter().
+ */
+
+/**
@@ -736,9 +745,18 @@ KMOD_EXPORT const char *kmod_module_get_path(const struct kmod_module *mod)
extern long delete_module(const char *name, unsigned int flags);
/**
Humn... this is ambiguous since user might think this is related to
the kmod_module reference count, which it isn't. Please make it
explicit like: "force module removal regardless if it's still in use
by a kernel subsystem or other process"
Actually we'd like to deprecate *not* using this flag so it might
become the default in a future version. See rmmod, it's already
warning the user that the "-w" flag is deprecated. Could you be a bit
Yes, I noticed, I originally think there is a bug since there is no help
info for "-w, --wait".

Do we need that?
Post by Lucas De Marchi
more verbose here?
Sure.

--
Thanks,
Chengwei
Post by Lucas De Marchi
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_remove_module().
+ */
+
+/**
+ * see #kmod_module_remove_flags.
*
* Remove a module from Linux kernel.
*
@@ -767,10 +785,19 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod,
extern long init_module(const void *mem, unsigned long len, const char *args);
/**
+ * insert module
I think it's weird to call this "interface". Maybe do like is done in
"Ignore symbol version hashes"
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_insert_module().
+ */
+
+/**
- * behavior of this function.
+ * behavior of this function. See #kmod_module_insert_flags.
*
@@ -879,7 +906,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
/**
* kmod_module_apply_filter
*
@@ -890,7 +917,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
* list.
*/
KMOD_EXPORT int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
Is this a limitation in gtk-doc that it can't generate the doc if it's
not typedef'ed? I don't think so...
We don't use typedefs in kmod and actually mixing this change in a
commit that says to be about adding doc is pretty bad.
Post by Chengwei Yang
+ kmod_filter filter_type,
const struct kmod_list *input,
struct kmod_list **output)
{
@@ -1147,10 +1174,31 @@ static int kmod_module_get_probe_list(struct kmod_module *mod,
}
/**
ditto.
Post by Chengwei Yang
+ * be ignored
whether the probe should ignore install commands and softdeps
configured in the system
Post by Chengwei Yang
+ * kernel or not
@KMOD_PROBE_DRY_RUN: dry run, do not insert module, just call the
associated callback function
Post by Chengwei Yang
+ * the module is already live in kernel, the function will fail if this flag
+ * specified
@KMOD_PROBE_FAIL_ON_LOADED: if KMOD_PROBE_IGNORE_LOADED is not
specified and the module is already live in kernel, the function will
fail if this flag is specified.
Post by Chengwei Yang
+ * blacklist
probe will apply KMOD_FILTER_BLACKLIST filter to this module and its
dependencies. This will most likely fail the probe, unless a
blacklisted module is already loaded.
ok
Post by Chengwei Yang
+ * alias and in blacklist
and is blacklisted
Post by Chengwei Yang
+ *
+ * kmod module probe flags used by kmod_module_probe_insert_module().
+ */
+
+/**
- * behavior of this function.
+ * behavior of this function. See #kmod_module_probe_flags.
@@ -1619,15 +1667,28 @@ KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx,
}
/**
+ *
+ * kmod module init state, used by kmod_module_get_initstate()
+ * and kmod_module_initstate_str().
+ */
+
+/**
+ * #kmod_module_initstate.
*
* Translate a initstate to a string.
*
* allocated, do not free it.
*/
-KMOD_EXPORT const char *kmod_module_initstate_str(enum kmod_module_initstate state)
+KMOD_EXPORT const char *kmod_module_initstate_str(kmod_module_initstate state)
{
switch (state) {
@@ -1650,7 +1711,7 @@ KMOD_EXPORT const char *kmod_module_initstate_str(enum kmod_module_initstate sta
* /sys filesystem.
*
- * Returns: < 0 on error or enum kmod_initstate if module is found in kernel.
+ * Returns: < 0 on error or #kmod_module_initstate if module is found in kernel.
*/
KMOD_EXPORT int kmod_module_get_initstate(const struct kmod_module *mod)
{
}
/**
*
* Get the symbol of a kmod module versions.
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 1113614..98cf15e 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -48,6 +48,16 @@
* and is passed to all library operations.
*/
+/**
+ * kmod_load_resources() and kmod_unload_resources()
+ *
+ * kmod resources status, see kmod_load_resources(), kmod_unload_resources()
+ * and kmod_validate_resources().
+ */
static struct _index_files {
const char *fn;
const char *prefix;
@@ -740,12 +750,9 @@ static bool is_cache_invalid(const char *path, unsigned long long stamp)
* Check if indexes and configuration files changed on disk and the current
* context is not valid anymore.
*
- * Returns: KMOD_RESOURCES_OK if resources are still valid,
- * KMOD_RESOURCES_MUST_RELOAD if it's sufficient to call
- * kmod_unload_resources() and kmod_load_resources() or
+ * Returns: kmod resources status, see #kmod_resources_status
*/
-KMOD_EXPORT int kmod_validate_resources(struct kmod_ctx *ctx)
+KMOD_EXPORT kmod_resources_status kmod_validate_resources(struct kmod_ctx *ctx)
we can't change the API right now, so keep it as int, but you can
document it like you did.
Post by Chengwei Yang
{
struct kmod_list *l;
size_t i;
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 3397f87..c1bec07 100644
--- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h
@@ -59,13 +59,15 @@ void kmod_set_userdata(struct kmod_ctx *ctx, const void *userdata);
int kmod_load_resources(struct kmod_ctx *ctx);
void kmod_unload_resources(struct kmod_ctx *ctx);
-enum kmod_resources {
+/* kmod resources status */
+typedef enum {
KMOD_RESOURCES_OK = 0,
KMOD_RESOURCES_MUST_RELOAD = 1,
KMOD_RESOURCES_MUST_RECREATE = 2,
-};
-int kmod_validate_resources(struct kmod_ctx *ctx);
+} kmod_resources_status;
+kmod_resources_status kmod_validate_resources(struct kmod_ctx *ctx);
+/* kmod module type */
enum kmod_index {
KMOD_INDEX_MODULES_DEP = 0,
KMOD_INDEX_MODULES_ALIAS,
@@ -138,19 +140,19 @@ struct kmod_module *kmod_module_get_module(const struct kmod_list *entry);
/* Removal flags */
-enum kmod_remove {
+typedef enum {
KMOD_REMOVE_FORCE = O_TRUNC,
KMOD_REMOVE_NOWAIT = O_NONBLOCK,
-};
+} kmod_module_remove_flags;
/* Insertion flags */
-enum kmod_insert {
+typedef enum {
KMOD_INSERT_FORCE_VERMAGIC = 0x1,
KMOD_INSERT_FORCE_MODVERSION = 0x2,
-};
+} kmod_module_insert_flags;
/* Flags to kmod_module_probe_insert_module() */
-enum kmod_probe {
+typedef enum {
KMOD_PROBE_FORCE_VERMAGIC = 0x00001,
KMOD_PROBE_FORCE_MODVERSION = 0x00002,
KMOD_PROBE_IGNORE_COMMAND = 0x00004,
@@ -162,13 +164,13 @@ enum kmod_probe {
KMOD_PROBE_APPLY_BLACKLIST_ALL = 0x10000,
KMOD_PROBE_APPLY_BLACKLIST = 0x20000,
KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY = 0x40000,
-};
+} kmod_module_probe_flags;
/* Flags to kmod_module_apply_filter() */
-enum kmod_filter {
+typedef enum {
KMOD_FILTER_BLACKLIST = 0x00001,
KMOD_FILTER_BUILTIN = 0x00002,
-};
+} kmod_filter;
int kmod_module_remove_module(struct kmod_module *mod, unsigned int flags);
int kmod_module_insert_module(struct kmod_module *mod, unsigned int flags,
@@ -194,7 +196,7 @@ int kmod_module_get_filtered_blacklist(const struct kmod_ctx *ctx,
const struct kmod_list *input,
struct kmod_list **output) __attribute__ ((deprecated));
int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
+ kmod_filter filter_type,
const struct kmod_list *input,
struct kmod_list **output);
@@ -205,15 +207,15 @@ int kmod_module_apply_filter(const struct kmod_ctx *ctx,
* by kernel
*/
-enum kmod_module_initstate {
+typedef enum {
KMOD_MODULE_BUILTIN = 0,
KMOD_MODULE_LIVE,
KMOD_MODULE_COMING,
KMOD_MODULE_GOING,
/* Padding to make sure enum is not mapped to char */
_KMOD_MODULE_PAD = (1 << 31),
-};
-const char *kmod_module_initstate_str(enum kmod_module_initstate state);
+} kmod_module_initstate;
+const char *kmod_module_initstate_str(kmod_module_initstate state);
int kmod_module_get_initstate(const struct kmod_module *mod);
int kmod_module_get_refcnt(const struct kmod_module *mod);
struct kmod_list *kmod_module_get_holders(const struct kmod_module *mod);
--
Lucas De Marchi
Lucas De Marchi
2013-04-25 05:33:59 UTC
Permalink
Post by Yang Chengwei
Post by Lucas De Marchi
Post by Chengwei Yang
There are several exported enum by libkmod without document, so this
* kmod_resources_status
* kmod_module_insert_flags
* kmod_module_remove_flags
* kmod_module_probe_flags
* kmod_filter
* kmod_module_initstate
---
libkmod/docs/libkmod-sections.txt | 6 +++
libkmod/libkmod-module.c | 79 ++++++++++++++++++++++++++++++++-----
libkmod/libkmod.c | 17 +++++---
libkmod/libkmod.h | 32 ++++++++-------
4 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/libkmod/docs/libkmod-sections.txt b/libkmod/docs/libkmod-sections.txt
index e59ab7a..d826daf 100644
--- a/libkmod/docs/libkmod-sections.txt
+++ b/libkmod/docs/libkmod-sections.txt
@@ -5,6 +5,7 @@ kmod_new
kmod_ref
kmod_unref
+kmod_resources_status
kmod_load_resources
kmod_unload_resources
kmod_validate_resources
@@ -53,13 +54,17 @@ kmod_module_ref
kmod_module_unref
kmod_module_unref_list
+kmod_module_insert_flags
kmod_module_insert_module
+kmod_module_probe_flags
kmod_module_probe_insert_module
+kmod_module_remove_flags
kmod_module_remove_module
kmod_module_get_module
kmod_module_get_dependencies
kmod_module_get_softdeps
+kmod_filter
kmod_module_apply_filter
kmod_module_get_filtered_blacklist
kmod_module_get_install_commands
@@ -98,6 +103,7 @@ kmod_module_info_get_value
<SECTION>
<FILE>libkmod-loaded</FILE>
kmod_module_new_from_loaded
+kmod_module_initstate
kmod_module_get_initstate
kmod_module_initstate_str
kmod_module_get_size
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 4754eeb..6086379 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -581,6 +581,15 @@ KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
}
/**
+ *
+ * kmod module filter flags, used to filter modules, used by
+ * kmod_module_apply_filter().
+ */
+
+/**
@@ -736,9 +745,18 @@ KMOD_EXPORT const char *kmod_module_get_path(const struct kmod_module *mod)
extern long delete_module(const char *name, unsigned int flags);
/**
Humn... this is ambiguous since user might think this is related to
the kmod_module reference count, which it isn't. Please make it
explicit like: "force module removal regardless if it's still in use
by a kernel subsystem or other process"
Actually we'd like to deprecate *not* using this flag so it might
become the default in a future version. See rmmod, it's already
warning the user that the "-w" flag is deprecated. Could you be a bit
Yes, I noticed, I originally think there is a bug since there is no help
info for "-w, --wait".
Do we need that?
It's removed from the help on purpose, so we don't get new users of
this option. See: cc833644b2193d661e4a9c06c047d1a527f3ecf4

But we need to let the option there for more some time, in case there
are still users that didn't notice it the 10s delay yet. Or that
didn't upgrade... I think Debian is still on kmod-9.
Post by Yang Chengwei
Post by Lucas De Marchi
more verbose here?
If this module is in use by any kernel subsystem or process, not using
this flag will cause the call to block indefinitely, until the module
is not in use anymore. Always use this flag, it's deprecated not using
it and the default behavior might change in future to always set it.

Lucas De Marchi
Yang Chengwei
2013-04-25 05:44:21 UTC
Permalink
Post by Lucas De Marchi
It's removed from the help on purpose, so we don't get new users of
this option. See: cc833644b2193d661e4a9c06c047d1a527f3ecf4
But we need to let the option there for more some time, in case there
are still users that didn't notice it the 10s delay yet. Or that
didn't upgrade... I think Debian is still on kmod-9.
I'm using Debian Squeeze, module-init-tools is in using. :-(. Seems
Wheezy will released with kmod-9.
Post by Lucas De Marchi
Post by Lucas De Marchi
more verbose here?
If this module is in use by any kernel subsystem or process, not using
this flag will cause the call to block indefinitely, until the module
is not in use anymore. Always use this flag, it's deprecated not using
it and the default behavior might change in future to always set it.
Yeah, it's verbose than mine and the delete_module(2).

--
Thanks,
Chengwei
Post by Lucas De Marchi
Lucas De Marchi
Yang Chengwei
2013-04-27 02:38:27 UTC
Permalink
Post by Lucas De Marchi
Post by Chengwei Yang
There are several exported enum by libkmod without document, so this
* kmod_resources_status
* kmod_module_insert_flags
* kmod_module_remove_flags
* kmod_module_probe_flags
* kmod_filter
* kmod_module_initstate
---
libkmod/docs/libkmod-sections.txt | 6 +++
libkmod/libkmod-module.c | 79 ++++++++++++++++++++++++++++++++-----
libkmod/libkmod.c | 17 +++++---
libkmod/libkmod.h | 32 ++++++++-------
4 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/libkmod/docs/libkmod-sections.txt b/libkmod/docs/libkmod-sections.txt
index e59ab7a..d826daf 100644
--- a/libkmod/docs/libkmod-sections.txt
+++ b/libkmod/docs/libkmod-sections.txt
@@ -5,6 +5,7 @@ kmod_new
kmod_ref
kmod_unref
+kmod_resources_status
kmod_load_resources
kmod_unload_resources
kmod_validate_resources
@@ -53,13 +54,17 @@ kmod_module_ref
kmod_module_unref
kmod_module_unref_list
+kmod_module_insert_flags
kmod_module_insert_module
+kmod_module_probe_flags
kmod_module_probe_insert_module
+kmod_module_remove_flags
kmod_module_remove_module
kmod_module_get_module
kmod_module_get_dependencies
kmod_module_get_softdeps
+kmod_filter
kmod_module_apply_filter
kmod_module_get_filtered_blacklist
kmod_module_get_install_commands
@@ -98,6 +103,7 @@ kmod_module_info_get_value
<SECTION>
<FILE>libkmod-loaded</FILE>
kmod_module_new_from_loaded
+kmod_module_initstate
kmod_module_get_initstate
kmod_module_initstate_str
kmod_module_get_size
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 4754eeb..6086379 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -581,6 +581,15 @@ KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
}
/**
+ *
+ * kmod module filter flags, used to filter modules, used by
+ * kmod_module_apply_filter().
+ */
+
+/**
@@ -736,9 +745,18 @@ KMOD_EXPORT const char *kmod_module_get_path(const struct kmod_module *mod)
extern long delete_module(const char *name, unsigned int flags);
/**
Humn... this is ambiguous since user might think this is related to
the kmod_module reference count, which it isn't. Please make it
explicit like: "force module removal regardless if it's still in use
by a kernel subsystem or other process"
Actually we'd like to deprecate *not* using this flag so it might
become the default in a future version. See rmmod, it's already
warning the user that the "-w" flag is deprecated. Could you be a bit
more verbose here?
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_remove_module().
+ */
+
+/**
+ * see #kmod_module_remove_flags.
*
* Remove a module from Linux kernel.
*
@@ -767,10 +785,19 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod,
extern long init_module(const void *mem, unsigned long len, const char *args);
/**
+ * insert module
I think it's weird to call this "interface". Maybe do like is done in
"Ignore symbol version hashes"
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_insert_module().
+ */
+
+/**
- * behavior of this function.
+ * behavior of this function. See #kmod_module_insert_flags.
*
@@ -879,7 +906,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
/**
* kmod_module_apply_filter
*
@@ -890,7 +917,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
* list.
*/
KMOD_EXPORT int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
Is this a limitation in gtk-doc that it can't generate the doc if it's
not typedef'ed? I don't think so...
I feel sorry to say that's true from my understand. It recognize
typedef'ed enum and enum _foo {...}; In the later the document generated
also say enum foo (no underscore), it's wrong if there is no typedef
enum _foo foo since in fact no enum foo here.

For detail, please refer to https://bugzilla.gnome.org/show_bug.cgi?id=657444

So due to this limitation, the workaround I could say is use typedef as
below:

typedef enum foo {
...
} foo;

Is that acceptable to you? If no, I think I'll drop the second patch
which try to document the exported enums.

--
Thanks,
Chengwei
Post by Lucas De Marchi
We don't use typedefs in kmod and actually mixing this change in a
commit that says to be about adding doc is pretty bad.
Post by Chengwei Yang
+ kmod_filter filter_type,
const struct kmod_list *input,
struct kmod_list **output)
{
@@ -1147,10 +1174,31 @@ static int kmod_module_get_probe_list(struct kmod_module *mod,
}
/**
ditto.
Post by Chengwei Yang
+ * be ignored
whether the probe should ignore install commands and softdeps
configured in the system
Post by Chengwei Yang
+ * kernel or not
@KMOD_PROBE_DRY_RUN: dry run, do not insert module, just call the
associated callback function
Post by Chengwei Yang
+ * the module is already live in kernel, the function will fail if this flag
+ * specified
@KMOD_PROBE_FAIL_ON_LOADED: if KMOD_PROBE_IGNORE_LOADED is not
specified and the module is already live in kernel, the function will
fail if this flag is specified.
Post by Chengwei Yang
+ * blacklist
probe will apply KMOD_FILTER_BLACKLIST filter to this module and its
dependencies. This will most likely fail the probe, unless a
blacklisted module is already loaded.
ok
Post by Chengwei Yang
+ * alias and in blacklist
and is blacklisted
Post by Chengwei Yang
+ *
+ * kmod module probe flags used by kmod_module_probe_insert_module().
+ */
+
+/**
- * behavior of this function.
+ * behavior of this function. See #kmod_module_probe_flags.
@@ -1619,15 +1667,28 @@ KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx,
}
/**
+ *
+ * kmod module init state, used by kmod_module_get_initstate()
+ * and kmod_module_initstate_str().
+ */
+
+/**
+ * #kmod_module_initstate.
*
* Translate a initstate to a string.
*
* allocated, do not free it.
*/
-KMOD_EXPORT const char *kmod_module_initstate_str(enum kmod_module_initstate state)
+KMOD_EXPORT const char *kmod_module_initstate_str(kmod_module_initstate state)
{
switch (state) {
@@ -1650,7 +1711,7 @@ KMOD_EXPORT const char *kmod_module_initstate_str(enum kmod_module_initstate sta
* /sys filesystem.
*
- * Returns: < 0 on error or enum kmod_initstate if module is found in kernel.
+ * Returns: < 0 on error or #kmod_module_initstate if module is found in kernel.
*/
KMOD_EXPORT int kmod_module_get_initstate(const struct kmod_module *mod)
{
}
/**
*
* Get the symbol of a kmod module versions.
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 1113614..98cf15e 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -48,6 +48,16 @@
* and is passed to all library operations.
*/
+/**
+ * kmod_load_resources() and kmod_unload_resources()
+ *
+ * kmod resources status, see kmod_load_resources(), kmod_unload_resources()
+ * and kmod_validate_resources().
+ */
static struct _index_files {
const char *fn;
const char *prefix;
@@ -740,12 +750,9 @@ static bool is_cache_invalid(const char *path, unsigned long long stamp)
* Check if indexes and configuration files changed on disk and the current
* context is not valid anymore.
*
- * Returns: KMOD_RESOURCES_OK if resources are still valid,
- * KMOD_RESOURCES_MUST_RELOAD if it's sufficient to call
- * kmod_unload_resources() and kmod_load_resources() or
+ * Returns: kmod resources status, see #kmod_resources_status
*/
-KMOD_EXPORT int kmod_validate_resources(struct kmod_ctx *ctx)
+KMOD_EXPORT kmod_resources_status kmod_validate_resources(struct kmod_ctx *ctx)
we can't change the API right now, so keep it as int, but you can
document it like you did.
Post by Chengwei Yang
{
struct kmod_list *l;
size_t i;
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 3397f87..c1bec07 100644
--- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h
@@ -59,13 +59,15 @@ void kmod_set_userdata(struct kmod_ctx *ctx, const void *userdata);
int kmod_load_resources(struct kmod_ctx *ctx);
void kmod_unload_resources(struct kmod_ctx *ctx);
-enum kmod_resources {
+/* kmod resources status */
+typedef enum {
KMOD_RESOURCES_OK = 0,
KMOD_RESOURCES_MUST_RELOAD = 1,
KMOD_RESOURCES_MUST_RECREATE = 2,
-};
-int kmod_validate_resources(struct kmod_ctx *ctx);
+} kmod_resources_status;
+kmod_resources_status kmod_validate_resources(struct kmod_ctx *ctx);
+/* kmod module type */
enum kmod_index {
KMOD_INDEX_MODULES_DEP = 0,
KMOD_INDEX_MODULES_ALIAS,
@@ -138,19 +140,19 @@ struct kmod_module *kmod_module_get_module(const struct kmod_list *entry);
/* Removal flags */
-enum kmod_remove {
+typedef enum {
KMOD_REMOVE_FORCE = O_TRUNC,
KMOD_REMOVE_NOWAIT = O_NONBLOCK,
-};
+} kmod_module_remove_flags;
/* Insertion flags */
-enum kmod_insert {
+typedef enum {
KMOD_INSERT_FORCE_VERMAGIC = 0x1,
KMOD_INSERT_FORCE_MODVERSION = 0x2,
-};
+} kmod_module_insert_flags;
/* Flags to kmod_module_probe_insert_module() */
-enum kmod_probe {
+typedef enum {
KMOD_PROBE_FORCE_VERMAGIC = 0x00001,
KMOD_PROBE_FORCE_MODVERSION = 0x00002,
KMOD_PROBE_IGNORE_COMMAND = 0x00004,
@@ -162,13 +164,13 @@ enum kmod_probe {
KMOD_PROBE_APPLY_BLACKLIST_ALL = 0x10000,
KMOD_PROBE_APPLY_BLACKLIST = 0x20000,
KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY = 0x40000,
-};
+} kmod_module_probe_flags;
/* Flags to kmod_module_apply_filter() */
-enum kmod_filter {
+typedef enum {
KMOD_FILTER_BLACKLIST = 0x00001,
KMOD_FILTER_BUILTIN = 0x00002,
-};
+} kmod_filter;
int kmod_module_remove_module(struct kmod_module *mod, unsigned int flags);
int kmod_module_insert_module(struct kmod_module *mod, unsigned int flags,
@@ -194,7 +196,7 @@ int kmod_module_get_filtered_blacklist(const struct kmod_ctx *ctx,
const struct kmod_list *input,
struct kmod_list **output) __attribute__ ((deprecated));
int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
+ kmod_filter filter_type,
const struct kmod_list *input,
struct kmod_list **output);
@@ -205,15 +207,15 @@ int kmod_module_apply_filter(const struct kmod_ctx *ctx,
* by kernel
*/
-enum kmod_module_initstate {
+typedef enum {
KMOD_MODULE_BUILTIN = 0,
KMOD_MODULE_LIVE,
KMOD_MODULE_COMING,
KMOD_MODULE_GOING,
/* Padding to make sure enum is not mapped to char */
_KMOD_MODULE_PAD = (1 << 31),
-};
-const char *kmod_module_initstate_str(enum kmod_module_initstate state);
+} kmod_module_initstate;
+const char *kmod_module_initstate_str(kmod_module_initstate state);
int kmod_module_get_initstate(const struct kmod_module *mod);
int kmod_module_get_refcnt(const struct kmod_module *mod);
struct kmod_list *kmod_module_get_holders(const struct kmod_module *mod);
--
Lucas De Marchi
Lucas De Marchi
2013-04-27 03:24:43 UTC
Permalink
Post by Yang Chengwei
Post by Lucas De Marchi
Post by Chengwei Yang
There are several exported enum by libkmod without document, so this
* kmod_resources_status
* kmod_module_insert_flags
* kmod_module_remove_flags
* kmod_module_probe_flags
* kmod_filter
* kmod_module_initstate
---
libkmod/docs/libkmod-sections.txt | 6 +++
libkmod/libkmod-module.c | 79 ++++++++++++++++++++++++++++++++-----
libkmod/libkmod.c | 17 +++++---
libkmod/libkmod.h | 32 ++++++++-------
4 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/libkmod/docs/libkmod-sections.txt b/libkmod/docs/libkmod-sections.txt
index e59ab7a..d826daf 100644
--- a/libkmod/docs/libkmod-sections.txt
+++ b/libkmod/docs/libkmod-sections.txt
@@ -5,6 +5,7 @@ kmod_new
kmod_ref
kmod_unref
+kmod_resources_status
kmod_load_resources
kmod_unload_resources
kmod_validate_resources
@@ -53,13 +54,17 @@ kmod_module_ref
kmod_module_unref
kmod_module_unref_list
+kmod_module_insert_flags
kmod_module_insert_module
+kmod_module_probe_flags
kmod_module_probe_insert_module
+kmod_module_remove_flags
kmod_module_remove_module
kmod_module_get_module
kmod_module_get_dependencies
kmod_module_get_softdeps
+kmod_filter
kmod_module_apply_filter
kmod_module_get_filtered_blacklist
kmod_module_get_install_commands
@@ -98,6 +103,7 @@ kmod_module_info_get_value
<SECTION>
<FILE>libkmod-loaded</FILE>
kmod_module_new_from_loaded
+kmod_module_initstate
kmod_module_get_initstate
kmod_module_initstate_str
kmod_module_get_size
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 4754eeb..6086379 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -581,6 +581,15 @@ KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
}
/**
+ *
+ * kmod module filter flags, used to filter modules, used by
+ * kmod_module_apply_filter().
+ */
+
+/**
@@ -736,9 +745,18 @@ KMOD_EXPORT const char *kmod_module_get_path(const struct kmod_module *mod)
extern long delete_module(const char *name, unsigned int flags);
/**
Humn... this is ambiguous since user might think this is related to
the kmod_module reference count, which it isn't. Please make it
explicit like: "force module removal regardless if it's still in use
by a kernel subsystem or other process"
Actually we'd like to deprecate *not* using this flag so it might
become the default in a future version. See rmmod, it's already
warning the user that the "-w" flag is deprecated. Could you be a bit
more verbose here?
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_remove_module().
+ */
+
+/**
+ * see #kmod_module_remove_flags.
*
* Remove a module from Linux kernel.
*
@@ -767,10 +785,19 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod,
extern long init_module(const void *mem, unsigned long len, const char *args);
/**
+ * insert module
I think it's weird to call this "interface". Maybe do like is done in
"Ignore symbol version hashes"
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_insert_module().
+ */
+
+/**
- * behavior of this function.
+ * behavior of this function. See #kmod_module_insert_flags.
*
@@ -879,7 +906,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
/**
* kmod_module_apply_filter
*
@@ -890,7 +917,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
* list.
*/
KMOD_EXPORT int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
Is this a limitation in gtk-doc that it can't generate the doc if it's
not typedef'ed? I don't think so...
I feel sorry to say that's true from my understand. It recognize
typedef'ed enum and enum _foo {...}; In the later the document generated
also say enum foo (no underscore), it's wrong if there is no typedef
enum _foo foo since in fact no enum foo here.
For detail, please refer to https://bugzilla.gnome.org/show_bug.cgi?id=657444
So due to this limitation, the workaround I could say is use typedef as
typedef enum foo {
...
} foo;
Is that acceptable to you? If no, I think I'll drop the second patch
which try to document the exported enums.
It's not acceptable in the public header and throughout the source
code. Since this is a limitation of gtk-doc and that in C you can add
the typedef anywhere, what could be done is to document these enums
hidden in the end of the respective .c file. And throughout the source
code we continue to use "enum ...". So you wouldn't touch the header,
but would have this, for example in the ende of
libkmod/libkmod-module.c:


/** kmod_module_probe_flags:
* @KMOD_PROBE_FORCE_VERMAGIC: remove version magic to force insert module
* @KMOD_PROBE_FORCE_MODVERSION: remove interface version to force insert module
* ...
*/
typedef enum kmod_module_probe_flags kmod_module_probe_flags;

Lucas De Marchi
Lucas De Marchi
2013-04-27 03:29:46 UTC
Permalink
On Sat, Apr 27, 2013 at 12:24 AM, Lucas De Marchi
Post by Lucas De Marchi
Post by Yang Chengwei
Post by Lucas De Marchi
Post by Chengwei Yang
There are several exported enum by libkmod without document, so this
* kmod_resources_status
* kmod_module_insert_flags
* kmod_module_remove_flags
* kmod_module_probe_flags
* kmod_filter
* kmod_module_initstate
---
libkmod/docs/libkmod-sections.txt | 6 +++
libkmod/libkmod-module.c | 79 ++++++++++++++++++++++++++++++++-----
libkmod/libkmod.c | 17 +++++---
libkmod/libkmod.h | 32 ++++++++-------
4 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/libkmod/docs/libkmod-sections.txt b/libkmod/docs/libkmod-sections.txt
index e59ab7a..d826daf 100644
--- a/libkmod/docs/libkmod-sections.txt
+++ b/libkmod/docs/libkmod-sections.txt
@@ -5,6 +5,7 @@ kmod_new
kmod_ref
kmod_unref
+kmod_resources_status
kmod_load_resources
kmod_unload_resources
kmod_validate_resources
@@ -53,13 +54,17 @@ kmod_module_ref
kmod_module_unref
kmod_module_unref_list
+kmod_module_insert_flags
kmod_module_insert_module
+kmod_module_probe_flags
kmod_module_probe_insert_module
+kmod_module_remove_flags
kmod_module_remove_module
kmod_module_get_module
kmod_module_get_dependencies
kmod_module_get_softdeps
+kmod_filter
kmod_module_apply_filter
kmod_module_get_filtered_blacklist
kmod_module_get_install_commands
@@ -98,6 +103,7 @@ kmod_module_info_get_value
<SECTION>
<FILE>libkmod-loaded</FILE>
kmod_module_new_from_loaded
+kmod_module_initstate
kmod_module_get_initstate
kmod_module_initstate_str
kmod_module_get_size
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 4754eeb..6086379 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -581,6 +581,15 @@ KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
}
/**
+ *
+ * kmod module filter flags, used to filter modules, used by
+ * kmod_module_apply_filter().
+ */
+
+/**
@@ -736,9 +745,18 @@ KMOD_EXPORT const char *kmod_module_get_path(const struct kmod_module *mod)
extern long delete_module(const char *name, unsigned int flags);
/**
Humn... this is ambiguous since user might think this is related to
the kmod_module reference count, which it isn't. Please make it
explicit like: "force module removal regardless if it's still in use
by a kernel subsystem or other process"
Actually we'd like to deprecate *not* using this flag so it might
become the default in a future version. See rmmod, it's already
warning the user that the "-w" flag is deprecated. Could you be a bit
more verbose here?
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_remove_module().
+ */
+
+/**
+ * see #kmod_module_remove_flags.
*
* Remove a module from Linux kernel.
*
@@ -767,10 +785,19 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod,
extern long init_module(const void *mem, unsigned long len, const char *args);
/**
+ * insert module
I think it's weird to call this "interface". Maybe do like is done in
"Ignore symbol version hashes"
Post by Chengwei Yang
+ *
+ * kmod module flags used by kmod_module_insert_module().
+ */
+
+/**
- * behavior of this function.
+ * behavior of this function. See #kmod_module_insert_flags.
*
@@ -879,7 +906,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
/**
* kmod_module_apply_filter
*
@@ -890,7 +917,7 @@ static bool module_is_blacklisted(struct kmod_module *mod)
* list.
*/
KMOD_EXPORT int kmod_module_apply_filter(const struct kmod_ctx *ctx,
- enum kmod_filter filter_type,
Is this a limitation in gtk-doc that it can't generate the doc if it's
not typedef'ed? I don't think so...
I feel sorry to say that's true from my understand. It recognize
typedef'ed enum and enum _foo {...}; In the later the document generated
also say enum foo (no underscore), it's wrong if there is no typedef
enum _foo foo since in fact no enum foo here.
For detail, please refer to https://bugzilla.gnome.org/show_bug.cgi?id=657444
So due to this limitation, the workaround I could say is use typedef as
typedef enum foo {
...
} foo;
Is that acceptable to you? If no, I think I'll drop the second patch
which try to document the exported enums.
It's not acceptable in the public header and throughout the source
code. Since this is a limitation of gtk-doc and that in C you can add
the typedef anywhere, what could be done is to document these enums
hidden in the end of the respective .c file. And throughout the source
code we continue to use "enum ...". So you wouldn't touch the header,
but would have this, for example in the ende of
* ...
*/
typedef enum kmod_module_probe_flags kmod_module_probe_flags;
oh... and don't rename the enums, otherwise we break the API. This one
should be "enum kmod_probe", not kmod_module_probe_flags.


Lucas De Marchi
Yang Chengwei
2013-04-27 04:03:20 UTC
Permalink
Post by Lucas De Marchi
On Sat, Apr 27, 2013 at 12:24 AM, Lucas De Marchi
Post by Lucas De Marchi
It's not acceptable in the public header and throughout the source
code. Since this is a limitation of gtk-doc and that in C you can add
the typedef anywhere, what could be done is to document these enums
hidden in the end of the respective .c file. And throughout the source
code we continue to use "enum ...". So you wouldn't touch the header,
but would have this, for example in the ende of
* ...
*/
typedef enum kmod_module_probe_flags kmod_module_probe_flags;
oh... and don't rename the enums, otherwise we break the API. This one
should be "enum kmod_probe", not kmod_module_probe_flags.
Sure, that's fine.

--
Thanks,
Chengwei
Post by Lucas De Marchi
Lucas De Marchi
Yang Chengwei
2013-04-27 04:02:24 UTC
Permalink
Post by Lucas De Marchi
Post by Yang Chengwei
I feel sorry to say that's true from my understand. It recognize
typedef'ed enum and enum _foo {...}; In the later the document generated
also say enum foo (no underscore), it's wrong if there is no typedef
enum _foo foo since in fact no enum foo here.
For detail, please refer to https://bugzilla.gnome.org/show_bug.cgi?id=657444
So due to this limitation, the workaround I could say is use typedef as
typedef enum foo {
...
} foo;
Is that acceptable to you? If no, I think I'll drop the second patch
which try to document the exported enums.
It's not acceptable in the public header and throughout the source
code. Since this is a limitation of gtk-doc and that in C you can add
the typedef anywhere, what could be done is to document these enums
hidden in the end of the respective .c file. And throughout the source
code we continue to use "enum ...". So you wouldn't touch the header,
but would have this, for example in the ende of
* ...
*/
typedef enum kmod_module_probe_flags kmod_module_probe_flags;
Hmm, I just checked the latest gtk-doc git repo. It has very limit
support for enum. Say it support:

1. plain enum named with underscore prefix.
enum _foo {
...
};

2. typedef'ed enum
typedef enum foo {
...
} foo;

3. another kind of typedef'ed enum
typedef enum _foo foo;
enum _foo {
...
};

Note the unerscore used here. So it doesn't support
typedef enum kmod_module_probe_flags kmod_module_probe_flags; :-(.

If I understand correctly, your goal is do not use typedef'ed enum like
foo but enum foo in source code. I agree with you and I think it's fine
with below:

typedef enum foo {
...
} foo;

We can still use "enum foo" in any place else. But unfortuately, user
will see that in docuement.

--
Thanks,
Chengwei
Post by Lucas De Marchi
Lucas De Marchi
Yang Chengwei
2013-04-27 04:47:52 UTC
Permalink
Post by Yang Chengwei
Post by Lucas De Marchi
Post by Yang Chengwei
I feel sorry to say that's true from my understand. It recognize
typedef'ed enum and enum _foo {...}; In the later the document generated
also say enum foo (no underscore), it's wrong if there is no typedef
enum _foo foo since in fact no enum foo here.
For detail, please refer to https://bugzilla.gnome.org/show_bug.cgi?id=657444
So due to this limitation, the workaround I could say is use typedef as
typedef enum foo {
...
} foo;
Is that acceptable to you? If no, I think I'll drop the second patch
which try to document the exported enums.
It's not acceptable in the public header and throughout the source
code. Since this is a limitation of gtk-doc and that in C you can add
the typedef anywhere, what could be done is to document these enums
hidden in the end of the respective .c file. And throughout the source
code we continue to use "enum ...". So you wouldn't touch the header,
but would have this, for example in the ende of
* ...
*/
typedef enum kmod_module_probe_flags kmod_module_probe_flags;
Hmm, I just checked the latest gtk-doc git repo. It has very limit
1. plain enum named with underscore prefix.
enum _foo {
...
};
2. typedef'ed enum
typedef enum foo {
...
} foo;
3. another kind of typedef'ed enum
typedef enum _foo foo;
enum _foo {
...
};
Note the unerscore used here. So it doesn't support
typedef enum kmod_module_probe_flags kmod_module_probe_flags; :-(.
If I understand correctly, your goal is do not use typedef'ed enum like
foo but enum foo in source code. I agree with you and I think it's fine
typedef enum foo {
...
} foo;
We can still use "enum foo" in any place else. But unfortuately, user
will see that in docuement.
In addition, the document shows in

typedef enum {
...
} foo;

rather than how it write in header

typedef enum foo {
...
} foo;

So the user will get clue to always use "foo" rather than "enum foo",
this just violate kmod coding style! I think I'm giving up the second
patch. :-(, any suggestion?

--
Thanks,
Chengwei
Post by Yang Chengwei
--
Thanks,
Chengwei
Post by Lucas De Marchi
Lucas De Marchi
Lucas De Marchi
2013-05-03 20:31:21 UTC
Permalink
Hi Yang,
Post by Yang Chengwei
Post by Yang Chengwei
Post by Lucas De Marchi
Post by Yang Chengwei
I feel sorry to say that's true from my understand. It recognize
typedef'ed enum and enum _foo {...}; In the later the document generated
also say enum foo (no underscore), it's wrong if there is no typedef
enum _foo foo since in fact no enum foo here.
For detail, please refer to https://bugzilla.gnome.org/show_bug.cgi?id=657444
So due to this limitation, the workaround I could say is use typedef as
typedef enum foo {
...
} foo;
Is that acceptable to you? If no, I think I'll drop the second patch
which try to document the exported enums.
It's not acceptable in the public header and throughout the source
code. Since this is a limitation of gtk-doc and that in C you can add
the typedef anywhere, what could be done is to document these enums
hidden in the end of the respective .c file. And throughout the source
code we continue to use "enum ...". So you wouldn't touch the header,
but would have this, for example in the ende of
* ...
*/
typedef enum kmod_module_probe_flags kmod_module_probe_flags;
Hmm, I just checked the latest gtk-doc git repo. It has very limit
1. plain enum named with underscore prefix.
enum _foo {
...
};
2. typedef'ed enum
typedef enum foo {
...
} foo;
3. another kind of typedef'ed enum
typedef enum _foo foo;
enum _foo {
...
};
Note the unerscore used here. So it doesn't support
typedef enum kmod_module_probe_flags kmod_module_probe_flags; :-(.
If I understand correctly, your goal is do not use typedef'ed enum like
foo but enum foo in source code. I agree with you and I think it's fine
typedef enum foo {
...
} foo;
We can still use "enum foo" in any place else. But unfortuately, user
will see that in docuement.
In addition, the document shows in
typedef enum {
...
} foo;
rather than how it write in header
typedef enum foo {
...
} foo;
So the user will get clue to always use "foo" rather than "enum foo",
this just violate kmod coding style! I think I'm giving up the second
patch. :-(, any suggestion?
In the header we can't add the typedefs, otherwise this would be
exported to the users and part of the API. If gtk-doc doesn't support
this:

libkmod.h:
enum kmod_filter {
....
}

libkmod-module.c:

/**
* doc...
*/
typedef enum kmod_filter kmod_filter;


Then I'd say to add your enum documentation on top of the functions
where they are used in .c. Then later either we figure out a way to
make it appear on gtk-doc (patching gtk-doc), or move away to another
better tool for generating doc, or we live with this documented only
in the .c file while the first options are not feasible.

I think the documentation your patch brings is way more important than
the way it's presented to the user.

regards,
Lucas De Marchi

Chengwei Yang
2013-04-24 08:19:54 UTC
Permalink
Signed-off-by: Chengwei Yang <chengwei.yang-***@public.gmane.org>
---
libkmod/libkmod-module.c | 10 ++++------
libkmod/libkmod.c | 6 ++++--
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 47d12ad..4754eeb 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -570,8 +570,7 @@ fail:
* Drop a reference of each kmod module in @list and releases the resources
* taken by the list itself.
*
- * Returns: NULL if @mod is NULL or if the module was released. Otherwise it
- * returns the passed @mod with its refcount decremented.
+ * Returns: 0
*/
KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
{
@@ -629,9 +628,8 @@ static const struct kmod_list *module_get_dependencies_noref(const struct kmod_m
* The result is cached in @mod, so subsequent calls to this function will
* return the already searched list of modules.
*
- * Returns: NULL on failure or if there are any dependencies. Otherwise it
- * returns a list of kmod modules that can be released by calling
- * kmod_module_unref_list().
+ * Returns: NULL on failure. Otherwise it returns a list of kmod modules
+ * that can be released by calling kmod_module_unref_list().
*/
KMOD_EXPORT struct kmod_list *kmod_module_get_dependencies(const struct kmod_module *mod)
{
@@ -1564,7 +1562,7 @@ void kmod_module_set_remove_commands(struct kmod_module *mod, const char *cmd)
* Create a new list of kmod modules with all modules currently loaded in
* kernel. It uses /proc/modules to get the names of loaded modules and to
* create kmod modules by calling kmod_module_new_from_name() in each of them.
- * They are put are put in @list in no particular order.
+ * They are put in @list in no particular order.
*
* The initial refcount is 1, and needs to be decremented to release the
* resources of the kmod_module. The returned @list must be released by
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 66d4859..1113614 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -219,8 +219,8 @@ static char *get_kernel_release(const char *dirname)
* kmod_new:
* @dirname: what to consider as linux module's directory, if NULL
* defaults to /lib/modules/`uname -r`. If it's relative,
- * it's treated as relative to current the current working
- * directory. Otherwise, give an absolute dirname.
+ * it's treated as relative to the current working directory.
+ * Otherwise, give an absolute dirname.
* @config_paths: ordered array of paths (directories or files) where
* to load from user-defined configuration parameters such as
* alias, blacklists, commands (install, remove). If
@@ -307,6 +307,8 @@ KMOD_EXPORT struct kmod_ctx *kmod_ref(struct kmod_ctx *ctx)
*
* Drop a reference of the kmod library context. If the refcount
* reaches zero, the resources of the context will be released.
+ *
+ * Returns: the passed kmod library context
*/
KMOD_EXPORT struct kmod_ctx *kmod_unref(struct kmod_ctx *ctx)
{
--
1.7.9.5
Lucas De Marchi
2013-04-25 03:34:11 UTC
Permalink
Hi Chengwei
First of all, we don't use s-o-b in kmod. Please remember this for the
next patches
Post by Chengwei Yang
---
libkmod/libkmod-module.c | 10 ++++------
libkmod/libkmod.c | 6 ++++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 47d12ad..4754eeb 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
* taken by the list itself.
*
+ * Returns: 0
*/
good catch.
Post by Chengwei Yang
KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
{
@@ -629,9 +628,8 @@ static const struct kmod_list *module_get_dependencies_noref(const struct kmod_m
* return the already searched list of modules.
*
- * Returns: NULL on failure or if there are any dependencies. Otherwise it
- * returns a list of kmod modules that can be released by calling
- * kmod_module_unref_list().
+ * Returns: NULL on failure. Otherwise it returns a list of kmod modules
Actually what was wrong was the use of "any". Returning NULL is not
necessarily a failure. Yes, it was a mistake doing a return like this
:(
Post by Chengwei Yang
+ * that can be released by calling kmod_module_unref_list().
*/
KMOD_EXPORT struct kmod_list *kmod_module_get_dependencies(const struct kmod_module *mod)
{
@@ -1564,7 +1562,7 @@ void kmod_module_set_remove_commands(struct kmod_module *mod, const char *cmd)
* Create a new list of kmod modules with all modules currently loaded in
* kernel. It uses /proc/modules to get the names of loaded modules and to
* create kmod modules by calling kmod_module_new_from_name() in each of them.
*
* The initial refcount is 1, and needs to be decremented to release the
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 66d4859..1113614 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -219,8 +219,8 @@ static char *get_kernel_release(const char *dirname)
* defaults to /lib/modules/`uname -r`. If it's relative,
- * it's treated as relative to current the current working
- * directory. Otherwise, give an absolute dirname.
+ * it's treated as relative to the current working directory.
+ * Otherwise, give an absolute dirname.
* to load from user-defined configuration parameters such as
* alias, blacklists, commands (install, remove). If
@@ -307,6 +307,8 @@ KMOD_EXPORT struct kmod_ctx *kmod_ref(struct kmod_ctx *ctx)
*
* Drop a reference of the kmod library context. If the refcount
* reaches zero, the resources of the context will be released.
+ *
+ * Returns: the passed kmod library context
or NULL if it's freed.
Post by Chengwei Yang
*/
KMOD_EXPORT struct kmod_ctx *kmod_unref(struct kmod_ctx *ctx)
{
--
thanks
Lucas De Marchi
Yang Chengwei
2013-04-25 03:54:58 UTC
Permalink
Post by Lucas De Marchi
Hi Chengwei
First of all, we don't use s-o-b in kmod. Please remember this for the
next patches
Sure.
Post by Lucas De Marchi
Post by Chengwei Yang
---
libkmod/libkmod-module.c | 10 ++++------
libkmod/libkmod.c | 6 ++++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 47d12ad..4754eeb 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
* taken by the list itself.
*
+ * Returns: 0
*/
good catch.
Thanks.
Post by Lucas De Marchi
Post by Chengwei Yang
KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
{
@@ -629,9 +628,8 @@ static const struct kmod_list *module_get_dependencies_noref(const struct kmod_m
* return the already searched list of modules.
*
- * Returns: NULL on failure or if there are any dependencies. Otherwise it
- * returns a list of kmod modules that can be released by calling
- * kmod_module_unref_list().
+ * Returns: NULL on failure. Otherwise it returns a list of kmod modules
Actually what was wrong was the use of "any". Returning NULL is not
necessarily a failure. Yes, it was a mistake doing a return like this
:(
Post by Chengwei Yang
+ * that can be released by calling kmod_module_unref_list().
*/
KMOD_EXPORT struct kmod_list *kmod_module_get_dependencies(const struct kmod_module *mod)
{
@@ -1564,7 +1562,7 @@ void kmod_module_set_remove_commands(struct kmod_module *mod, const char *cmd)
* Create a new list of kmod modules with all modules currently loaded in
* kernel. It uses /proc/modules to get the names of loaded modules and to
* create kmod modules by calling kmod_module_new_from_name() in each of them.
*
* The initial refcount is 1, and needs to be decremented to release the
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 66d4859..1113614 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -219,8 +219,8 @@ static char *get_kernel_release(const char *dirname)
* defaults to /lib/modules/`uname -r`. If it's relative,
- * it's treated as relative to current the current working
- * directory. Otherwise, give an absolute dirname.
+ * it's treated as relative to the current working directory.
+ * Otherwise, give an absolute dirname.
* to load from user-defined configuration parameters such as
* alias, blacklists, commands (install, remove). If
@@ -307,6 +307,8 @@ KMOD_EXPORT struct kmod_ctx *kmod_ref(struct kmod_ctx *ctx)
*
* Drop a reference of the kmod library context. If the refcount
* reaches zero, the resources of the context will be released.
+ *
+ * Returns: the passed kmod library context
or NULL if it's freed.
Yes, I just found that there are several places don't clarify NULL will
returned, so I follow the rule. :-). E.g. kmod_new, kmod_unref...

Would you like me to upload a V2 or just keep it as it?

--
Thanks,
Chengwei
Post by Lucas De Marchi
Post by Chengwei Yang
*/
KMOD_EXPORT struct kmod_ctx *kmod_unref(struct kmod_ctx *ctx)
{
--
thanks
Lucas De Marchi
Lucas De Marchi
2013-04-25 04:25:47 UTC
Permalink
Post by Yang Chengwei
Post by Lucas De Marchi
Hi Chengwei
First of all, we don't use s-o-b in kmod. Please remember this for the
next patches
Sure.
Post by Lucas De Marchi
Post by Chengwei Yang
---
libkmod/libkmod-module.c | 10 ++++------
libkmod/libkmod.c | 6 ++++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 47d12ad..4754eeb 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
* taken by the list itself.
*
+ * Returns: 0
*/
good catch.
Thanks.
Post by Lucas De Marchi
Post by Chengwei Yang
KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list)
{
@@ -629,9 +628,8 @@ static const struct kmod_list *module_get_dependencies_noref(const struct kmod_m
* return the already searched list of modules.
*
- * Returns: NULL on failure or if there are any dependencies. Otherwise it
- * returns a list of kmod modules that can be released by calling
- * kmod_module_unref_list().
+ * Returns: NULL on failure. Otherwise it returns a list of kmod modules
Actually what was wrong was the use of "any". Returning NULL is not
necessarily a failure. Yes, it was a mistake doing a return like this
:(
Post by Chengwei Yang
+ * that can be released by calling kmod_module_unref_list().
*/
KMOD_EXPORT struct kmod_list *kmod_module_get_dependencies(const struct kmod_module *mod)
{
@@ -1564,7 +1562,7 @@ void kmod_module_set_remove_commands(struct kmod_module *mod, const char *cmd)
* Create a new list of kmod modules with all modules currently loaded in
* kernel. It uses /proc/modules to get the names of loaded modules and to
* create kmod modules by calling kmod_module_new_from_name() in each of them.
*
* The initial refcount is 1, and needs to be decremented to release the
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 66d4859..1113614 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -219,8 +219,8 @@ static char *get_kernel_release(const char *dirname)
* defaults to /lib/modules/`uname -r`. If it's relative,
- * it's treated as relative to current the current working
- * directory. Otherwise, give an absolute dirname.
+ * it's treated as relative to the current working directory.
+ * Otherwise, give an absolute dirname.
* to load from user-defined configuration parameters such as
* alias, blacklists, commands (install, remove). If
@@ -307,6 +307,8 @@ KMOD_EXPORT struct kmod_ctx *kmod_ref(struct kmod_ctx *ctx)
*
* Drop a reference of the kmod library context. If the refcount
* reaches zero, the resources of the context will be released.
+ *
+ * Returns: the passed kmod library context
or NULL if it's freed.
Yes, I just found that there are several places don't clarify NULL will
returned, so I follow the rule. :-). E.g. kmod_new, kmod_unref...
Would you like me to upload a V2 or just keep it as it?
take a look on the other comments, also in the other patch and then submit a v2.

thanks
Lucas De Marchi
Loading...