All of lore.kernel.org
 help / color / mirror / Atom feed
* [ANNOUNCE] udev 0.2 release
@ 2003-07-25 21:47 Greg KH
  2003-07-26  0:18 ` Joshua Schmidlkofer
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Greg KH @ 2003-07-25 21:47 UTC (permalink / raw)
  To: linux-hotplug

Hi,

I've released the 0.2 version of udev into the wild, after surviving a
live demo at the 2003 Ottawa Linux Symposium during a presentation.  It
can be found at:
	kernel.org/pub/linux/utils/kernel/hotplug/udev-0.2.tar.gz

udev is a implementation of devfs in userspace using sysfs and
/sbin/hotplug.  It requires a 2.5/2.6 kernel to run properly.  The major
changes since the last release is that persistent device naming schemes
are now implemented.  Yeah, it's pretty rough, but it does prove that
the concept is sane and will end up working well for users.

There's a BitKeeper tree of the latest stuff available at:
	bk://kernel.bkbits.net/gregkh/udev/

I've also placed the slides from my OLS talk up at:
	http://www.kroah.com/linux/talks/ols_2003_udev_talk/

The paper which attempts to explain the background of udev, what it
does, and where it is going is at:
	http://archive.linuxsymposium.org/ols2003/Proceedings/All-Reprints/Reprint-Kroah-Hartman-OLS2003.pdf


Due to the rush of the development of udev in this past week (hacking at
it during the conference in an attempt to have something to show) there
are still a number of very rough corners present, a few known memory
leaks, and at least one hard coded path to my home directory for a
config file...  Please feel free to take it for a spin to see how well
things are progressing.

Patches are always welcome, and discussions of the implementation, and
future directions that the project should entail are welcome for now on
the linux-hotplug-devel mailing list (if it's over-run, a new list will
be started up, but I don't think that's necessary for now.)

thanks,

greg k-h


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
@ 2003-07-26  0:18 ` Joshua Schmidlkofer
  2003-07-26 15:57 ` Greg KH
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Joshua Schmidlkofer @ 2003-07-26  0:18 UTC (permalink / raw)
  To: linux-hotplug

On Fri, 2003-07-25 at 14:47, Greg KH wrote:
> Hi,
> 
> I've released the 0.2 version of udev into the wild, after surviving a
> live demo at the 2003 Ottawa Linux Symposium during a presentation.  It
> can be found at:
> 	kernel.org/pub/linux/utils/kernel/hotplug/udev-0.2.tar.gz
> 
> udev is a implementation of devfs in userspace using sysfs and
> /sbin/hotplug.  It requires a 2.5/2.6 kernel to run properly.  The major
> changes since the last release is that persistent device naming schemes
> are now implemented.  Yeah, it's pretty rough, but it does prove that
> the concept is sane and will end up working well for users.
> 
> There's a BitKeeper tree of the latest stuff available at:
> 	bk://kernel.bkbits.net/gregkh/udev/
> 
> I've also placed the slides from my OLS talk up at:
> 	http://www.kroah.com/linux/talks/ols_2003_udev_talk/
> 
> The paper which attempts to explain the background of udev, what it
> does, and where it is going is at:
> 	http://archive.linuxsymposium.org/ols2003/Proceedings/All-Reprints/Reprint-Kroah-Hartman-OLS2003.pdf
> 
> 
> Due to the rush of the development of udev in this past week (hacking at
> it during the conference in an attempt to have something to show) there
> are still a number of very rough corners present, a few known memory
> leaks, and at least one hard coded path to my home directory for a
> config file...  Please feel free to take it for a spin to see how well
> things are progressing.
> 
> Patches are always welcome, and discussions of the implementation, and
> future directions that the project should entail are welcome for now on
> the linux-hotplug-devel mailing list (if it's over-run, a new list will
> be started up, but I don't think that's necessary for now.)
> 
> thanks,
> 
> greg k-h

This looks cool!   I was so excited about devfs when it was written.
Since then I;ve felt a huge sense of disappointment as the
implementation never quite became something cool as it could be.  

Since this is mostly userspace it looks awesome.  I have not looked at
anything besides your slides yet.  Will this affect existing apps?  Does
udev act as a /dev replacement, or will it actually need some app-level
work?

thanks,
   joshua



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
  2003-07-26  0:18 ` Joshua Schmidlkofer
@ 2003-07-26 15:57 ` Greg KH
  2003-07-31  7:46 ` Guo, Min
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2003-07-26 15:57 UTC (permalink / raw)
  To: linux-hotplug

On Fri, Jul 25, 2003 at 05:18:21PM -0700, Joshua Schmidlkofer wrote:
> 
> Since this is mostly userspace it looks awesome.

It is entirely userspace as we get the sysfs and /sbin/hotplug kernel
support in 2.6 anyway.

> I have not looked at
> anything besides your slides yet.  Will this affect existing apps?

In the default mode, no.  We need to provide the default kernel naming
scheme to comply with the Linux Standards Base and to prevent all older
apps from breaking.

> Does udev act as a /dev replacement, or will it actually need some
> app-level work?

Yes, it is a /dev replacement.
The only application work would be if a user starts to change their
naming scheme (to always name a specific printer a specific name), as
then the config file to point to a specific device would need to be
changed.  All applications should not have hard coded /dev entries, but
I'm sure there are some out there that are for some reason...

thanks,

greg k-h


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
  2003-07-26  0:18 ` Joshua Schmidlkofer
  2003-07-26 15:57 ` Greg KH
@ 2003-07-31  7:46 ` Guo, Min
  2003-07-31  7:47 ` Guo, Min
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Guo, Min @ 2003-07-31  7:46 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1782 bytes --]

Simple patch for udev mknod.


Thanks
Guo Min 
The content of this email message solely contains my own personal views,
and not those of my employer.

