lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 5 Nov 2007 13:42:03 +0100
From:	Cornelia Huck <cornelia.huck@...ibm.com>
To:	Greg Kroah-Hartman <gregkh@...e.de>
Cc:	linux-kernel@...r.kernel.org, Kay Sievers <kay.sievers@...y.org>,
	Greg Kroah-Hartman <gregkh@...e.de>
Subject: Re: [PATCH 34/54] Driver Core: add kobj_attribute handling

On Fri,  2 Nov 2007 16:59:12 -0700,
Greg Kroah-Hartman <gregkh@...e.de> wrote:

> From: Kay Sievers <kay.sievers@...y.org>
> 
> Add kobj_sysfs_ops to replace subsys_sysfs_ops. There is no
> need for special kset operations, we want to be able to use
> simple attribute operations at any kobject, not only ksets.
> 
> The whole concept of any default sysfs attribute operations
> will go away with the upcoming removal of subsys_sysfs_ops.
> 
> Signed-off-by: Kay Sievers <kay.sievers@...y.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@...e.de>
> ---
>  include/linux/kobject.h |   10 ++++++++++
>  lib/kobject.c           |   29 +++++++++++++++++++++++++++++
>  2 files changed, 39 insertions(+), 0 deletions(-)

How about adding some simple wrappers around the new kobj_attribute
structure? This makes the layering clearer.

Signed-off-by: Cornelia Huck <cornelia.huck@...ibm.com>
---
 include/linux/kobject.h |    7 ++++++-
 lib/kobject.c           |   22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

Index: linux-2.6/include/linux/kobject.h
===================================================================
--- linux-2.6.orig/include/linux/kobject.h	2007-11-05 11:12:49.000000000 +0100
+++ linux-2.6/include/linux/kobject.h	2007-11-05 13:24:55.000000000 +0100
@@ -126,7 +126,12 @@ struct kobj_attribute {
 	ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
 			 const char *buf, size_t count);
 };
-
+#define KOBJ_ATTR(_name,_mode,_show,_store)		\
+	struct kobj_attribute kobj_attr_##_name =	\
+		__ATTR(_name,_mode,_show,_store)
+extern int __must_check kobject_create_file(struct kobject *,
+					    struct kobj_attribute *);
+extern void kobject_remove_file(struct kobject *,struct kobj_attribute *);
 extern struct sysfs_ops kobj_sysfs_ops;
 
 /**
Index: linux-2.6/lib/kobject.c
===================================================================
--- linux-2.6.orig/lib/kobject.c	2007-11-05 11:12:49.000000000 +0100
+++ linux-2.6/lib/kobject.c	2007-11-05 13:36:45.000000000 +0100
@@ -577,6 +577,28 @@ struct sysfs_ops kobj_sysfs_ops = {
 	.store	= kobj_attr_store,
 };
 
+/**
+ * kobject_create_file() - create an attribute file for a kobject
+ * @kobj: kobject the attribute is created for
+ * @attr: attribute to be created
+ */
+int kobject_create_file(struct kobject *kobj, struct kobj_attribute *attr)
+{
+	return sysfs_create_file(kobj, &attr->attr);
+}
+EXPORT_SYMBOL_GPL(kobject_create_file);
+
+/**
+ * kobject_remove_file() - remove an attribute file from a kobject
+ * @kobj: kobject the attribute is removed from
+ * @attr: attribute to be removed
+ */
+void kobject_remove_file(struct kobject *kobj, struct kobj_attribute *attr)
+{
+	sysfs_remove_file(kobj, &attr->attr);
+}
+EXPORT_SYMBOL_GPL(kobject_remove_file);
+
 static void dir_release(struct kobject *kobj)
 {
 	kfree(kobj);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