linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [udev] remove '\n' from end of callout return
@ 2003-12-15  1:26 Kay Sievers
  2003-12-15  1:32 ` Kay Sievers
  0 siblings, 1 reply; 5+ messages in thread
From: Kay Sievers @ 2003-12-15  1:26 UTC (permalink / raw)
  To: linux-hotplug

Attched is a patch to remove a possible newline from the end
of the callout returned string. So we can use echo instead of "echo -n"
is a callout script.

thanks,
Kay



-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
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] 5+ messages in thread

* [udev] remove '\n' from end of callout return
  2003-12-15  1:26 [udev] remove '\n' from end of callout return Kay Sievers
@ 2003-12-15  1:32 ` Kay Sievers
  0 siblings, 0 replies; 5+ messages in thread
From: Kay Sievers @ 2003-12-15  1:32 UTC (permalink / raw)
  To: linux-hotplug

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

Uups, new mail.  It's better to attach the promised file :)

Attached is a patch to remove a possible newline from the end
of the callout returned string. So we can use "echo" instead of "echo -n"
in a callout script, to match with ID=

thanks,
Kay


03-remove-newline-from-callout-return.diff
  remove possible newline at end of callout output,
  for easier matching with ID=

[-- Attachment #2: 03-remove-newline-from-callout-return.diff --]
[-- Type: text/plain, Size: 491 bytes --]

diff -Nru a/namedev.c b/namedev.c
--- a/namedev.c	Mon Dec 15 02:22:46 2003
+++ b/namedev.c	Mon Dec 15 02:22:46 2003
@@ -266,6 +266,7 @@
 	char buffer[256];
 	char *arg;
 	char *args[CALLOUT_MAXARG];
+	char *pos;
 	int i;
 
 	dbg("callout to '%s'", dev->exec_program);
@@ -326,6 +327,9 @@
 				strncpy(value, buffer, len);
 			}
 		}
+		pos = value + strlen(value)-1;
+		if (pos[0] == '\n')
+			pos[0] = '\0';
 		dbg("callout returned '%s'", value);
 		close(fds[0]);
 		res = wait(&status);

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

* Re: [udev] remove '\n' from end of callout return
@ 2003-12-15  2:27 Kay Sievers
  0 siblings, 0 replies; 5+ messages in thread
From: Kay Sievers @ 2003-12-15  2:27 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Dec 15, 2003 at 02:32:20AM +0100, Kay Sievers wrote:

Yes, there are only 3 lines in the patch, but this one is still better :)

> Uups, new mail.  It's better to attach the promised file :)
> 
> Attached is a patch to remove a possible newline from the end
> of the callout returned string. So we can use "echo" instead of "echo -n"
> in a callout script, to match with ID> 
> thanks,
> Kay
> 
> 
> 03-remove-newline-from-callout-return.diff
>   remove possible newline at end of callout output,
>   for easier matching with ID

-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
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] 5+ messages in thread

* Re: [udev] remove '\n' from end of callout return
@ 2003-12-15  2:48 Kay Sievers
  0 siblings, 0 replies; 5+ messages in thread
From: Kay Sievers @ 2003-12-15  2:48 UTC (permalink / raw)
  To: linux-hotplug

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

Sorry, i hit the second time that key in Mutt that sends
the mail instead of selecting the file to attach?
We have for every line of code one mail now,
luckily the patch is so small :)

thanks,
Kay

> Yes, there are only 3 lines in the patch, but this one is still better :)
> 
> > Uups, new mail.  It's better to attach the promised file :)
> > 
> > Attached is a patch to remove a possible newline from the end
> > of the callout returned string. So we can use "echo" instead of "echo -n"
> > in a callout script, to match with ID=
> > 
> > thanks,
> > Kay
> > 
> > 
> > 03-remove-newline-from-callout-return.diff
> >   remove possible newline at end of callout output,
> >   for easier matching with ID=

[-- Attachment #2: 03-remove-newline-from-callout-return.diff --]
[-- Type: text/plain, Size: 942 bytes --]

diff -Nru a/namedev.c b/namedev.c
--- a/namedev.c	Mon Dec 15 03:25:29 2003
+++ b/namedev.c	Mon Dec 15 03:25:29 2003
@@ -264,7 +264,7 @@
 	pid_t pid;
 	int value_set = 0;
 	char buffer[256];
-	char *arg;
+	char *pos;
 	char *args[CALLOUT_MAXARG];
 	int i;
 
@@ -286,9 +286,9 @@
 		dup(fds[1]);	/* dup write side of pipe to STDOUT */
 		if (strchr(dev->exec_program, ' ')) {
 			/* callout with arguments */
-			arg = dev->exec_program;
+			pos = dev->exec_program;
 			for (i=0; i < CALLOUT_MAXARG-1; i++) {
-				args[i] = strsep(&arg, " ");
+				args[i] = strsep(&pos, " ");
 				if (args[i] == NULL)
 					break;
 			}
@@ -324,9 +324,12 @@
 			} else {
 				value_set = 1;
 				strncpy(value, buffer, len);
+				pos = value + strlen(value)-1;
+				if (pos[0] == '\n')
+				pos[0] = '\0';
+				dbg("callout returned '%s'", value);
 			}
 		}
-		dbg("callout returned '%s'", value);
 		close(fds[0]);
 		res = wait(&status);
 		if (res < 0) {

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

* Re: [udev] remove '\n' from end of callout return
@ 2003-12-15 22:38 Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2003-12-15 22:38 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Dec 15, 2003 at 03:48:04AM +0100, Kay Sievers wrote:
> Sorry, i hit the second time that key in Mutt that sends
> the mail instead of selecting the file to attach?
> We have for every line of code one mail now,
> luckily the patch is so small :)

Heh, thanks for all of the retrys :)

I've applied this version, thanks.

greg k-h


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
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] 5+ messages in thread

end of thread, other threads:[~2003-12-15 22:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-15  1:26 [udev] remove '\n' from end of callout return Kay Sievers
2003-12-15  1:32 ` Kay Sievers
  -- strict thread matches above, loose matches on Subject: below --
2003-12-15  2:27 Kay Sievers
2003-12-15  2:48 Kay Sievers
2003-12-15 22:38 Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).