From jgranado at redhat.com Tue Jun 17 12:50:38 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 14:50:38 +0200 Subject: [Firstaidkit-devel] Scripting miss behavior from parted Message-ID: <1213707039-7456-1-git-send-email-jgranado@redhat.com> Hi list: There is an issue with parted 1.8.1 in scripting mode. It sometimes does not know that it should just continue and not ask the user about anything. This patch addresses the creation of partitions when the command `parted -s /dev/sdb "mklabel gpt mkpart primary ext3 1s -1s"`. I'll send a test script that shows the misbehavior. I think that there is two ways out of this: 1. To react according to the value of opt_script_mode before we through the exception and format the exception accordingly. or, 2. search for the value of opt_script_mode in the exception code (ped_exception_throw function) the and always return a yes for a yes_no exception question. IMO we should go with the first. This allows us to actually change the warning message and not print the "Is this still acceptable for you" message. The message should include a question when in interactive mode, and should not include a question when in scripting mode. This could also be done if we make the change in the exception code, but we would have to change the ped_exception_throw function and the code that calls the function as well as we would have to anticipate ped_exception_throw behavior and change the message format accordingly. I think that there might be a case where we need the ped_exception_throw function to stop when in opt_script_mode is set. Like when a command is not really suppose to be scriptable. The first option means of course that we need to look for all the places that we need to check the opt_script_mode variable and not wait for answers from the user, but I think community testing can take care of those :) This is not the last draft of the patch, I post it to the list to get some feedback. Comments on the patch are greatly appreciated. From jgranado at redhat.com Tue Jun 17 12:50:39 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 14:50:39 +0200 Subject: [Firstaidkit-devel] [PATCH] Skip all the interaction with the use if we are in script mode. In-Reply-To: <1213707039-7456-1-git-send-email-jgranado@redhat.com> References: <1213707039-7456-1-git-send-email-jgranado@redhat.com> Message-ID: <1213707039-7456-2-git-send-email-jgranado@redhat.com> --- parted/parted.c | 86 ++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 53 insertions(+), 33 deletions(-) diff --git a/parted/parted.c b/parted/parted.c index 9f79ea4..81b7805 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -776,23 +776,33 @@ do_mkpart (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) - { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) + { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; @@ -936,22 +946,32 @@ do_mkpartfs (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; -- 1.5.3.8 From jgranado at redhat.com Tue Jun 17 14:05:02 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:05:02 +0200 Subject: [Firstaidkit-devel] Scripting miss behavior from parted In-Reply-To: y References: y Message-ID: <1213711503-8057-1-git-send-email-jgranado@redhat.com> Hi list: There is an issue with parted 1.8.1 in scripting mode. It sometimes does not know that it should just continue and not ask the user about anything. This patch addresses the creation of partitions when the command `parted -s /dev/sdb "mklabel gpt mkpart primary ext3 1s -1s"`. I'll send a test script that shows the misbehavior. I think that there is two ways out of this: 1. To react according to the value of opt_script_mode before we through the exception and format the exception accordingly. or, 2. search for the value of opt_script_mode in the exception code (ped_exception_throw function) the and always return a yes for a yes_no exception question. IMO we should go with the first. This allows us to actually change the warning message and not print the "Is this still acceptable for you" message. The message should include a question when in interactive mode, and should not include a question when in scripting mode. This could also be done if we make the change in the exception code, but we would have to change the ped_exception_throw function and the code that calls the function as well as we would have to anticipate ped_exception_throw behavior and change the message format accordingly. I think that there might be a case where we need the ped_exception_throw function to stop when in opt_script_mode is set. Like when a command is not really suppose to be scriptable. The first option means of course that we need to look for all the places that we need to check the opt_script_mode variable and not wait for answers from the user, but I think community testing can take care of those :) This is not the last draft of the patch, I post it to the list to get some feedback. Comments on the patch are greatly appreciated. From jgranado at redhat.com Tue Jun 17 14:05:03 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:05:03 +0200 Subject: [Firstaidkit-devel] [PATCH] Skip all the interaction with the use if we are in script mode. In-Reply-To: y References: y Message-ID: <1213711503-8057-2-git-send-email-jgranado@redhat.com> --- parted/parted.c | 86 ++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 53 insertions(+), 33 deletions(-) diff --git a/parted/parted.c b/parted/parted.c index 9f79ea4..81b7805 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -776,23 +776,33 @@ do_mkpart (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) - { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) + { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; @@ -936,22 +946,32 @@ do_mkpartfs (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; -- 1.5.3.8 From jgranado at redhat.com Tue Jun 17 14:15:08 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:15:08 +0200 Subject: [Firstaidkit-devel] [PATCH] Skip all the interaction with the use if we are in script mode. In-Reply-To: --suppress-from References: --suppress-from Message-ID: <1213712108-12541-2-git-send-email-jgranado@redhat.com> --- parted/parted.c | 86 ++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 53 insertions(+), 33 deletions(-) diff --git a/parted/parted.c b/parted/parted.c index 9f79ea4..81b7805 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -776,23 +776,33 @@ do_mkpart (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) - { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) + { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; @@ -936,22 +946,32 @@ do_mkpartfs (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; -- 1.5.3.8 From jgranado at redhat.com Tue Jun 17 14:15:07 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:15:07 +0200 Subject: [Firstaidkit-devel] Scripting miss behavior from parted In-Reply-To: --suppress-from References: --suppress-from Message-ID: <1213712108-12541-1-git-send-email-jgranado@redhat.com> Hi list: There is an issue with parted 1.8.1 in scripting mode. It sometimes does not know that it should just continue and not ask the user about anything. This patch addresses the creation of partitions when the command `parted -s /dev/sdb "mklabel gpt mkpart primary ext3 1s -1s"`. I'll send a test script that shows the misbehavior. I think that there is two ways out of this: 1. To react according to the value of opt_script_mode before we through the exception and format the exception accordingly. or, 2. search for the value of opt_script_mode in the exception code (ped_exception_throw function) the and always return a yes for a yes_no exception question. IMO we should go with the first. This allows us to actually change the warning message and not print the "Is this still acceptable for you" message. The message should include a question when in interactive mode, and should not include a question when in scripting mode. This could also be done if we make the change in the exception code, but we would have to change the ped_exception_throw function and the code that calls the function as well as we would have to anticipate ped_exception_throw behavior and change the message format accordingly. I think that there might be a case where we need the ped_exception_throw function to stop when in opt_script_mode is set. Like when a command is not really suppose to be scriptable. The first option means of course that we need to look for all the places that we need to check the opt_script_mode variable and not wait for answers from the user, but I think community testing can take care of those :) This is not the last draft of the patch, I post it to the list to get some feedback. Comments on the patch are greatly appreciated. From jgranado at redhat.com Tue Jun 17 14:19:13 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:19:13 +0200 Subject: [Firstaidkit-devel] Scripting miss behavior from parted In-Reply-To: --suppress-cc References: --suppress-cc Message-ID: <1213712354-14445-1-git-send-email-jgranado@redhat.com> Hi list: There is an issue with parted 1.8.1 in scripting mode. It sometimes does not know that it should just continue and not ask the user about anything. This patch addresses the creation of partitions when the command `parted -s /dev/sdb "mklabel gpt mkpart primary ext3 1s -1s"`. I'll send a test script that shows the misbehavior. I think that there is two ways out of this: 1. To react according to the value of opt_script_mode before we through the exception and format the exception accordingly. or, 2. search for the value of opt_script_mode in the exception code (ped_exception_throw function) the and always return a yes for a yes_no exception question. IMO we should go with the first. This allows us to actually change the warning message and not print the "Is this still acceptable for you" message. The message should include a question when in interactive mode, and should not include a question when in scripting mode. This could also be done if we make the change in the exception code, but we would have to change the ped_exception_throw function and the code that calls the function as well as we would have to anticipate ped_exception_throw behavior and change the message format accordingly. I think that there might be a case where we need the ped_exception_throw function to stop when in opt_script_mode is set. Like when a command is not really suppose to be scriptable. The first option means of course that we need to look for all the places that we need to check the opt_script_mode variable and not wait for answers from the user, but I think community testing can take care of those :) This is not the last draft of the patch, I post it to the list to get some feedback. Comments on the patch are greatly appreciated. From jgranado at redhat.com Tue Jun 17 14:19:14 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:19:14 +0200 Subject: [Firstaidkit-devel] [PATCH] Skip all the interaction with the use if we are in script mode. In-Reply-To: --suppress-cc References: --suppress-cc Message-ID: <1213712354-14445-2-git-send-email-jgranado@redhat.com> --- parted/parted.c | 86 ++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 53 insertions(+), 33 deletions(-) diff --git a/parted/parted.c b/parted/parted.c index 9f79ea4..81b7805 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -776,23 +776,33 @@ do_mkpart (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) - { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) + { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; @@ -936,22 +946,32 @@ do_mkpartfs (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; -- 1.5.3.8 From jgranado at redhat.com Tue Jun 17 14:26:47 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:26:47 +0200 Subject: [Firstaidkit-devel] Scripting miss behavior from parted In-Reply-To: --suppress-all References: --suppress-all Message-ID: <1213712808-17868-1-git-send-email-jgranado@redhat.com> Hi list: There is an issue with parted 1.8.1 in scripting mode. It sometimes does not know that it should just continue and not ask the user about anything. This patch addresses the creation of partitions when the command `parted -s /dev/sdb "mklabel gpt mkpart primary ext3 1s -1s"`. I'll send a test script that shows the misbehavior. I think that there is two ways out of this: 1. To react according to the value of opt_script_mode before we through the exception and format the exception accordingly. or, 2. search for the value of opt_script_mode in the exception code (ped_exception_throw function) the and always return a yes for a yes_no exception question. IMO we should go with the first. This allows us to actually change the warning message and not print the "Is this still acceptable for you" message. The message should include a question when in interactive mode, and should not include a question when in scripting mode. This could also be done if we make the change in the exception code, but we would have to change the ped_exception_throw function and the code that calls the function as well as we would have to anticipate ped_exception_throw behavior and change the message format accordingly. I think that there might be a case where we need the ped_exception_throw function to stop when in opt_script_mode is set. Like when a command is not really suppose to be scriptable. The first option means of course that we need to look for all the places that we need to check the opt_script_mode variable and not wait for answers from the user, but I think community testing can take care of those :) This is not the last draft of the patch, I post it to the list to get some feedback. Comments on the patch are greatly appreciated. From jgranado at redhat.com Tue Jun 17 14:26:48 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:26:48 +0200 Subject: [Firstaidkit-devel] [PATCH] Skip all the interaction with the use if we are in script mode. In-Reply-To: --suppress-all References: --suppress-all Message-ID: <1213712808-17868-2-git-send-email-jgranado@redhat.com> --- parted/parted.c | 86 ++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 53 insertions(+), 33 deletions(-) diff --git a/parted/parted.c b/parted/parted.c index 9f79ea4..81b7805 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -776,23 +776,33 @@ do_mkpart (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) - { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) + { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; @@ -936,22 +946,32 @@ do_mkpartfs (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; -- 1.5.3.8 From jgranado at redhat.com Tue Jun 17 14:39:10 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:39:10 +0200 Subject: [Firstaidkit-devel] [PATCH] Skip all the interaction with the use if we are in script mode. In-Reply-To: <1213713550-23673-1-git-send-email-jgranado@redhat.com> References: --no-chain-reply-to <1213713550-23673-1-git-send-email-jgranado@redhat.com> Message-ID: <1213713550-23673-2-git-send-email-jgranado@redhat.com> --- parted/parted.c | 86 ++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 53 insertions(+), 33 deletions(-) diff --git a/parted/parted.c b/parted/parted.c index 9f79ea4..81b7805 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -776,23 +776,33 @@ do_mkpart (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) - { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) + { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; @@ -936,22 +946,32 @@ do_mkpartfs (PedDevice** dev) start_sol = ped_unit_format (*dev, part->geom.start); end_sol = ped_unit_format (*dev, part->geom.end); - switch (ped_exception_throw ( - PED_EXCEPTION_WARNING, - PED_EXCEPTION_YES_NO, - _("You requested a partition from %s to %s.\n" - "The closest location we can manage is " - "%s to %s. " - "Is this still acceptable to you?"), - start_usr, end_usr, start_sol, end_sol)) { - case PED_EXCEPTION_YES: - /* all is well in this state */ - break; - case PED_EXCEPTION_NO: - case PED_EXCEPTION_UNHANDLED: - default: - /* undo partition addition */ - goto error_remove_part; + if(!opt_script_mode){ + switch (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s. " + "Is this still acceptable to you?"), + start_usr, end_usr, start_sol, end_sol)) { + case PED_EXCEPTION_YES: + /* all is well in this state */ + break; + case PED_EXCEPTION_NO: + case PED_EXCEPTION_UNHANDLED: + default: + /* undo partition addition */ + goto error_remove_part; + } + } else { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_OK, + _("You requested a partition from %s to %s.\n" + "The closest location we can manage is " + "%s to %s."), + start_usr, end_usr, start_sol, end_sol); } } else { goto error_remove_part; -- 1.5.4.1 From jgranado at redhat.com Tue Jun 17 14:39:09 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Tue, 17 Jun 2008 16:39:09 +0200 Subject: [Firstaidkit-devel] Scripting miss behavior from parted In-Reply-To: --no-chain-reply-to References: --no-chain-reply-to Message-ID: <1213713550-23673-1-git-send-email-jgranado@redhat.com> Hi list: There is an issue with parted 1.8.1 in scripting mode. It sometimes does not know that it should just continue and not ask the user about anything. This patch addresses the creation of partitions when the command `parted -s /dev/sdb "mklabel gpt mkpart primary ext3 1s -1s"`. I'll send a test script that shows the misbehavior. I think that there is two ways out of this: 1. To react according to the value of opt_script_mode before we through the exception and format the exception accordingly. or, 2. search for the value of opt_script_mode in the exception code (ped_exception_throw function) the and always return a yes for a yes_no exception question. IMO we should go with the first. This allows us to actually change the warning message and not print the "Is this still acceptable for you" message. The message should include a question when in interactive mode, and should not include a question when in scripting mode. This could also be done if we make the change in the exception code, but we would have to change the ped_exception_throw function and the code that calls the function as well as we would have to anticipate ped_exception_throw behavior and change the message format accordingly. I think that there might be a case where we need the ped_exception_throw function to stop when in opt_script_mode is set. Like when a command is not really suppose to be scriptable. The first option means of course that we need to look for all the places that we need to check the opt_script_mode variable and not wait for answers from the user, but I think community testing can take care of those :) This is not the last draft of the patch, I post it to the list to get some feedback. Comments on the patch are greatly appreciated. From jgranado at redhat.com Wed Jun 18 15:58:38 2008 From: jgranado at redhat.com (Joel Andres Granados) Date: Wed, 18 Jun 2008 17:58:38 +0200 Subject: [Firstaidkit-devel] noise mail Message-ID: <485930AE.8040609@redhat.com> I apologize for whatever inconvenience there was with my previous mails. It seems that my git configuration and my smtp configuration did not agree with me :) -- Joel Andres Granados Red Hat / Brno, Czech Republic