-----------------------------------------------------------------------------------------------------------------
--- /root/udev-0.2/udev-add.c	2003-07-24 23:54:49.000000000 +0800
+++ udev/udev-add.c	2003-07-31 16:35:14.277998152 +0800
@@ -81,35 +81,26 @@
  */
 static int create_node(char *name, char type, int major, int minor, int mode)
 {
-	char *argv[7];
-	char mode_string[100];
-	char type_string[3];
-	char major_string[20];
-	char minor_string[20];
 	char filename[255];
 	int retval = 0;
 
 	strncpy(filename, UDEV_ROOT, sizeof(filename));
 	strncat(filename, name, sizeof(filename));
+	if (type == 'b') {
+	       mode |= S_IFBLK;
+    	} else if ((type == 'c') || (type == 'u')){
+	        mode |= S_IFCHR;
+    	} else if ( type == 'p') {
+       		 mode |= S_IFIFO;
+    	} else {
+       		dbg("unknown node type %c\n", type);
+       		return -1;
+ 	}
 
-	snprintf(mode_string, sizeof(mode_string), "--mode=%#o", mode);
-	snprintf(type_string, sizeof(type_string), "%c", type);
-	snprintf(major_string, sizeof(major_string), "%d", major);
-	snprintf(minor_string, sizeof(minor_string), "%d", minor);
-	
-	argv[0] = MKNOD;
-	argv[1] = mode_string;
-	argv[2] = filename;
-	argv[3] = type_string;
-	argv[4] = major_string;
-	argv[5] = minor_string;
-	argv[6] = NULL;
-	dbg ("executing %s %s %s %s %s %s",
-		argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
 	switch (fork()) {
 		case 0:
 			/* we are the child, so lets run the program */
-			execv (MKNOD, argv);
+			mknod(filename,mode,makedev(major,minor));
 			exit(0);
 			break;
 		case (-1):



[-- Attachment #2: udev-add.c.diff --]
[-- Type: application/octet-stream, Size: 1455 bytes --]

--- /root/udev-0.2/udev-add.c	2003-07-24 23:54:49.000000000 +0800
+++ udev/udev-add.c	2003-07-31 16:35:14.277998152 +0800
@@ -81,35 +81,26 @@
  */
 static int create_node(char *name, char type, int major, int minor, int mode)
 {
-	char *argv[7];
-	char mode_string[100];
-	char type_string[3];
-	char major_string[20];
-	char minor_string[20];
 	char filename[255];
 	int retval = 0;
 
 	strncpy(filename, UDEV_ROOT, sizeof(filename));
 	strncat(filename, name, sizeof(filename));
+	if (type == 'b') {
+	       mode |= S_IFBLK;
+    	} else if ((type == 'c') || (type == 'u')){
+	        mode |= S_IFCHR;
+    	} else if ( type == 'p') {
+       		 mode |= S_IFIFO;
+    	} else {
+       		dbg("unknown node type %c\n", type);
+       		return -1;
+ 	}
 
-	snprintf(mode_string, sizeof(mode_string), "--mode=%#o", mode);
-	snprintf(type_string, sizeof(type_string), "%c", type);
-	snprintf(major_string, sizeof(major_string), "%d", major);
-	snprintf(minor_string, sizeof(minor_string), "%d", minor);
-	
-	argv[0] = MKNOD;
-	argv[1] = mode_string;
-	argv[2] = filename;
-	argv[3] = type_string;
-	argv[4] = major_string;
-	argv[5] = minor_string;
-	argv[6] = NULL;
-	dbg ("executing %s %s %s %s %s %s",
-		argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
 	switch (fork()) {
 		case 0:
 			/* we are the child, so lets run the program */
-			execv (MKNOD, argv);
+			mknod(filename,mode,makedev(major,minor));
 			exit(0);
 			break;
 		case (-1):

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
                   ` (2 preceding siblings ...)
  2003-07-31  7:46 ` Guo, Min
@ 2003-07-31  7:47 ` Guo, Min
  2003-07-31 23:04 ` Greg KH
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Guo, Min @ 2003-07-31  7:47 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1782 bytes --]

Simple patch for udev mknod.


Thanks
Guo Min 
The content of this email message solely contains my own personal views,
and not those of my employer.

-----------------------------------------------------------------------------------------------------------------
--- /root/udev-0.2/udev-add.c	2003-07-24 23:54:49.000000000 +0800
+++ udev/udev-add.c	2003-07-31 16:35:14.277998152 +0800
@@ -81,35 +81,26 @@
  */
 static int create_node(char *name, char type, int major, int minor, int mode)
 {
-	char *argv[7];
-	char mode_string[100];
-	char type_string[3];
-	char major_string[20];
-	char minor_string[20];
 	char filename[255];
 	int retval = 0;
 
 	strncpy(filename, UDEV_ROOT, sizeof(filename));
 	strncat(filename, name, sizeof(filename));
+	if (type == 'b') {
+	       mode |= S_IFBLK;
+    	} else if ((type == 'c') || (type == 'u')){
+	        mode |= S_IFCHR;
+    	} else if ( type == 'p') {
+       		 mode |= S_IFIFO;
+    	} else {
+       		dbg("unknown node type %c\n", type);
+       		return -1;
+ 	}
 
-	snprintf(mode_string, sizeof(mode_string), "--mode=%#o", mode);
-	snprintf(type_string, sizeof(type_string), "%c", type);
-	snprintf(major_string, sizeof(major_string), "%d", major);
-	snprintf(minor_string, sizeof(minor_string), "%d", minor);
-	
-	argv[0] = MKNOD;
-	argv[1] = mode_string;
-	argv[2] = filename;
-	argv[3] = type_string;
-	argv[4] = major_string;
-	argv[5] = minor_string;
-	argv[6] = NULL;
-	dbg ("executing %s %s %s %s %s %s",
-		argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
 	switch (fork()) {
 		case 0:
 			/* we are the child, so lets run the program */
-			execv (MKNOD, argv);
+			mknod(filename,mode,makedev(major,minor));
 			exit(0);
 			break;
 		case (-1):



[-- Attachment #2: udev-add.c.diff --]
[-- Type: application/octet-stream, Size: 1455 bytes --]

--- /root/udev-0.2/udev-add.c	2003-07-24 23:54:49.000000000 +0800
+++ udev/udev-add.c	2003-07-31 16:35:14.277998152 +0800
@@ -81,35 +81,26 @@
  */
 static int create_node(char *name, char type, int major, int minor, int mode)
 {
-	char *argv[7];
-	char mode_string[100];
-	char type_string[3];
-	char major_string[20];
-	char minor_string[20];
 	char filename[255];
 	int retval = 0;
 
 	strncpy(filename, UDEV_ROOT, sizeof(filename));
 	strncat(filename, name, sizeof(filename));
+	if (type == 'b') {
+	       mode |= S_IFBLK;
+    	} else if ((type == 'c') || (type == 'u')){
+	        mode |= S_IFCHR;
+    	} else if ( type == 'p') {
+       		 mode |= S_IFIFO;
+    	} else {
+       		dbg("unknown node type %c\n", type);
+       		return -1;
+ 	}
 
-	snprintf(mode_string, sizeof(mode_string), "--mode=%#o", mode);
-	snprintf(type_string, sizeof(type_string), "%c", type);
-	snprintf(major_string, sizeof(major_string), "%d", major);
-	snprintf(minor_string, sizeof(minor_string), "%d", minor);
-	
-	argv[0] = MKNOD;
-	argv[1] = mode_string;
-	argv[2] = filename;
-	argv[3] = type_string;
-	argv[4] = major_string;
-	argv[5] = minor_string;
-	argv[6] = NULL;
-	dbg ("executing %s %s %s %s %s %s",
-		argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
 	switch (fork()) {
 		case 0:
 			/* we are the child, so lets run the program */
-			execv (MKNOD, argv);
+			mknod(filename,mode,makedev(major,minor));
 			exit(0);
 			break;
 		case (-1):

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
                   ` (3 preceding siblings ...)
  2003-07-31  7:47 ` Guo, Min
@ 2003-07-31 23:04 ` Greg KH
  2003-08-01  0:48 ` Guo, Min
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2003-07-31 23:04 UTC (permalink / raw)
  To: linux-hotplug

On Thu, Jul 31, 2003 at 03:47:58PM +0800, Guo, Min wrote:
> Simple patch for udev mknod.

Why still fork() for this?  Can't we just call mknod() directly and then
return?

thanks,

greg k-h


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
                   ` (4 preceding siblings ...)
  2003-07-31 23:04 ` Greg KH
@ 2003-08-01  0:48 ` Guo, Min
  2003-08-05  0:19 ` Greg KH
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Guo, Min @ 2003-08-01  0:48 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1770 bytes --]

Thanks,the revised patch.
---------------------------------------------
--- /root/udev-0.2/udev-add.c	2003-07-24 23:54:49.000000000 +0800
+++ /udev/udev-add.c	2003-08-01 09:45:24.651393112 +0800
@@ -81,45 +81,24 @@
  */
 static int create_node(char *name, char type, int major, int minor, int mode)
 {
-	char *argv[7];
-	char mode_string[100];
-	char type_string[3];
-	char major_string[20];
-	char minor_string[20];
 	char filename[255];
 	int retval = 0;
-
 	strncpy(filename, UDEV_ROOT, sizeof(filename));
 	strncat(filename, name, sizeof(filename));
+	if (type == 'b') {
+	       mode |= S_IFBLK;
+    	} else if ((type == 'c') || (type == 'u')){
+	        mode |= S_IFCHR;
+    	} else if ( type == 'p') {
+       		 mode |= S_IFIFO;
+    	} else {
+       		dbg("unknown node type %c\n", type);
+       		return -1;
+ 	}
 
-	snprintf(mode_string, sizeof(mode_string), "--mode=%#o", mode);
-	snprintf(type_string, sizeof(type_string), "%c", type);
-	snprintf(major_string, sizeof(major_string), "%d", major);
-	snprintf(minor_string, sizeof(minor_string), "%d", minor);
-	
-	argv[0] = MKNOD;
-	argv[1] = mode_string;
-	argv[2] = filename;
-	argv[3] = type_string;
-	argv[4] = major_string;
-	argv[5] = minor_string;
-	argv[6] = NULL;
-	dbg ("executing %s %s %s %s %s %s",
-		argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
-	switch (fork()) {
-		case 0:
-			/* we are the child, so lets run the program */
-			execv (MKNOD, argv);
-			exit(0);
-			break;
-		case (-1):
-			dbg ("fork failed.");
-			retval = -EFAULT;
-			break;
-		default:
-			break;
-	}
+	retval = mknod(filename,mode,makedev(major,minor));
 	return retval;
+		
 }
 
 struct sysfs_class_device *get_class_dev(char *device_name)

[-- Attachment #2: udev-add.c.diff --]
[-- Type: application/octet-stream, Size: 1636 bytes --]

--- /root/udev-0.2/udev-add.c	2003-07-24 23:54:49.000000000 +0800
+++ /udev/udev-add.c	2003-08-01 09:45:24.651393112 +0800
@@ -81,45 +81,24 @@
  */
 static int create_node(char *name, char type, int major, int minor, int mode)
 {
-	char *argv[7];
-	char mode_string[100];
-	char type_string[3];
-	char major_string[20];
-	char minor_string[20];
 	char filename[255];
 	int retval = 0;
-
 	strncpy(filename, UDEV_ROOT, sizeof(filename));
 	strncat(filename, name, sizeof(filename));
+	if (type == 'b') {
+	       mode |= S_IFBLK;
+    	} else if ((type == 'c') || (type == 'u')){
+	        mode |= S_IFCHR;
+    	} else if ( type == 'p') {
+       		 mode |= S_IFIFO;
+    	} else {
+       		dbg("unknown node type %c\n", type);
+       		return -1;
+ 	}
 
-	snprintf(mode_string, sizeof(mode_string), "--mode=%#o", mode);
-	snprintf(type_string, sizeof(type_string), "%c", type);
-	snprintf(major_string, sizeof(major_string), "%d", major);
-	snprintf(minor_string, sizeof(minor_string), "%d", minor);
-	
-	argv[0] = MKNOD;
-	argv[1] = mode_string;
-	argv[2] = filename;
-	argv[3] = type_string;
-	argv[4] = major_string;
-	argv[5] = minor_string;
-	argv[6] = NULL;
-	dbg ("executing %s %s %s %s %s %s",
-		argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
-	switch (fork()) {
-		case 0:
-			/* we are the child, so lets run the program */
-			execv (MKNOD, argv);
-			exit(0);
-			break;
-		case (-1):
-			dbg ("fork failed.");
-			retval = -EFAULT;
-			break;
-		default:
-			break;
-	}
+	retval = mknod(filename,mode,makedev(major,minor));
 	return retval;
+		
 }
 
 struct sysfs_class_device *get_class_dev(char *device_name)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
                   ` (5 preceding siblings ...)
  2003-08-01  0:48 ` Guo, Min
@ 2003-08-05  0:19 ` Greg KH
  2003-08-05  2:22 ` Guo, Min
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2003-08-05  0:19 UTC (permalink / raw)
  To: linux-hotplug

On Fri, Aug 01, 2003 at 08:48:27AM +0800, Guo, Min wrote:
> Thanks,the revised patch.

Thanks, I've applied this and cleaned it up a big (report the error to
the debug log if there is one.)

greg k-h


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
                   ` (6 preceding siblings ...)
  2003-08-05  0:19 ` Greg KH
@ 2003-08-05  2:22 ` Guo, Min
  2003-08-05 10:08 ` Daniel Stekloff
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Guo, Min @ 2003-08-05  2:22 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 3076 bytes --]

Here are two function patch for libsys which metioned in TODO list, could you please take a look
at it and see whether it can meet the TODO req.

Thanks
Guo Min 
The content of this email message solely contains my own personal views,
and not those of my employer.
-----------------------------------------------------------------------------------------------------------------------------------------
diff -Nuar /udev/libsysfs/libsysfs.h libsysfs/libsysfs.h
--- /udev/libsysfs/libsysfs.h	2003-07-19 03:06:48.000000000 +0800
+++ libsysfs/libsysfs.h	2003-08-05 11:01:29.183292832 +0800
@@ -124,6 +124,9 @@
 extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
 extern int sysfs_read_attribute_value(const char *attrpath, char *value, 
 								size_t vsize);
+extern int sysfs_write_attribute(struct sysfs_attribute *sysattr,char *value);
+extern int sysfs_write_attribute_value(const char *attrpath, char *value);
+
 extern char *sysfs_get_value_from_attributes(struct sysfs_attribute *attr, 
 							const char * name);
 extern void sysfs_close_directory(struct sysfs_directory *sysdir);
diff -Nuar /udev/libsysfs/sysfs_dir.c libsysfs/sysfs_dir.c
--- /udev/libsysfs/sysfs_dir.c	2003-07-19 03:06:34.000000000 +0800
+++ libsysfs/sysfs_dir.c	2003-08-05 11:18:44.580888472 +0800
@@ -78,6 +78,34 @@
 
 	return sysattr;
 }
+/**
+ * sysfs_write_attribute: write value to the attribute
+ * @sysattr: attribute to write
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute(struct sysfs_attribute *sysattr,char  *value)
+{
+	if (sysattr == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	
+	if (!(sysattr->method & SYSFS_METHOD_STORE)) {
+		dprintf (stderr, "Store method not supported for attribute %s\n",
+			sysattr->path);
+		return -1;
+	}
+	
+	if (!value)
+		sysattr->value=value;
+	else
+	{
+		dprintf (stderr, "The value is NULL\n");
+		return -1;
+	}
+	return 0;
+}
+
 
 /**
  * sysfs_read_attribute: reads value from attribute
@@ -134,6 +162,41 @@
 }
 
 /**
+ * sysfs_write_attribute_value: given path to attribute, 
+ * value will be saved to the attribute.
+ * @attrpath: sysfs path to attribute
+ * @value: value to give to attribute
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute_value(const char *attrpath, char *value)
+{
+	struct sysfs_attribute *attr = NULL;
+	
+	if (attrpath == NULL || value == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	attr = sysfs_open_attribute(attrpath);
+	if (attr == NULL) {
+		dprintf(stderr, "Invalid attribute path %s\n", attrpath);
+		errno = EINVAL;
+		return -1;
+	}
+	
+	if((sysfs_write_attribute(attr,value)) != 0 ) {
+		dprintf(stderr, "Error write to attribute %s\n", attrpath);
+		sysfs_close_attribute(attr);
+		return -1;
+	}
+
+	sysfs_close_attribute(attr);
+
+	return 0;
+}
+
+
+/**
  * sysfs_read_attribute_value: given path to attribute, return its value.
  *	values can be up to a pagesize, if buffer is smaller the value will 
  *	be truncated. 

[-- Attachment #2: libsysfs.diff --]
[-- Type: application/octet-stream, Size: 2572 bytes --]

diff -Nuar /udev/libsysfs/libsysfs.h libsysfs/libsysfs.h
--- /udev/libsysfs/libsysfs.h	2003-07-19 03:06:48.000000000 +0800
+++ libsysfs/libsysfs.h	2003-08-05 11:01:29.183292832 +0800
@@ -124,6 +124,9 @@
 extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
 extern int sysfs_read_attribute_value(const char *attrpath, char *value, 
 								size_t vsize);
+extern int sysfs_write_attribute(struct sysfs_attribute *sysattr,char *value);
+extern int sysfs_write_attribute_value(const char *attrpath, char *value);
+
 extern char *sysfs_get_value_from_attributes(struct sysfs_attribute *attr, 
 							const char * name);
 extern void sysfs_close_directory(struct sysfs_directory *sysdir);
diff -Nuar /udev/libsysfs/sysfs_dir.c libsysfs/sysfs_dir.c
--- /udev/libsysfs/sysfs_dir.c	2003-07-19 03:06:34.000000000 +0800
+++ libsysfs/sysfs_dir.c	2003-08-05 11:18:44.580888472 +0800
@@ -78,6 +78,34 @@
 
 	return sysattr;
 }
+/**
+ * sysfs_write_attribute: write value to the attribute
+ * @sysattr: attribute to write
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute(struct sysfs_attribute *sysattr,char  *value)
+{
+	if (sysattr == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	
+	if (!(sysattr->method & SYSFS_METHOD_STORE)) {
+		dprintf (stderr, "Store method not supported for attribute %s\n",
+			sysattr->path);
+		return -1;
+	}
+	
+	if (!value)
+		sysattr->value=value;
+	else
+	{
+		dprintf (stderr, "The value is NULL\n");
+		return -1;
+	}
+	return 0;
+}
+
 
 /**
  * sysfs_read_attribute: reads value from attribute
@@ -134,6 +162,41 @@
 }
 
 /**
+ * sysfs_write_attribute_value: given path to attribute, 
+ * value will be saved to the attribute.
+ * @attrpath: sysfs path to attribute
+ * @value: value to give to attribute
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute_value(const char *attrpath, char *value)
+{
+	struct sysfs_attribute *attr = NULL;
+	
+	if (attrpath == NULL || value == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	attr = sysfs_open_attribute(attrpath);
+	if (attr == NULL) {
+		dprintf(stderr, "Invalid attribute path %s\n", attrpath);
+		errno = EINVAL;
+		return -1;
+	}
+	
+	if((sysfs_write_attribute(attr,value)) != 0 ) {
+		dprintf(stderr, "Error write to attribute %s\n", attrpath);
+		sysfs_close_attribute(attr);
+		return -1;
+	}
+
+	sysfs_close_attribute(attr);
+
+	return 0;
+}
+
+
+/**
  * sysfs_read_attribute_value: given path to attribute, return its value.
  *	values can be up to a pagesize, if buffer is smaller the value will 
  *	be truncated. 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
                   ` (7 preceding siblings ...)
  2003-08-05  2:22 ` Guo, Min
@ 2003-08-05 10:08 ` Daniel Stekloff
  2003-08-12  7:17 ` Guo, Min
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Daniel Stekloff @ 2003-08-05 10:08 UTC (permalink / raw)
  To: linux-hotplug


Hi Guo Min,

Thank you very much for the patch. It's a good start. Some ideas:

- sysfs_write_attribute needs to actually write the value out to the 
file/attribute. Use the path in sysfs_attribute.

 - sysfs_write_attribute should probably only need the sysfs_attribute 
*sysattr as an argument, the value being already assigned to the 
sysfs_attribute.

- sysfs_write_attribute_value could assign the value to the included 
sysfs_attribute and then call sysfs_write_attribute like you have it now.

- Please look at sysfs_read_attribute as a guide.

Thanks,

Dan


> Subject: RE: [ANNOUNCE] udev 0.2 release
> From: "Guo, Min" <min.guo@intel.com>
> To: "Greg KH" <greg@kroah.com>
> Cc: <linux-hotplug-devel@lists.sourceforge.net>
> Date: Tue, 5 Aug 2003 10:22:00 +0800
>
> Here are two function patch for libsys which metioned in TODO list, could
> you please take a look at it and see whether it can meet the TODO req.
>
> Thanks
> Guo Min
> The content of this email message solely contains my own personal views,
> and not those of my employer.
> ---------------------------------------------------------------------------
>-------------------------------------------------------------- diff -Nuar
> /udev/libsysfs/libsysfs.h libsysfs/libsysfs.h
> --- /udev/libsysfs/libsysfs.h	2003-07-19 03:06:48.000000000 +0800
> +++ libsysfs/libsysfs.h	2003-08-05 11:01:29.183292832 +0800
> @@ -124,6 +124,9 @@
>  extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
>  extern int sysfs_read_attribute_value(const char *attrpath, char *value,
>  								size_t vsize);
> +extern int sysfs_write_attribute(struct sysfs_attribute *sysattr,char
> *value); +extern int sysfs_write_attribute_value(const char *attrpath, char
> *value); +
>  extern char *sysfs_get_value_from_attributes(struct sysfs_attribute *attr,
>  							const char * name);
>  extern void sysfs_close_directory(struct sysfs_directory *sysdir);
> diff -Nuar /udev/libsysfs/sysfs_dir.c libsysfs/sysfs_dir.c
> --- /udev/libsysfs/sysfs_dir.c	2003-07-19 03:06:34.000000000 +0800
> +++ libsysfs/sysfs_dir.c	2003-08-05 11:18:44.580888472 +0800
> @@ -78,6 +78,34 @@
>
>  	return sysattr;
>  }
> +/**
> + * sysfs_write_attribute: write value to the attribute
> + * @sysattr: attribute to write
> + * returns 0 with success and -1 with error.
> + */
> +int sysfs_write_attribute(struct sysfs_attribute *sysattr,char  *value)
> +{
> +	if (sysattr = NULL) {
> +		errno = EINVAL;
> +		return -1;
> +	}
> +
> +	if (!(sysattr->method & SYSFS_METHOD_STORE)) {
> +		dprintf (stderr, "Store method not supported for attribute %s\n",
> +			sysattr->path);
> +		return -1;
> +	}
> +
> +	if (!value)
> +		sysattr->value=value;
> +	else
> +	{
> +		dprintf (stderr, "The value is NULL\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
>
>  /**
>   * sysfs_read_attribute: reads value from attribute
> @@ -134,6 +162,41 @@
>  }
>
>  /**
> + * sysfs_write_attribute_value: given path to attribute,
> + * value will be saved to the attribute.
> + * @attrpath: sysfs path to attribute
> + * @value: value to give to attribute
> + * returns 0 with success and -1 with error.
> + */
> +int sysfs_write_attribute_value(const char *attrpath, char *value)
> +{
> +	struct sysfs_attribute *attr = NULL;
> +
> +	if (attrpath = NULL || value = NULL) {
> +		errno = EINVAL;
> +		return -1;
> +	}
> +
> +	attr = sysfs_open_attribute(attrpath);
> +	if (attr = NULL) {
> +		dprintf(stderr, "Invalid attribute path %s\n", attrpath);
> +		errno = EINVAL;
> +		return -1;
> +	}
> +
> +	if((sysfs_write_attribute(attr,value)) != 0 ) {
> +		dprintf(stderr, "Error write to attribute %s\n", attrpath);
> +		sysfs_close_attribute(attr);
> +		return -1;
> +	}
> +
> +	sysfs_close_attribute(attr);
> +
> +	return 0;
> +}
> +
> +
> +/**
>   * sysfs_read_attribute_value: given path to attribute, return its value.
>   *	values can be up to a pagesize, if buffer is smaller the value will
>   *	be truncated.
>
>
>


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
                   ` (8 preceding siblings ...)
  2003-08-05 10:08 ` Daniel Stekloff
@ 2003-08-12  7:17 ` Guo, Min
  2003-08-12  7:24 ` Guo, Min
  2003-08-13  9:35 ` Daniel Stekloff
  11 siblings, 0 replies; 14+ messages in thread
From: Guo, Min @ 2003-08-12  7:17 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 3957 bytes --]

Thanks!The revised path!
----------------------------------------------------------------------------------------------------------
diff -Nuar /udev/libsysfs/libsysfs.h /root/udev-0.2/libsysfs/libsysfs.h
--- /udev/libsysfs/libsysfs.h	2003-07-19 03:06:48.000000000 +0800
+++ /root/udev-0.2/libsysfs/libsysfs.h	2003-08-12 16:05:36.483706096 +0800
@@ -124,6 +124,9 @@
 extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
 extern int sysfs_read_attribute_value(const char *attrpath, char *value, 
 								size_t vsize);
+extern int sysfs_write_attribute(struct sysfs_attribute *sysattr);
+extern int sysfs_write_attribute_value(const char *attrpath, char *value);
+
 extern char *sysfs_get_value_from_attributes(struct sysfs_attribute *attr, 
 							const char * name);
 extern void sysfs_close_directory(struct sysfs_directory *sysdir);
diff -Nuar /udev/libsysfs/sysfs_dir.c /root/udev-0.2/libsysfs/sysfs_dir.c
--- /udev/libsysfs/sysfs_dir.c	2003-07-19 03:06:34.000000000 +0800
+++ /root/udev-0.2/libsysfs/sysfs_dir.c	2003-08-12 16:07:45.000168624 +0800
@@ -78,6 +78,43 @@
 
 	return sysattr;
 }
+/**
+ * sysfs_write_attribute: write value to the attribute
+ * @sysattr: attribute to write
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute(struct sysfs_attribute *sysattr)
+{
+	int fd;
+	int length;
+	
+	if (sysattr == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	
+	if (!(sysattr->method & SYSFS_METHOD_STORE)) {
+		dprintf (stderr, "Store method not supported for attribute %s\n",
+			sysattr->path);
+		return -1;
+	}
+		
+	if ((fd = open(sysattr->path, O_RDWR)) < 0) {
+		dprintf (stderr, "Error reading attribute %s\n", sysattr->path);
+		return -1;
+	}
+
+	length = write(fd,sysattr->value,sizeof(sysattr->value));
+	if (length < 0) {
+		dprintf (stderr, "Error write to the attribute %s\n",
+			sysattr->path);
+		close(fd);
+		return -1;
+	}
+	close(fd);	
+	return 0;
+}
+
 
 /**
  * sysfs_read_attribute: reads value from attribute
@@ -134,6 +171,41 @@
 }
 
 /**
+ * sysfs_write_attribute_value: given path to attribute, 
+ * value will be saved to the attribute.
+ * @attrpath: sysfs path to attribute
+ * @value: value to give to attribute
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute_value(const char *attrpath, char *value)
+{
+	struct sysfs_attribute *attr = NULL;
+	
+	if (attrpath == NULL || value == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	attr = sysfs_open_attribute(attrpath);
+	if (attr == NULL) {
+		dprintf(stderr, "Invalid attribute path %s\n", attrpath);
+		errno = EINVAL;
+		return -1;
+	}
+	strncpy(attr->value,value,sizeof(value));
+	if((sysfs_write_attribute(attr) != 0 )){
+		dprintf(stderr, "Error write to attribute %s\n", attrpath);
+		sysfs_close_attribute(attr);
+		return -1;
+	}
+
+	sysfs_close_attribute(attr);
+
+	return 0;
+}
+
+
+/**
  * sysfs_read_attribute_value: given path to attribute, return its value.
  *	values can be up to a pagesize, if buffer is smaller the value will 
  *	be truncated. 
-----Original Message-----
From: Daniel Stekloff [mailto:dsteklof@us.ibm.com]
Sent: Tuesday, August 05, 2003 6:09 PM
To: Guo, Min
Cc: linux-hotplug-devel@lists.sourceforge.net; Greg KH
Subject: RE: [ANNOUNCE] udev 0.2 release 



Hi Guo Min,

Thank you very much for the patch. It's a good start. Some ideas:

- sysfs_write_attribute needs to actually write the value out to the 
file/attribute. Use the path in sysfs_attribute.

 - sysfs_write_attribute should probably only need the sysfs_attribute 
*sysattr as an argument, the value being already assigned to the 
sysfs_attribute.

- sysfs_write_attribute_value could assign the value to the included 
sysfs_attribute and then call sysfs_write_attribute like you have it now.

- Please look at sysfs_read_attribute as a guide.

Thanks,

Dan


[-- Attachment #2: libsysfs.diff --]
[-- Type: application/octet-stream, Size: 2896 bytes --]

diff -Nuar /udev/libsysfs/libsysfs.h /root/udev-0.2/libsysfs/libsysfs.h
--- /udev/libsysfs/libsysfs.h	2003-07-19 03:06:48.000000000 +0800
+++ /root/udev-0.2/libsysfs/libsysfs.h	2003-08-12 16:05:36.483706096 +0800
@@ -124,6 +124,9 @@
 extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
 extern int sysfs_read_attribute_value(const char *attrpath, char *value, 
 								size_t vsize);
+extern int sysfs_write_attribute(struct sysfs_attribute *sysattr);
+extern int sysfs_write_attribute_value(const char *attrpath, char *value);
+
 extern char *sysfs_get_value_from_attributes(struct sysfs_attribute *attr, 
 							const char * name);
 extern void sysfs_close_directory(struct sysfs_directory *sysdir);
diff -Nuar /udev/libsysfs/sysfs_dir.c /root/udev-0.2/libsysfs/sysfs_dir.c
--- /udev/libsysfs/sysfs_dir.c	2003-07-19 03:06:34.000000000 +0800
+++ /root/udev-0.2/libsysfs/sysfs_dir.c	2003-08-12 16:07:45.000168624 +0800
@@ -78,6 +78,43 @@
 
 	return sysattr;
 }
+/**
+ * sysfs_write_attribute: write value to the attribute
+ * @sysattr: attribute to write
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute(struct sysfs_attribute *sysattr)
+{
+	int fd;
+	int length;
+	
+	if (sysattr == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	
+	if (!(sysattr->method & SYSFS_METHOD_STORE)) {
+		dprintf (stderr, "Store method not supported for attribute %s\n",
+			sysattr->path);
+		return -1;
+	}
+		
+	if ((fd = open(sysattr->path, O_RDWR)) < 0) {
+		dprintf (stderr, "Error reading attribute %s\n", sysattr->path);
+		return -1;
+	}
+
+	length = write(fd,sysattr->value,sizeof(sysattr->value));
+	if (length < 0) {
+		dprintf (stderr, "Error write to the attribute %s\n",
+			sysattr->path);
+		close(fd);
+		return -1;
+	}
+	close(fd);	
+	return 0;
+}
+
 
 /**
  * sysfs_read_attribute: reads value from attribute
@@ -134,6 +171,41 @@
 }
 
 /**
+ * sysfs_write_attribute_value: given path to attribute, 
+ * value will be saved to the attribute.
+ * @attrpath: sysfs path to attribute
+ * @value: value to give to attribute
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute_value(const char *attrpath, char *value)
+{
+	struct sysfs_attribute *attr = NULL;
+	
+	if (attrpath == NULL || value == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	attr = sysfs_open_attribute(attrpath);
+	if (attr == NULL) {
+		dprintf(stderr, "Invalid attribute path %s\n", attrpath);
+		errno = EINVAL;
+		return -1;
+	}
+	strncpy(attr->value,value,sizeof(value));
+	if((sysfs_write_attribute(attr) != 0 )){
+		dprintf(stderr, "Error write to attribute %s\n", attrpath);
+		sysfs_close_attribute(attr);
+		return -1;
+	}
+
+	sysfs_close_attribute(attr);
+
+	return 0;
+}
+
+
+/**
  * sysfs_read_attribute_value: given path to attribute, return its value.
  *	values can be up to a pagesize, if buffer is smaller the value will 
  *	be truncated. 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
                   ` (9 preceding siblings ...)
  2003-08-12  7:17 ` Guo, Min
@ 2003-08-12  7:24 ` Guo, Min
  2003-08-13  9:35 ` Daniel Stekloff
  11 siblings, 0 replies; 14+ messages in thread
From: Guo, Min @ 2003-08-12  7:24 UTC (permalink / raw)
  To: linux-hotplug

How to write value to sysfs? now sysfs is only readable.

Thanks
Guo Min
-----Original Message-----
From: Guo, Min 
Sent: Tuesday, August 12, 2003 3:19 PM
To: 'Daniel Stekloff'
Cc: linux-hotplug-devel@lists.sourceforge.net; Greg KH
Subject: RE: [ANNOUNCE] udev 0.2 release 


Thanks!The revised path!
----------------------------------------------------------------------------------------------------------
diff -Nuar /udev/libsysfs/libsysfs.h /root/udev-0.2/libsysfs/libsysfs.h
--- /udev/libsysfs/libsysfs.h	2003-07-19 03:06:48.000000000 +0800
+++ /root/udev-0.2/libsysfs/libsysfs.h	2003-08-12 16:05:36.483706096 +0800
@@ -124,6 +124,9 @@
 extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
 extern int sysfs_read_attribute_value(const char *attrpath, char *value, 
 								size_t vsize);
+extern int sysfs_write_attribute(struct sysfs_attribute *sysattr);
+extern int sysfs_write_attribute_value(const char *attrpath, char *value);
+
 extern char *sysfs_get_value_from_attributes(struct sysfs_attribute *attr, 
 							const char * name);
 extern void sysfs_close_directory(struct sysfs_directory *sysdir);
diff -Nuar /udev/libsysfs/sysfs_dir.c /root/udev-0.2/libsysfs/sysfs_dir.c
--- /udev/libsysfs/sysfs_dir.c	2003-07-19 03:06:34.000000000 +0800
+++ /root/udev-0.2/libsysfs/sysfs_dir.c	2003-08-12 16:07:45.000168624 +0800
@@ -78,6 +78,43 @@
 
 	return sysattr;
 }
+/**
+ * sysfs_write_attribute: write value to the attribute
+ * @sysattr: attribute to write
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute(struct sysfs_attribute *sysattr)
+{
+	int fd;
+	int length;
+	
+	if (sysattr = NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	
+	if (!(sysattr->method & SYSFS_METHOD_STORE)) {
+		dprintf (stderr, "Store method not supported for attribute %s\n",
+			sysattr->path);
+		return -1;
+	}
+		
+	if ((fd = open(sysattr->path, O_RDWR)) < 0) {
+		dprintf (stderr, "Error reading attribute %s\n", sysattr->path);
+		return -1;
+	}
+
+	length = write(fd,sysattr->value,sizeof(sysattr->value));
+	if (length < 0) {
+		dprintf (stderr, "Error write to the attribute %s\n",
+			sysattr->path);
+		close(fd);
+		return -1;
+	}
+	close(fd);	
+	return 0;
+}
+
 
 /**
  * sysfs_read_attribute: reads value from attribute
@@ -134,6 +171,41 @@
 }
 
 /**
+ * sysfs_write_attribute_value: given path to attribute, 
+ * value will be saved to the attribute.
+ * @attrpath: sysfs path to attribute
+ * @value: value to give to attribute
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute_value(const char *attrpath, char *value)
+{
+	struct sysfs_attribute *attr = NULL;
+	
+	if (attrpath = NULL || value = NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	attr = sysfs_open_attribute(attrpath);
+	if (attr = NULL) {
+		dprintf(stderr, "Invalid attribute path %s\n", attrpath);
+		errno = EINVAL;
+		return -1;
+	}
+	strncpy(attr->value,value,sizeof(value));
+	if((sysfs_write_attribute(attr) != 0 )){
+		dprintf(stderr, "Error write to attribute %s\n", attrpath);
+		sysfs_close_attribute(attr);
+		return -1;
+	}
+
+	sysfs_close_attribute(attr);
+
+	return 0;
+}
+
+
+/**
  * sysfs_read_attribute_value: given path to attribute, return its value.
  *	values can be up to a pagesize, if buffer is smaller the value will 
  *	be truncated. 
-----Original Message-----
From: Daniel Stekloff [mailto:dsteklof@us.ibm.com]
Sent: Tuesday, August 05, 2003 6:09 PM
To: Guo, Min
Cc: linux-hotplug-devel@lists.sourceforge.net; Greg KH
Subject: RE: [ANNOUNCE] udev 0.2 release 



Hi Guo Min,

Thank you very much for the patch. It's a good start. Some ideas:

- sysfs_write_attribute needs to actually write the value out to the 
file/attribute. Use the path in sysfs_attribute.

 - sysfs_write_attribute should probably only need the sysfs_attribute 
*sysattr as an argument, the value being already assigned to the 
sysfs_attribute.

- sysfs_write_attribute_value could assign the value to the included 
sysfs_attribute and then call sysfs_write_attribute like you have it now.

- Please look at sysfs_read_attribute as a guide.

Thanks,

Dan



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ANNOUNCE] udev 0.2 release
  2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
                   ` (10 preceding siblings ...)
  2003-08-12  7:24 ` Guo, Min
@ 2003-08-13  9:35 ` Daniel Stekloff
  11 siblings, 0 replies; 14+ messages in thread
From: Daniel Stekloff @ 2003-08-13  9:35 UTC (permalink / raw)
  To: linux-hotplug


Thank you very much for the revised patch. We will put it into our tree. 

As for writing values to sysfs, sysfs files or attributes are sometimes 
writeable. You can write to them as you write to any file. For instance, I 
could have a "debug" file for my usb device driver. The driver could export 
the callback through sysfs as a file. Reading from the file returns the 
current "debug" state of the driver. Writing to the file would change the 
debug level for the driver. 

Is this what you were asking?

Thanks,

Dan


On Tuesday 12 August 2003 07:24 am, Guo, Min wrote:
> How to write value to sysfs? now sysfs is only readable.
>
> Thanks
> Guo Min
> -----Original Message-----
> From: Guo, Min
> Sent: Tuesday, August 12, 2003 3:19 PM
> To: 'Daniel Stekloff'
> Cc: linux-hotplug-devel@lists.sourceforge.net; Greg KH
> Subject: RE: [ANNOUNCE] udev 0.2 release
>
>
> Thanks!The revised path!
> ---------------------------------------------------------------------------
>------------------------------- diff -Nuar /udev/libsysfs/libsysfs.h
> /root/udev-0.2/libsysfs/libsysfs.h --- /udev/libsysfs/libsysfs.h	2003-07-19
> 03:06:48.000000000 +0800
> +++ /root/udev-0.2/libsysfs/libsysfs.h	2003-08-12 16:05:36.483706096 +0800
> @@ -124,6 +124,9 @@
>  extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
>  extern int sysfs_read_attribute_value(const char *attrpath, char *value,
>  								size_t vsize);
> +extern int sysfs_write_attribute(struct sysfs_attribute *sysattr);
> +extern int sysfs_write_attribute_value(const char *attrpath, char *value);
> +
>  extern char *sysfs_get_value_from_attributes(struct sysfs_attribute *attr,
>  							const char * name);
>  extern void sysfs_close_directory(struct sysfs_directory *sysdir);
> diff -Nuar /udev/libsysfs/sysfs_dir.c /root/udev-0.2/libsysfs/sysfs_dir.c
> --- /udev/libsysfs/sysfs_dir.c	2003-07-19 03:06:34.000000000 +0800
> +++ /root/udev-0.2/libsysfs/sysfs_dir.c	2003-08-12 16:07:45.000168624 +0800
> @@ -78,6 +78,43 @@
>
>  	return sysattr;
>  }
> +/**
> + * sysfs_write_attribute: write value to the attribute
> + * @sysattr: attribute to write
> + * returns 0 with success and -1 with error.
> + */
> +int sysfs_write_attribute(struct sysfs_attribute *sysattr)
> +{
> +	int fd;
> +	int length;
> +
> +	if (sysattr = NULL) {
> +		errno = EINVAL;
> +		return -1;
> +	}
> +
> +	if (!(sysattr->method & SYSFS_METHOD_STORE)) {
> +		dprintf (stderr, "Store method not supported for attribute %s\n",
> +			sysattr->path);
> +		return -1;
> +	}
> +
> +	if ((fd = open(sysattr->path, O_RDWR)) < 0) {
> +		dprintf (stderr, "Error reading attribute %s\n", sysattr->path);
> +		return -1;
> +	}
> +
> +	length = write(fd,sysattr->value,sizeof(sysattr->value));
> +	if (length < 0) {
> +		dprintf (stderr, "Error write to the attribute %s\n",
> +			sysattr->path);
> +		close(fd);
> +		return -1;
> +	}
> +	close(fd);
> +	return 0;
> +}
> +
>
>  /**
>   * sysfs_read_attribute: reads value from attribute
> @@ -134,6 +171,41 @@
>  }
>
>  /**
> + * sysfs_write_attribute_value: given path to attribute,
> + * value will be saved to the attribute.
> + * @attrpath: sysfs path to attribute
> + * @value: value to give to attribute
> + * returns 0 with success and -1 with error.
> + */
> +int sysfs_write_attribute_value(const char *attrpath, char *value)
> +{
> +	struct sysfs_attribute *attr = NULL;
> +
> +	if (attrpath = NULL || value = NULL) {
> +		errno = EINVAL;
> +		return -1;
> +	}
> +
> +	attr = sysfs_open_attribute(attrpath);
> +	if (attr = NULL) {
> +		dprintf(stderr, "Invalid attribute path %s\n", attrpath);
> +		errno = EINVAL;
> +		return -1;
> +	}
> +	strncpy(attr->value,value,sizeof(value));
> +	if((sysfs_write_attribute(attr) != 0 )){
> +		dprintf(stderr, "Error write to attribute %s\n", attrpath);
> +		sysfs_close_attribute(attr);
> +		return -1;
> +	}
> +
> +	sysfs_close_attribute(attr);
> +
> +	return 0;
> +}
> +
> +
> +/**
>   * sysfs_read_attribute_value: given path to attribute, return its value.
>   *	values can be up to a pagesize, if buffer is smaller the value will
>   *	be truncated.
> -----Original Message-----
> From: Daniel Stekloff [mailto:dsteklof@us.ibm.com]
> Sent: Tuesday, August 05, 2003 6:09 PM
> To: Guo, Min
> Cc: linux-hotplug-devel@lists.sourceforge.net; Greg KH
> Subject: RE: [ANNOUNCE] udev 0.2 release
>
>
>
> Hi Guo Min,
>
> Thank you very much for the patch. It's a good start. Some ideas:
>
> - sysfs_write_attribute needs to actually write the value out to the
> file/attribute. Use the path in sysfs_attribute.
>
>  - sysfs_write_attribute should probably only need the sysfs_attribute
> *sysattr as an argument, the value being already assigned to the
> sysfs_attribute.
>
> - sysfs_write_attribute_value could assign the value to the included
> sysfs_attribute and then call sysfs_write_attribute like you have it now.
>
> - Please look at sysfs_read_attribute as a guide.
>
> Thanks,
>
> Dan
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites including
> Data Reports, E-commerce, Portals, and Forums are available now.
> Download today and enter to win an XBOX or Visual Studio .NET.
> http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
> _______________________________________________
> Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
> Linux-hotplug-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ANNOUNCE] udev 0.2 release
@ 2003-07-25 21:47 Greg KH
  0 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2003-07-25 21:47 UTC (permalink / raw)
  To: linux-hotplug-devel, linux-kernel

Hi,

I've released the 0.2 version of udev into the wild, after surviving a
live demo at the 2003 Ottawa Linux Symposium during a presentation.  It
can be found at:
	kernel.org/pub/linux/utils/kernel/hotplug/udev-0.2.tar.gz

udev is a implementation of devfs in userspace using sysfs and
/sbin/hotplug.  It requires a 2.5/2.6 kernel to run properly.  The major
changes since the last release is that persistent device naming schemes
are now implemented.  Yeah, it's pretty rough, but it does prove that
the concept is sane and will end up working well for users.

There's a BitKeeper tree of the latest stuff available at:
	bk://kernel.bkbits.net/gregkh/udev/

I've also placed the slides from my OLS talk up at:
	http://www.kroah.com/linux/talks/ols_2003_udev_talk/

The paper which attempts to explain the background of udev, what it
does, and where it is going is at:
	http://archive.linuxsymposium.org/ols2003/Proceedings/All-Reprints/Reprint-Kroah-Hartman-OLS2003.pdf


Due to the rush of the development of udev in this past week (hacking at
it during the conference in an attempt to have something to show) there
are still a number of very rough corners present, a few known memory
leaks, and at least one hard coded path to my home directory for a
config file...  Please feel free to take it for a spin to see how well
things are progressing.

Patches are always welcome, and discussions of the implementation, and
future directions that the project should entail are welcome for now on
the linux-hotplug-devel mailing list (if it's over-run, a new list will
be started up, but I don't think that's necessary for now.)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2003-08-13  9:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
2003-07-26  0:18 ` Joshua Schmidlkofer
2003-07-26 15:57 ` Greg KH
2003-07-31  7:46 ` Guo, Min
2003-07-31  7:47 ` Guo, Min
2003-07-31 23:04 ` Greg KH
2003-08-01  0:48 ` Guo, Min
2003-08-05  0:19 ` Greg KH
2003-08-05  2:22 ` Guo, Min
2003-08-05 10:08 ` Daniel Stekloff
2003-08-12  7:17 ` Guo, Min
2003-08-12  7:24 ` Guo, Min
2003-08-13  9:35 ` Daniel Stekloff
  -- strict thread matches above, loose matches on Subject: below --
2003-07-25 21:47 Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.