From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Stekloff Date: Tue, 05 Aug 2003 10:08:45 +0000 Subject: RE: [ANNOUNCE] udev 0.2 release Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org 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" > To: "Greg KH" > Cc: > 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